@Test public void getAnOrganizationThatDoesNotExist(){ final RepositoryHandler repositoryHandler = mock(RepositoryHandler.class); final OrganizationHandler handler = new OrganizationHandler(repositoryHandler); WebApplicationException exception = null; try { handler.getOrganization("doesNotExist"); }catch (WebApplicationException e){ exception = e; } assertNotNull(exception); Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), exception.getResponse().getStatus()); }
public DbOrganization getOrganization(final String organizationId) { final DbOrganization dbOrganization = repositoryHandler.getOrganization(organizationId); if(dbOrganization == null){ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Organization " + organizationId + " does not exist.").build()); } return dbOrganization; }
OrganizationHandler { public DbOrganization getOrganization(final String organizationId) { final DbOrganization dbOrganization = repositoryHandler.getOrganization(organizationId); if(dbOrganization == null){ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Organization " + organizationId + " does not exist.").build()); } return dbOrganization; } }
OrganizationHandler { public DbOrganization getOrganization(final String organizationId) { final DbOrganization dbOrganization = repositoryHandler.getOrganization(organizationId); if(dbOrganization == null){ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Organization " + organizationId + " does not exist.").build()); } return dbOrganization; } OrganizationHandler(final RepositoryHandler repositoryHandler); }
OrganizationHandler { public DbOrganization getOrganization(final String organizationId) { final DbOrganization dbOrganization = repositoryHandler.getOrganization(organizationId); if(dbOrganization == null){ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Organization " + organizationId + " does not exist.").build()); } return dbOrganization; } OrganizationHandler(final RepositoryHandler repositoryHandler); void store(final DbOrganization dbOrganization); List<String> getOrganizationNames(); DbOrganization getOrganization(final String organizationId); void deleteOrganization(final String organizationId); List<String> getCorporateGroupIds(final String organizationId); void addCorporateGroupId(final String organizationId, final String corporateGroupId); void removeCorporateGroupId(final String organizationId, final String corporateGroupId); DbOrganization getMatchingOrganization(final DbModule dbModule); }
OrganizationHandler { public DbOrganization getOrganization(final String organizationId) { final DbOrganization dbOrganization = repositoryHandler.getOrganization(organizationId); if(dbOrganization == null){ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("Organization " + organizationId + " does not exist.").build()); } return dbOrganization; } OrganizationHandler(final RepositoryHandler repositoryHandler); void store(final DbOrganization dbOrganization); List<String> getOrganizationNames(); DbOrganization getOrganization(final String organizationId); void deleteOrganization(final String organizationId); List<String> getCorporateGroupIds(final String organizationId); void addCorporateGroupId(final String organizationId, final String corporateGroupId); void removeCorporateGroupId(final String organizationId, final String corporateGroupId); DbOrganization getMatchingOrganization(final DbModule dbModule);  }