use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class FrontendUtilsTest method noStatsFile_assetsByChunkReturnsNull.
@Test
public void noStatsFile_assetsByChunkReturnsNull() throws IOException, ServiceException {
VaadinService service = getServiceWithResource(null);
String statsAssetsByChunkName = FrontendUtils.getStatsAssetsByChunkName(service);
Assert.assertNull(statsAssetsByChunkName);
}
use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class FrontendUtilsTest method faultyStatsFileReturnsNull.
@Test
public void faultyStatsFileReturnsNull() throws IOException, ServiceException {
VaadinService service = setupStatsAssetMocks("InvalidStats.json");
String statsAssetsByChunkName = FrontendUtils.getStatsAssetsByChunkName(service);
Assert.assertNull(statsAssetsByChunkName);
}
use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class FrontendUtilsTest method clearCachedStatsContent_clearsCache.
@Test
public void clearCachedStatsContent_clearsCache() throws IOException, ServiceException {
VaadinService service = setupStatsAssetMocks("ValidStats.json");
assertNull("Stats cache should not be present", service.getContext().getAttribute(CACHE_KEY));
// Can be invoked without cache - throws no exception
FrontendUtils.clearCachedStatsContent(service);
// Populates cache
FrontendUtils.getStatsAssetsByChunkName(service);
// Clears cache
FrontendUtils.clearCachedStatsContent(service);
assertNull("Stats cache should not be present", service.getContext().getAttribute(CACHE_KEY));
}
use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class FrontendUtilsTest method getStatsAssetsByChunkName_getStatsFromClassPath_populatesStatsCache.
@Test
public void getStatsAssetsByChunkName_getStatsFromClassPath_populatesStatsCache() throws IOException, ServiceException {
VaadinService service = setupStatsAssetMocks("ValidStats.json");
assertNull("Stats cache should not be present", service.getContext().getAttribute(CACHE_KEY));
// Populates cache
FrontendUtils.getStatsAssetsByChunkName(service);
assertNotNull("Stats cache should be created", service.getContext().getAttribute(CACHE_KEY));
}
use of com.vaadin.flow.server.VaadinService in project flow by vaadin.
the class InternalErrorView method showCriticalNotification.
protected void showCriticalNotification(String caption, String message, String details, String url) {
VaadinService service = VaadinService.getCurrent();
VaadinResponse response = VaadinService.getCurrentResponse();
try {
service.writeUncachedStringResponse(response, JsonConstants.JSON_CONTENT_TYPE, VaadinService.createCriticalNotificationJSON(caption, message, details, url));
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations