PwaRegistry implements Serializable { public List<PwaIcon> getIcons() { return new ArrayList<>(icons); } PwaRegistry(PWA pwa, ServletContext servletContext); static PwaRegistry getInstance(ServletContext servletContext); String getOfflineHtml(); String getManifestJson(); String getServiceWorkerJs(); String offlinePageCache(); List<PwaIcon> getHeaderIcons(); List<PwaIcon> getManifestIcons(); List<PwaIcon> getIcons(); PwaConfiguration getPwaConfiguration(); static final String WORKBOX_FOLDER; }
@Test public void pwaIconIsGeneratedBasedOnClasspathIcon_servletContextHasNoResources() throws IOException { ServletContext context = Mockito.mock(ServletContext.class); PwaRegistry registry = new PwaRegistry( PwaRegistryTest.class.getAnnotation(PWA.class), context); List<PwaIcon> icons = registry.getIcons(); PwaIcon pwaIcon = icons.stream().filter(icon -> icon.getWidth() == 32) .findFirst().get(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); pwaIcon.write(stream); Assert.assertEquals(26, stream.toByteArray()[36]); }