use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class UidlRequestHandler method handleSessionExpired.
/*
* (non-Javadoc)
*
* @see
* com.vaadin.server.SessionExpiredHandler#handleSessionExpired(com.vaadin
* .server.VaadinRequest, com.vaadin.server.VaadinResponse)
*/
@Override
public boolean handleSessionExpired(VaadinRequest request, VaadinResponse response) throws IOException {
if (!HandlerHelper.isRequestType(request, RequestType.UIDL)) {
return false;
}
VaadinService service = request.getService();
service.writeUncachedStringResponse(response, JsonConstants.JSON_CONTENT_TYPE, VaadinService.createSessionExpiredJSON(false));
return true;
}
use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class MockUI method createSession.
private static VaadinSession createSession(Router router) {
VaadinService service = Mockito.mock(VaadinService.class);
if (router != null) {
Mockito.when(service.getRouter()).thenReturn(router);
}
VaadinSession session = new AlwaysLockedVaadinSession(service);
VaadinSession.setCurrent(session);
return session;
}
use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class WebComponentConfigurationRegistryTest method init.
@Before
public void init() {
VaadinService service = mock(VaadinService.class);
context = mock(VaadinContext.class);
VaadinService.setCurrent(service);
Mockito.when(service.getContext()).thenReturn(context);
WebComponentConfigurationRegistry instance = createRegistry();
Mockito.when(context.getAttribute(WebComponentConfigurationRegistry.class)).thenReturn(instance);
Mockito.when(context.getAttribute(eq(WebComponentConfigurationRegistry.class), any())).thenReturn(instance);
registry = WebComponentConfigurationRegistry.getInstance(context);
}
use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class RouterLinkTest method setUp.
@Before
public void setUp() throws NoSuchFieldException, IllegalAccessException, InvalidRouteConfigurationException {
registry = new TestRouteRegistry();
RouteConfiguration routeConfiguration = RouteConfiguration.forRegistry(registry);
routeConfiguration.update(() -> {
routeConfiguration.getHandledRegistry().clean();
Arrays.asList(TestView.class, FooNavigationTarget.class, ParameterNavigationTarget.class, GreetingNavigationTarget.class).forEach(routeConfiguration::setAnnotatedRoute);
});
router = new Router(registry);
ui = new RoutingTestBase.RouterTestUI(router);
VaadinService service = VaadinService.getCurrent();
Mockito.when(service.getRouter()).thenReturn(router);
}
use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class FrontendUtilsTest method assetsByChunkIsCorrectlyParsedFromStats.
@Test
public void assetsByChunkIsCorrectlyParsedFromStats() throws IOException, ServiceException {
VaadinService service = setupStatsAssetMocks("ValidStats.json");
String statsAssetsByChunkName = FrontendUtils.getStatsAssetsByChunkName(service);
Assert.assertEquals("{\"bundle\": \"build/vaadin-bundle-1111.cache.js\",\"export\": \"build/vaadin-export-2222.cache.js\"}", statsAssetsByChunkName);
}
Aggregations