Search in sources :

Example 1 with JavaScriptBootstrapContext

use of com.vaadin.flow.server.communication.JavaScriptBootstrapHandler.JavaScriptBootstrapContext in project flow by vaadin.

the class BootstrapContextTest method getPushAnnotation_routeTargetPresents_pushFromTheClassDefinitionIsUsed.

@Test
public void getPushAnnotation_routeTargetPresents_pushFromTheClassDefinitionIsUsed() {
    ui.getInternals().getRouter().getRegistry().setRoute("foo", MainView.class, Collections.emptyList());
    Mockito.when(request.getParameter(ApplicationConstants.REQUEST_LOCATION_PARAMETER)).thenReturn("foo");
    BootstrapContext context = new JavaScriptBootstrapContext(request, Mockito.mock(VaadinResponse.class), ui, callback);
    Optional<Push> push = context.getPageConfigurationAnnotation(Push.class);
    Assert.assertTrue(push.isPresent());
    Push pushAnnotation = push.get();
    Assert.assertEquals(PushMode.MANUAL, pushAnnotation.value());
    Assert.assertEquals(Transport.LONG_POLLING, pushAnnotation.transport());
}
Also used : JavaScriptBootstrapContext(com.vaadin.flow.server.communication.JavaScriptBootstrapHandler.JavaScriptBootstrapContext) BootstrapContext(com.vaadin.flow.server.BootstrapHandler.BootstrapContext) JavaScriptBootstrapContext(com.vaadin.flow.server.communication.JavaScriptBootstrapHandler.JavaScriptBootstrapContext) Push(com.vaadin.flow.component.page.Push) Test(org.junit.Test)

Example 2 with JavaScriptBootstrapContext

use of com.vaadin.flow.server.communication.JavaScriptBootstrapHandler.JavaScriptBootstrapContext in project flow by vaadin.

the class BootstrapContextTest method getPushAnnotation_routeTargetPresents_pushDefinedOnParentLayout_pushFromTheClassDefinitionIsUsed.

@Test
public void getPushAnnotation_routeTargetPresents_pushDefinedOnParentLayout_pushFromTheClassDefinitionIsUsed() {
    ui.getInternals().getRouter().getRegistry().setRoute("foo", OtherView.class, Collections.singletonList(MainView.class));
    Mockito.when(request.getParameter(ApplicationConstants.REQUEST_LOCATION_PARAMETER)).thenReturn("foo");
    BootstrapContext context = new JavaScriptBootstrapContext(request, Mockito.mock(VaadinResponse.class), ui, callback);
    Optional<Push> push = context.getPageConfigurationAnnotation(Push.class);
    Assert.assertTrue(push.isPresent());
    Push pushAnnotation = push.get();
    Assert.assertEquals(PushMode.MANUAL, pushAnnotation.value());
    Assert.assertEquals(Transport.LONG_POLLING, pushAnnotation.transport());
}
Also used : JavaScriptBootstrapContext(com.vaadin.flow.server.communication.JavaScriptBootstrapHandler.JavaScriptBootstrapContext) BootstrapContext(com.vaadin.flow.server.BootstrapHandler.BootstrapContext) JavaScriptBootstrapContext(com.vaadin.flow.server.communication.JavaScriptBootstrapHandler.JavaScriptBootstrapContext) Push(com.vaadin.flow.component.page.Push) Test(org.junit.Test)

Aggregations

Push (com.vaadin.flow.component.page.Push)2 BootstrapContext (com.vaadin.flow.server.BootstrapHandler.BootstrapContext)2 JavaScriptBootstrapContext (com.vaadin.flow.server.communication.JavaScriptBootstrapHandler.JavaScriptBootstrapContext)2 Test (org.junit.Test)2