use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class TemplateModelWithEncodersTest 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;
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class LitTemplateTest method setUp.
@Before
public void setUp() {
DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class UITest method initUI.
private static void initUI(UI ui, String initialLocation, ArgumentCaptor<Integer> statusCodeCaptor) throws InvalidRouteConfigurationException {
VaadinServletRequest request = Mockito.mock(VaadinServletRequest.class);
VaadinResponse response = Mockito.mock(VaadinResponse.class);
String pathInfo;
if (initialLocation.isEmpty()) {
pathInfo = null;
} else {
Assert.assertFalse(initialLocation.startsWith("/"));
pathInfo = "/" + initialLocation;
}
Mockito.when(request.getPathInfo()).thenReturn(pathInfo);
VaadinService service = new MockVaadinServletService() {
@Override
public VaadinContext getContext() {
return new MockVaadinContext();
}
};
service.setCurrentInstances(request, response);
MockVaadinSession session = new AlwaysLockedVaadinSession(service);
DeploymentConfiguration config = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(config.isProductionMode()).thenReturn(false);
session.lock();
session.setConfiguration(config);
ui.getInternals().setSession(session);
RouteConfiguration routeConfiguration = RouteConfiguration.forRegistry(ui.getInternals().getRouter().getRegistry());
routeConfiguration.update(() -> {
routeConfiguration.getHandledRegistry().clean();
Arrays.asList(RootNavigationTarget.class, FooBarNavigationTarget.class, Parameterized.class, FooBarParamNavigationTarget.class).forEach(routeConfiguration::setAnnotatedRoute);
});
ui.doInit(request, 0);
ui.getInternals().getRouter().initializeUI(ui, BootstrapHandlerTest.requestToLocation(request));
session.unlock();
if (statusCodeCaptor != null) {
Mockito.verify(response).setStatus(statusCodeCaptor.capture());
}
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class LookupInitializerTest method initialize_noStaticFileHandlerFactory_defaultStaticFileHandlerFactoryCreated.
@Test
public void initialize_noStaticFileHandlerFactory_defaultStaticFileHandlerFactoryCreated() throws ServletException {
AtomicReference<Lookup> capture = new AtomicReference<>();
initializer.initialize(null, new HashMap<>(), capture::set);
Lookup lookup = capture.get();
StaticFileHandlerFactory factory = lookup.lookup(StaticFileHandlerFactory.class);
VaadinService service = Mockito.mock(VaadinService.class);
DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
ClassLoader loader = Mockito.mock(ClassLoader.class);
Mockito.when(service.getClassLoader()).thenReturn(loader);
StaticFileHandler handler = factory.createHandler(service);
Assert.assertNotNull(handler);
Assert.assertEquals(StaticFileServer.class, handler.getClass());
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class UIInternalsTest method useV14Bootstrap.
private void useV14Bootstrap() {
DeploymentConfiguration deploymentConfiguration = vaadinService.getDeploymentConfiguration();
Mockito.when(deploymentConfiguration.useV14Bootstrap()).thenReturn(true);
}
Aggregations