OrganizationFilter implements Filter { @Override public boolean filter(final Object datamodelObj) { if(datamodelObj instanceof DbModule){ return organization.equals(((DbModule)datamodelObj).getOrganization()); } return false; } OrganizationFilter(final String organization); @Override boolean filter(final Object datamodelObj); @Override Map<String, Object> moduleFilterFields(); @Override Map<String, Object> artifactFilterFields();  }
@Test public void filterAModuleThatIsNull(){ final OrganizationFilter filter = new OrganizationFilter("test"); assertFalse(filter.filter(null)); }
@Test public void filterAModuleThatHaveItsOrganizationIsNull(){ final OrganizationFilter filter = new OrganizationFilter("test"); final DbModule module = new DbModule(); module.setOrganization(null); assertFalse(filter.filter(module)); }
@Test public void filterAModuleThatHavAnOrganizationThatDoesNotMatchTheFilter(){ final OrganizationFilter filter = new OrganizationFilter("test"); final DbModule module = new DbModule(); module.setOrganization("no"); assertFalse(filter.filter(module)); }
@Test public void filterAModuleThatHavAnOrganizationThatMatchesTheFilter(){ final OrganizationFilter filter = new OrganizationFilter("test"); final DbModule module = new DbModule(); module.setOrganization("test"); assertTrue(filter.filter(module)); }