package it.mice.voila.runtime.web.filter;

import java.io.IOException;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequestWrapper;

public class MockRequestDispatcher implements RequestDispatcher {

	private RequestDispatcher wrappedRequestDispatcher;
	private HttpServletRequestWrapper mockRequest;

	public MockRequestDispatcher(HttpServletRequestWrapper mockRequest, String path) {
		super();
		this.wrappedRequestDispatcher = mockRequest.getRequest().getRequestDispatcher(path);
		this.mockRequest = mockRequest;
	}

	public void forward(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {
		wrappedRequestDispatcher.forward(mockRequest.getRequest(), response);
	}

	public void include(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {
		wrappedRequestDispatcher.include(mockRequest.getRequest(), response);
	}

}
