ClasspathRepository implements Repository { @Override public RepositoryDTO fetchInstallableApplications() { try { final List<TypeDTO> typeDTOS = new ArrayList<>(); Resource[] resources = resourceResolver.getResources(packagePath + "/*"); for (Resource resource : resources) { final TypeDTO type = buildType(resource.getFilename()); if (!type.getCategories().isEmpty()) { typeDTOS.add(type); } } typeDTOS.sort(Comparator.comparing(TypeDTO::getName)); final RepositoryDTO.Builder repositoryDTOBuilder = new RepositoryDTO.Builder() .withName("classpath repository").withTypes(typeDTOS); return repositoryDTOBuilder.build(); } catch (IOException e) { LOGGER.warn("Error while reading resource directory", e); return new RepositoryDTO.Builder().build(); } } ClasspathRepository(String packagePath, ResourcePatternResolver resourceResolver,
            ObjectMapper objectMapper); @Override RepositoryDTO fetchInstallableApplications(); @Override boolean isSafe(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void fetchInstallableApplicationsCategoriesTypes() { assertEquals(CategoryDTO.CategoryType.INSTALLERS, repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(0).getType()); assertEquals(CategoryDTO.CategoryType.FUNCTIONS, repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(1).getType()); }
@Test public void fetchInstallableApplicationsNumberOfCategories() { assertEquals(2, repository.fetchInstallableApplications().getTypes().get(0).getCategories().size()); }
@Test public void fetchInstallableApplicationsCategoriesNames() { assertEquals("Development", repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(0).getName()); assertEquals("Graphics", repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(1).getName()); }
@Test public void fetchInstallableApplicationsGraphics() { assertEquals(1, repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(1) .getApplications().size()); }
@Test public void fetchInstallableApplicationsGraphicsPhotofiltre() { assertEquals("Photofiltre", repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(1).getApplications() .get(0).getName()); }
@Test public void fetchInstallableApplicationsGraphicsPhotofiltreScripts() { assertEquals(1, repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(1) .getApplications().get(0) .getScripts().size()); }
@Test public void fetchInstallableApplicationsGraphicsPhotofiltreScriptName() { assertEquals("Online", repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(1) .getApplications().get(0) .getScripts().get(0).getScriptName()); }
@Test public void fetchInstallableApplicationsGraphicsPhotofiltreScriptContent() { assertEquals("const OnlineInstallerScript = include(\"engines.wine.quick_script.online_installer_script\");\n" + "\n" + "new OnlineInstallerScript()\n" + " .name(\"Photofiltre\")\n" + " .editor(\"Antonio Da Cruz\")\n" + " .applicationHomepage(\"http: + " .author(\"Quentin PÂRIS\")\n" + " .url(\"http: + " .checksum(\"dc965875d698cd3f528423846f837d0dcf39616d\")\n" + " .category(\"Graphics\")\n" + " .executable(\"PhotoFiltre.exe\");", repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(1).getApplications() .get(0).getScripts() .get(0).getScript().trim()); }
@Test public void fetchInstallableApplicationsGraphicsPhotofiltreMiniatures() { assertEquals(1, repository.fetchInstallableApplications().getTypes().get(0).getCategories().get(1) .getApplications().get(0) .getMiniatures().size()); }