PromotedFilter implements Filter { @Override public boolean filter(final Object datamodelObj) { if(datamodelObj instanceof DbModule){ return promoted.equals( ((DbModule)datamodelObj).isPromoted()); } if(datamodelObj instanceof DbArtifact){ return promoted.equals( ((DbArtifact)datamodelObj).isPromoted()); } return false; } PromotedFilter(final Boolean promoted); @Override boolean filter(final Object datamodelObj); @Override Map<String, Object> moduleFilterFields(); @Override Map<String, Object> artifactFilterFields();  }
@Test public void approveNull(){ PromotedFilter filter = new PromotedFilter(true); assertFalse(filter.filter(null)); filter = new PromotedFilter(false); assertFalse(filter.filter(null)); }
@Test public void promotedArtifact(){ final DbArtifact promotedArtifact = new DbArtifact(); promotedArtifact.setPromoted(true); final DbArtifact notPromotedArtifact = new DbArtifact(); notPromotedArtifact.setPromoted(false); PromotedFilter filter = new PromotedFilter(true); assertTrue(filter.filter(promotedArtifact)); assertFalse(filter.filter(notPromotedArtifact)); filter = new PromotedFilter(false); assertFalse(filter.filter(promotedArtifact)); assertTrue(filter.filter(notPromotedArtifact)); }
@Test public void promotedModule(){ final DbModule promotedModule = new DbModule(); promotedModule.setPromoted(true); final DbModule notPromotedModule = new DbModule(); notPromotedModule.setPromoted(false); PromotedFilter filter = new PromotedFilter(true); assertTrue(filter.filter(promotedModule)); assertFalse(filter.filter(notPromotedModule)); filter = new PromotedFilter(false); assertFalse(filter.filter(promotedModule)); assertTrue(filter.filter(notPromotedModule)); }