use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class CustomUIClassLoaderTest method createRequestMock.
private static VaadinRequest createRequestMock(ClassLoader classloader) {
// Mock a VaadinService to give the passed classloader
VaadinService configurationMock = Mockito.mock(VaadinService.class);
DeploymentConfiguration deploymentConfiguration = createConfigurationMock();
Mockito.when(configurationMock.getDeploymentConfiguration()).thenReturn(deploymentConfiguration);
Mockito.when(configurationMock.getClassLoader()).thenReturn(classloader);
// Mock a VaadinRequest to give the mocked vaadin service
VaadinRequest requestMock = Mockito.mock(VaadinRequest.class);
Mockito.when(requestMock.getService()).thenReturn(configurationMock);
Mockito.when(requestMock.getService()).thenReturn(configurationMock);
Mockito.when(requestMock.getService()).thenReturn(configurationMock);
return requestMock;
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class RouteNotFoundErrorTest method setErrorParameter_productionMode_pathContainRoutesTemplate_renderedElementHasNoRoutes.
@Test
public void setErrorParameter_productionMode_pathContainRoutesTemplate_renderedElementHasNoRoutes() {
RouteNotFoundError page = new RouteNotFoundError();
BeforeEnterEvent event = Mockito.mock(BeforeEnterEvent.class);
Location location = Mockito.mock(Location.class);
Mockito.when(location.getPath()).thenReturn("{{routes}}");
Mockito.when(event.getLocation()).thenReturn(location);
UI ui = Mockito.mock(UI.class);
VaadinSession session = Mockito.mock(VaadinSession.class);
Mockito.when(ui.getSession()).thenReturn(session);
DeploymentConfiguration config = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(session.getConfiguration()).thenReturn(config);
Mockito.when(config.isProductionMode()).thenReturn(true);
Mockito.when(event.getUI()).thenReturn(ui);
ErrorParameter<NotFoundException> param = new ErrorParameter<NotFoundException>(NotFoundException.class, new NotFoundException());
Router router = Mockito.mock(Router.class);
Mockito.when(event.getSource()).thenReturn(router);
RouteRegistry registry = Mockito.mock(RouteRegistry.class);
Mockito.when(router.getRegistry()).thenReturn(registry);
RouteData data = new RouteData(Collections.emptyList(), "bar", Collections.emptyList(), RouteTarget.class, Collections.emptyList());
Mockito.when(registry.getRegisteredRoutes()).thenReturn(Collections.singletonList(data));
event.getSource().getRegistry().getRegisteredRoutes();
page.setErrorParameter(event, param);
MatcherAssert.assertThat(page.getElement().toString(), CoreMatchers.not(CoreMatchers.containsString("bar")));
}
use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.
the class FrontendUtilsTest method mockResourceProvider.
private ResourceProvider mockResourceProvider(VaadinService service) {
DeploymentConfiguration config = Mockito.mock(DeploymentConfiguration.class);
VaadinContext context = Mockito.mock(VaadinContext.class);
Lookup lookup = Mockito.mock(Lookup.class);
Mockito.when(context.getAttribute(Lookup.class)).thenReturn(lookup);
ResourceProvider provider = Mockito.mock(ResourceProvider.class);
Mockito.when(lookup.lookup(ResourceProvider.class)).thenReturn(provider);
Mockito.when(service.getDeploymentConfiguration()).thenReturn(config);
Mockito.when(service.getContext()).thenReturn(context);
Mockito.when(config.isProductionMode()).thenReturn(true);
Mockito.when(config.getStringProperty(SERVLET_PARAMETER_STATISTICS_JSON, VAADIN_SERVLET_RESOURCES + STATISTICS_JSON_DEFAULT)).thenReturn("foo");
return provider;
}
Aggregations