Search in sources :

Example 11 with ViewContext

use of com.tvd12.ezyhttp.server.core.view.ViewContext in project ezyhttp by youngmonkeys.

the class ApplicationContextBuilderTest method buildViewContextViewContextNotNull.

@Test
public void buildViewContextViewContextNotNull() {
    // given
    EzyBeanContext beanContext = mock(EzyBeanContext.class);
    ViewContext viewContext = mock(ViewContext.class);
    when(beanContext.getSingleton(ViewContext.class)).thenReturn(viewContext);
    EzySingletonFactory singletonFactory = mock(EzySingletonFactory.class);
    when(beanContext.getSingletonFactory()).thenReturn(singletonFactory);
    ApplicationContextBuilder sut = new ApplicationContextBuilder();
    // when
    ViewContext actual = MethodInvoker.create().object(sut).method("buildViewContext").param(EzyBeanContext.class, beanContext).invoke(ViewContext.class);
    // then
    Asserts.assertEquals(viewContext, actual);
    verify(beanContext, times(1)).getSingleton(ViewContext.class);
    verify(beanContext, times(1)).getSingletonFactory();
    verify(singletonFactory, times(1)).addSingleton(viewContext);
}
Also used : ViewContext(com.tvd12.ezyhttp.server.core.view.ViewContext) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzySingletonFactory(com.tvd12.ezyfox.bean.EzySingletonFactory) ApplicationContextBuilder(com.tvd12.ezyhttp.server.core.ApplicationContextBuilder) Test(org.testng.annotations.Test)

Aggregations

ViewContext (com.tvd12.ezyhttp.server.core.view.ViewContext)10 Test (org.testng.annotations.Test)9 TemplateResolver (com.tvd12.ezyhttp.server.core.view.TemplateResolver)7 View (com.tvd12.ezyhttp.server.core.view.View)5 ThymeleafViewContextBuilder (com.tvd12.ezyhttp.server.thymeleaf.ThymeleafViewContextBuilder)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 PrintWriter (java.io.PrintWriter)4 ServletContext (javax.servlet.ServletContext)4 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)3 ApplicationContextBuilder (com.tvd12.ezyhttp.server.core.ApplicationContextBuilder)3 ViewContextBuilder (com.tvd12.ezyhttp.server.core.view.ViewContextBuilder)3 ViewDecorator (com.tvd12.ezyhttp.server.core.view.ViewDecorator)3 EzySingletonFactory (com.tvd12.ezyfox.bean.EzySingletonFactory)2 AbsentMessageResolver (com.tvd12.ezyhttp.server.core.view.AbsentMessageResolver)2 ViewDialect (com.tvd12.ezyhttp.server.core.view.ViewDialect)2 Cookie (javax.servlet.http.Cookie)2 MultiValueMap (com.tvd12.ezyhttp.core.data.MultiValueMap)1 ResponseEntity (com.tvd12.ezyhttp.core.response.ResponseEntity)1 RequestCookie (com.tvd12.ezyhttp.server.core.annotation.RequestCookie)1