@Test public void getMatchingOrganizationOfAModuleWhenThereIsNone(){ final DbModule module = new DbModule(); final DbArtifact artifact = new DbArtifact(); artifact.setGroupId("unknown.production"); module.addArtifact(artifact); final RepositoryHandler repositoryHandler = GrapesTestUtils.getRepoHandlerMock(); final OrganizationHandler handler = new OrganizationHandler(repositoryHandler); final DbOrganization organization = handler.getMatchingOrganization(new DbModule()); assertNull(organization); }
public DbOrganization getMatchingOrganization(final DbModule dbModule) { if(dbModule.getOrganization() != null && !dbModule.getOrganization().isEmpty()){ return getOrganization(dbModule.getOrganization()); } for(final DbOrganization organization: repositoryHandler.getAllOrganizations()){ final CorporateFilter corporateFilter = new CorporateFilter(organization); if(corporateFilter.matches(dbModule)){ return organization; } } return null; }
OrganizationHandler { public DbOrganization getMatchingOrganization(final DbModule dbModule) { if(dbModule.getOrganization() != null && !dbModule.getOrganization().isEmpty()){ return getOrganization(dbModule.getOrganization()); } for(final DbOrganization organization: repositoryHandler.getAllOrganizations()){ final CorporateFilter corporateFilter = new CorporateFilter(organization); if(corporateFilter.matches(dbModule)){ return organization; } } return null; } }
OrganizationHandler { public DbOrganization getMatchingOrganization(final DbModule dbModule) { if(dbModule.getOrganization() != null && !dbModule.getOrganization().isEmpty()){ return getOrganization(dbModule.getOrganization()); } for(final DbOrganization organization: repositoryHandler.getAllOrganizations()){ final CorporateFilter corporateFilter = new CorporateFilter(organization); if(corporateFilter.matches(dbModule)){ return organization; } } return null; } OrganizationHandler(final RepositoryHandler repositoryHandler); }
OrganizationHandler { public DbOrganization getMatchingOrganization(final DbModule dbModule) { if(dbModule.getOrganization() != null && !dbModule.getOrganization().isEmpty()){ return getOrganization(dbModule.getOrganization()); } for(final DbOrganization organization: repositoryHandler.getAllOrganizations()){ final CorporateFilter corporateFilter = new CorporateFilter(organization); if(corporateFilter.matches(dbModule)){ return organization; } } return null; } 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 getMatchingOrganization(final DbModule dbModule) { if(dbModule.getOrganization() != null && !dbModule.getOrganization().isEmpty()){ return getOrganization(dbModule.getOrganization()); } for(final DbOrganization organization: repositoryHandler.getAllOrganizations()){ final CorporateFilter corporateFilter = new CorporateFilter(organization); if(corporateFilter.matches(dbModule)){ return organization; } } return null; } 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);  }