Search in sources :

Example 41 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class RouterLinkTest method noImplicitRouter.

@Test(expected = IllegalStateException.class)
public void noImplicitRouter() {
    VaadinService service = VaadinService.getCurrent();
    Mockito.when(service.getRouter()).thenReturn(null);
    new RouterLink("Show something", TestView.class);
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) Test(org.junit.Test)

Example 42 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class EventUtilTest method setUp.

@Before
public void setUp() {
    VaadinSession session = Mockito.mock(VaadinSession.class);
    ui = new UI() {

        @Override
        public VaadinSession getSession() {
            return session;
        }
    };
    VaadinService service = Mockito.mock(VaadinService.class);
    when(session.getService()).thenReturn(service);
    DefaultInstantiator instantiator = new DefaultInstantiator(service);
    when(service.getInstantiator()).thenReturn(instantiator);
    UI.setCurrent(ui);
}
Also used : DefaultInstantiator(com.vaadin.flow.di.DefaultInstantiator) VaadinSession(com.vaadin.flow.server.VaadinSession) UI(com.vaadin.flow.component.UI) VaadinService(com.vaadin.flow.server.VaadinService) Before(org.junit.Before)

Example 43 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class PolymerServerEventHandlersTest method createService.

@Override
protected VaadinService createService() {
    VaadinService service = Mockito.mock(VaadinService.class);
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(configuration.isProductionMode()).thenReturn(true);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
    return service;
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 44 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class CustomElementRegistryInitializerTest method createService.

@Override
protected VaadinService createService() {
    VaadinService service = Mockito.mock(VaadinService.class);
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(configuration.isProductionMode()).thenReturn(true);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
    return service;
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 45 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class CustomElementRegistryInitializerTest method setup.

@Before
public void setup() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    Field customElements = CustomElementRegistry.class.getDeclaredField("customElements");
    customElements.setAccessible(true);
    customElements.set(CustomElementRegistry.getInstance(), new AtomicReference<>());
    customElementRegistryInitializer = new CustomElementRegistryInitializer();
    VaadinSession session = Mockito.mock(VaadinSession.class);
    UI ui = new UI() {

        @Override
        public VaadinSession getSession() {
            return session;
        }
    };
    VaadinService service = Mockito.mock(VaadinService.class);
    when(session.getService()).thenReturn(service);
    DefaultInstantiator instantiator = new DefaultInstantiator(service);
    when(service.getInstantiator()).thenReturn(instantiator);
    UI.setCurrent(ui);
}
Also used : DefaultInstantiator(com.vaadin.flow.di.DefaultInstantiator) Field(java.lang.reflect.Field) VaadinSession(com.vaadin.flow.server.VaadinSession) UI(com.vaadin.flow.component.UI) VaadinService(com.vaadin.flow.server.VaadinService) Before(org.junit.Before)

Aggregations

VaadinService (com.vaadin.flow.server.VaadinService)86 Test (org.junit.Test)39 DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)19 VaadinSession (com.vaadin.flow.server.VaadinSession)18 Properties (java.util.Properties)15 VaadinContext (com.vaadin.flow.server.VaadinContext)12 Before (org.junit.Before)11 SpringInstantiatorTest (com.vaadin.flow.spring.instantiator.SpringInstantiatorTest)10 UI (com.vaadin.flow.component.UI)9 ApplicationConfiguration (com.vaadin.flow.server.startup.ApplicationConfiguration)8 Lookup (com.vaadin.flow.di.Lookup)7 VaadinResponse (com.vaadin.flow.server.VaadinResponse)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 ServletContext (javax.servlet.ServletContext)6 MockVaadinContext (com.vaadin.flow.server.MockVaadinContext)5 DefaultInstantiator (com.vaadin.flow.di.DefaultInstantiator)4 Instantiator (com.vaadin.flow.di.Instantiator)4 BrowserLiveReload (com.vaadin.flow.internal.BrowserLiveReload)4 DefaultDeploymentConfiguration (com.vaadin.flow.server.DefaultDeploymentConfiguration)4 MockVaadinServletService (com.vaadin.flow.server.MockVaadinServletService)4