How do I bring the context for processing the template to the executor
Hey,
I currently struggle with creating the variables hat should be used to fill the templates from the surrounding java JUnit code. I know I can do it from within the thtest-file but that is not a viable solution as the context contains multiple aggregated objects. Is there an intended way to do so? If not, i would like to request it.
I already asked this on stackoverflow some time ago but did no receive any response or solution to it.
I found this solution:
`public class WebProcessingContextBuilderWithJavaVariables extends WebProcessingContextBuilder {
private final Map<String, Object> vars;
public WebProcessingContextBuilderWithJavaVariables(Map<String, Object> variables) {
vars = variables;
}
@Override
protected void doAdditionalVariableProcessing(
final ITest test,
final HttpServletRequest request, final HttpServletResponse response, final ServletContext servletContext,
final Locale locale, final Map<String, Object> variables) {
variables.putAll(vars);
}
}
@Test void someTest() { HashMap<String, Object> vars = new HashMap<>(); vars.put("key", validations); executor.setProcessingContextBuilder(new WebProcessingContextBuilderWithJavaVariables(vars)); executor.execute("classpath:template.thtest");
Assertions.assertTrue(executor.isAllOK());
}`