DBKeyProjectCompanyPredicate implements Predicate<DBKey> { @Override public boolean apply(DBKey dbKey) { return companyMatches(dbKey) && projectMatches(dbKey); } DBKeyProjectCompanyPredicate(String companyFilter, String projectFilter); @Override boolean apply(DBKey dbKey); @Override String toString();  }
@Test public void apply_whenProjectAndCompanyFiltersAreBlank_expectTrue() { assertTrue(new DBKeyProjectCompanyPredicate(null, null).apply(dbKey)); }
@Test public void apply_whenProjectMatchDbKeyAndCompanyBlank_expectTrue() { when(dbKey.getProject()).thenReturn("filterP"); assertTrue(new DBKeyProjectCompanyPredicate(null, "filterP").apply(dbKey)); }
@Test public void apply_whenCompanyMatchDbKeyAndProjectBlank_expectTrue() { when(dbKey.getCompany()).thenReturn("filterC"); assertTrue(new DBKeyProjectCompanyPredicate("filterC", null).apply(dbKey)); }
@Test public void apply_whenProjectDoesNotMatchDbKey_expectFalse() { when(dbKey.getProject()).thenReturn("filterA"); assertFalse(new DBKeyProjectCompanyPredicate(null, "filterB").apply(dbKey)); }
@Test public void apply_whenCompanyDoesNotMatchDbKey_expectFalse() { when(dbKey.getCompany()).thenReturn("filterA"); assertFalse(new DBKeyProjectCompanyPredicate("filterB", null).apply(dbKey)); }