WebExpressionContextProvider.java

1
package fr.sii.ogham.spring.v2.template.thymeleaf;
2
3
import java.util.Map;
4
5
import javax.servlet.ServletContext;
6
import javax.servlet.http.HttpServletRequest;
7
import javax.servlet.http.HttpServletResponse;
8
9
import org.springframework.context.ApplicationContext;
10
import org.thymeleaf.IEngineConfiguration;
11
import org.thymeleaf.ITemplateEngine;
12
import org.thymeleaf.context.IContext;
13
import org.thymeleaf.context.WebExpressionContext;
14
15
import fr.sii.ogham.core.template.context.Context;
16
import fr.sii.ogham.spring.template.thymeleaf.ThymeleafWebContextProvider;
17
import fr.sii.ogham.spring.util.compat.HttpServletRequestWrapper;
18
import fr.sii.ogham.spring.util.compat.HttpServletResponseWrapper;
19
import fr.sii.ogham.spring.util.compat.ServletContextWrapper;
20
21
/**
22
 * Generate an instance of {@link WebExpressionContext} for Thymeleaf v3.
23
 *
24
 * This is used to mimic the behavior of {@link org.thymeleaf.spring5.view.ThymeleafView} in order to give
25
 * access to {@link HttpServletRequest}, {@link HttpServletResponse} and
26
 * {@link ServletContext} from templates.
27
 *
28
 * @author Aurélien Baudet
29
 *
30
 */
31
public class WebExpressionContextProvider implements ThymeleafWebContextProvider {
32
	private final ITemplateEngine viewTemplateEngine;
33
34
	public WebExpressionContextProvider(ITemplateEngine viewTemplateEngine) {
35
		super();
36
		this.viewTemplateEngine = viewTemplateEngine;
37
	}
38
39
	@Override
40
	public IContext getWebContext(Context context, IContext base, HttpServletRequestWrapper request, HttpServletResponseWrapper response, ServletContextWrapper servletContext, ApplicationContext applicationContext,
41
								  Map<String, Object> springModel) {
42
		final IEngineConfiguration configuration = viewTemplateEngine.getConfiguration();
43 1 1. getWebContext : replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/WebExpressionContextProvider::getWebContext → RUN_ERROR
		return new WebExpressionContext(configuration, request.get(), response.get(), servletContext.get(), base.getLocale(), springModel);
44
	}
45
46
}

Mutations

43

1.1
Location : getWebContext
Killed by :
replaced return value with null for fr/sii/ogham/spring/v2/template/thymeleaf/WebExpressionContextProvider::getWebContext → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1