use of com.tvd12.ezyhttp.server.thymeleaf.ThymeleafViewContextBuilder in project ezyhttp by youngmonkeys.
the class ThymeleafViewContextTest method test.
@Test
public void test() throws Exception {
// given
TemplateResolver resolver = TemplateResolver.builder().build();
ViewContext viewContext = new ThymeleafViewContextBuilder().templateResolver(resolver).build();
ServletContext servletContext = mock(ServletContext.class);
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PrintWriter writer = mock(PrintWriter.class);
when(response.getWriter()).thenReturn(writer);
View view = View.builder().template("index.html").build();
// when
viewContext.render(servletContext, request, response, view);
// then
Asserts.assertNotNull(viewContext);
}
use of com.tvd12.ezyhttp.server.thymeleaf.ThymeleafViewContextBuilder in project ezyhttp by youngmonkeys.
the class ThymeleafViewContextTest method renderWithViewDecorator.
@Test
public void renderWithViewDecorator() throws Exception {
// given
TemplateResolver resolver = TemplateResolver.builder().build();
ViewDecorator viewDecorator = mock(ViewDecorator.class);
ViewContext viewContext = new ThymeleafViewContextBuilder().templateResolver(resolver).viewDecorators(Collections.singletonList(viewDecorator)).build();
ServletContext servletContext = mock(ServletContext.class);
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PrintWriter writer = mock(PrintWriter.class);
when(response.getWriter()).thenReturn(writer);
View view = View.builder().template("index.html").build();
// when
viewContext.render(servletContext, request, response, view);
// then
Asserts.assertNotNull(viewContext);
verify(viewDecorator, times(1)).decorate(request, view);
}
use of com.tvd12.ezyhttp.server.thymeleaf.ThymeleafViewContextBuilder in project ezyhttp by youngmonkeys.
the class ThymeleafViewContextBuilderTest method test.
@Test
public void test() {
// given
TemplateResolver resolver = TemplateResolver.builder().build();
ViewContextBuilder sut = new ThymeleafViewContextBuilder().templateResolver(resolver);
// when
ViewContext viewContext = sut.build();
// then
Asserts.assertNotNull(viewContext);
}
use of com.tvd12.ezyhttp.server.thymeleaf.ThymeleafViewContextBuilder in project ezyhttp by youngmonkeys.
the class ThymeleafViewContextTest method renderWithDialectButNotViewDialect.
@Test
public void renderWithDialectButNotViewDialect() throws Exception {
// given
TemplateResolver resolver = TemplateResolver.builder().build();
ViewDialect viewDialect = mock(ViewDialect.class);
ViewContext viewContext = new ThymeleafViewContextBuilder().templateResolver(resolver).viewDialects(Collections.singletonList(viewDialect)).build();
ServletContext servletContext = mock(ServletContext.class);
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PrintWriter writer = mock(PrintWriter.class);
when(response.getWriter()).thenReturn(writer);
View view = View.builder().template("index.html").build();
// when
viewContext.render(servletContext, request, response, view);
// then
Asserts.assertNotNull(viewContext);
}
use of com.tvd12.ezyhttp.server.thymeleaf.ThymeleafViewContextBuilder in project ezyhttp by youngmonkeys.
the class ThymeleafViewContextTest method renderWithViewDialect.
@Test
public void renderWithViewDialect() throws Exception {
// given
TemplateResolver resolver = TemplateResolver.builder().build();
ViewContext viewContext = new ThymeleafViewContextBuilder().templateResolver(resolver).viewDialects(Collections.singletonList(new VewHelloDialect())).build();
ServletContext servletContext = mock(ServletContext.class);
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
PrintWriter writer = mock(PrintWriter.class);
when(response.getWriter()).thenReturn(writer);
View view = View.builder().template("index.html").build();
// when
viewContext.render(servletContext, request, response, view);
// then
Asserts.assertNotNull(viewContext);
}
Aggregations