LicenseHandler implements LicenseMatcher { public void approveLicense(final String name, final Boolean approved) { final DbLicense license = getLicense(name); repoHandler.approveLicense(license, approved); } 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 approveALicenseThatDoesNotExist(){ final RepositoryHandler repositoryHandler = mock(RepositoryHandler.class); final LicenseHandler handler = new LicenseHandler(repositoryHandler); WebApplicationException exception = null; try { handler.approveLicense("doesNotExist", true); }catch (WebApplicationException e){ exception = e; } assertNotNull(exception); Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), exception.getResponse().getStatus()); }