@Test public void getALicenseThatDoesNotExist(){ final RepositoryHandler repositoryHandler = mock(RepositoryHandler.class); final LicenseHandler handler = new LicenseHandler(repositoryHandler); WebApplicationException exception = null; try { handler.getLicense("doesNotExist"); }catch (WebApplicationException e){ exception = e; } assertNotNull(exception); Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), exception.getResponse().getStatus()); }
public DbLicense getLicense(final String name) { final DbLicense license = repoHandler.getLicense(name); if (license == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("License " + name + " does not exist.").build()); } return license; }
LicenseHandler implements LicenseMatcher { public DbLicense getLicense(final String name) { final DbLicense license = repoHandler.getLicense(name); if (license == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("License " + name + " does not exist.").build()); } return license; } }
LicenseHandler implements LicenseMatcher { public DbLicense getLicense(final String name) { final DbLicense license = repoHandler.getLicense(name); if (license == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("License " + name + " does not exist.").build()); } return license; } LicenseHandler(final RepositoryHandler repoHandler); }
LicenseHandler implements LicenseMatcher { public DbLicense getLicense(final String name) { final DbLicense license = repoHandler.getLicense(name); if (license == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("License " + name + " does not exist.").build()); } return license; } 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); }
LicenseHandler implements LicenseMatcher { public DbLicense getLicense(final String name) { final DbLicense license = repoHandler.getLicense(name); if (license == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("License " + name + " does not exist.").build()); } return license; } 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);  }