@Test public void removeCorporateGroupId(){ final DbOrganization dbOrganization= new DbOrganization(); dbOrganization.setName("organization1"); dbOrganization.getCorporateGroupIdPrefixes().add("org.test"); final RepositoryHandler repositoryHandler = mock(RepositoryHandler.class); ArgumentCaptor<DbOrganization> captor = ArgumentCaptor.forClass(DbOrganization.class); when(repositoryHandler.getOrganization(dbOrganization.getName())).thenReturn(dbOrganization); final OrganizationHandler handler = new OrganizationHandler(repositoryHandler); handler.removeCorporateGroupId(dbOrganization.getName(), "org.test"); verify(repositoryHandler, times(1)).store((DbOrganization)captor.capture()); assertFalse(captor.getValue().getCorporateGroupIdPrefixes().contains("org.test")); verify(repositoryHandler, times(1)).removeModulesOrganization("org.test", dbOrganization); }
public void removeCorporateGroupId(final String organizationId, final String corporateGroupId) { final DbOrganization dbOrganization = getOrganization(organizationId); if(dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){ dbOrganization.getCorporateGroupIdPrefixes().remove(corporateGroupId); repositoryHandler.store(dbOrganization); } repositoryHandler.removeModulesOrganization(corporateGroupId, dbOrganization); }
OrganizationHandler { public void removeCorporateGroupId(final String organizationId, final String corporateGroupId) { final DbOrganization dbOrganization = getOrganization(organizationId); if(dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){ dbOrganization.getCorporateGroupIdPrefixes().remove(corporateGroupId); repositoryHandler.store(dbOrganization); } repositoryHandler.removeModulesOrganization(corporateGroupId, dbOrganization); } }
OrganizationHandler { public void removeCorporateGroupId(final String organizationId, final String corporateGroupId) { final DbOrganization dbOrganization = getOrganization(organizationId); if(dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){ dbOrganization.getCorporateGroupIdPrefixes().remove(corporateGroupId); repositoryHandler.store(dbOrganization); } repositoryHandler.removeModulesOrganization(corporateGroupId, dbOrganization); } OrganizationHandler(final RepositoryHandler repositoryHandler); }
OrganizationHandler { public void removeCorporateGroupId(final String organizationId, final String corporateGroupId) { final DbOrganization dbOrganization = getOrganization(organizationId); if(dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){ dbOrganization.getCorporateGroupIdPrefixes().remove(corporateGroupId); repositoryHandler.store(dbOrganization); } repositoryHandler.removeModulesOrganization(corporateGroupId, 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 void removeCorporateGroupId(final String organizationId, final String corporateGroupId) { final DbOrganization dbOrganization = getOrganization(organizationId); if(dbOrganization.getCorporateGroupIdPrefixes().contains(corporateGroupId)){ dbOrganization.getCorporateGroupIdPrefixes().remove(corporateGroupId); repositoryHandler.store(dbOrganization); } repositoryHandler.removeModulesOrganization(corporateGroupId, 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);  }