LicenseHandler implements LicenseMatcher { public void deleteLicense(final String licName) { final DbLicense dbLicense = getLicense(licName); repoHandler.deleteLicense(dbLicense.getName()); final FiltersHolder filters = new FiltersHolder(); final LicenseIdFilter licenseIdFilter = new LicenseIdFilter(licName); filters.addFilter(licenseIdFilter); for (final DbArtifact artifact : repoHandler.getArtifacts(filters)) { repoHandler.removeLicenseFromArtifact(artifact, licName, this); } } LicenseHandler(final RepositoryHandler repoHandler); void store(final DbLicense dbLicense); List<String> getLicensesNames(final FiltersHolder filters); DbLicense getLicense(final String name); void deleteLicense(final String licName); void approveLicense(final String name, final Boolean approved); DbLicense resolve(final String licenseId); List<License> getLicenses(); Set<DbLicense> resolveLicenses(List<String> licStrings); @Override Set<DbLicense> getMatchingLicenses(String licenseString);  }
@Test public void deleteAnArtifactThatDoesNotExist(){ final RepositoryHandler repositoryHandler = mock(RepositoryHandler.class); final LicenseHandler handler = new LicenseHandler(repositoryHandler); WebApplicationException exception = null; try { handler.deleteLicense("doesNotExist"); }catch (WebApplicationException e){ exception = e; } assertNotNull(exception); Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), exception.getResponse().getStatus()); }