@Test public void getVersionsOfAModule(){ final DbModule module = new DbModule(); module.setName("module"); module.setVersion("1.0.0-SNAPSHOT"); final FiltersHolder filters = mock(FiltersHolder.class); final RepositoryHandler repositoryHandler = mock(RepositoryHandler.class); when(repositoryHandler.getModuleVersions(module.getName(), filters)).thenReturn(Collections.singletonList("1.0.0-SNAPSHOT")); final ModuleHandler handler = new ModuleHandler(repositoryHandler); final List<String> versions = handler.getModuleVersions(module.getName(), filters); assertNotNull(versions); assertEquals(1, versions.size()); assertEquals(module.getVersion(), versions.get(0)); verify(repositoryHandler, times(1)).getModuleVersions(module.getName(),filters); }
public List<String> getModuleVersions(final String name, final FiltersHolder filters) { final List<String> versions = repositoryHandler.getModuleVersions(name, filters); if (versions.isEmpty()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Module " + name + " does not exist.").build()); } return versions; }
ModuleHandler { public List<String> getModuleVersions(final String name, final FiltersHolder filters) { final List<String> versions = repositoryHandler.getModuleVersions(name, filters); if (versions.isEmpty()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Module " + name + " does not exist.").build()); } return versions; } }
ModuleHandler { public List<String> getModuleVersions(final String name, final FiltersHolder filters) { final List<String> versions = repositoryHandler.getModuleVersions(name, filters); if (versions.isEmpty()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Module " + name + " does not exist.").build()); } return versions; } ModuleHandler(final RepositoryHandler repositoryHandler); }
ModuleHandler { public List<String> getModuleVersions(final String name, final FiltersHolder filters) { final List<String> versions = repositoryHandler.getModuleVersions(name, filters); if (versions.isEmpty()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Module " + name + " does not exist.").build()); } return versions; } ModuleHandler(final RepositoryHandler repositoryHandler); void store(final DbModule dbModule); List<String> getModuleNames(final FiltersHolder filters); List<String> getModuleVersions(final String name, final FiltersHolder filters); DbModule getModule(final String moduleId); void deleteModule(final String moduleId); List<DbLicense> getModuleLicenses(final String moduleId,
                                             final LicenseMatcher licenseMatcher); void promoteModule(final String moduleId); PromotionReportView getPromotionReport(final String moduleId); DbOrganization getOrganization(final DbModule module); List<DbModule> getModules(final FiltersHolder filters); }
ModuleHandler { public List<String> getModuleVersions(final String name, final FiltersHolder filters) { final List<String> versions = repositoryHandler.getModuleVersions(name, filters); if (versions.isEmpty()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Module " + name + " does not exist.").build()); } return versions; } ModuleHandler(final RepositoryHandler repositoryHandler); void store(final DbModule dbModule); List<String> getModuleNames(final FiltersHolder filters); List<String> getModuleVersions(final String name, final FiltersHolder filters); DbModule getModule(final String moduleId); void deleteModule(final String moduleId); List<DbLicense> getModuleLicenses(final String moduleId,
                                             final LicenseMatcher licenseMatcher); void promoteModule(final String moduleId); PromotionReportView getPromotionReport(final String moduleId); DbOrganization getOrganization(final DbModule module); List<DbModule> getModules(final FiltersHolder filters);  }