DoNotUseFilter implements Filter { @Override public boolean filter(final Object datamodelObj) { if(datamodelObj instanceof DbArtifact){ return doNotUse.equals( ((DbArtifact)datamodelObj).getDoNotUse()); } return false; } DoNotUseFilter(final Boolean doNotUse); @Override boolean filter(final Object datamodelObj); @Override Map<String, Object> moduleFilterFields(); @Override Map<String, Object> artifactFilterFields();  }
@Test public void approveNull(){ DoNotUseFilter filter = new DoNotUseFilter(true); assertFalse(filter.filter(null)); filter = new DoNotUseFilter(false); assertFalse(filter.filter(null)); }
@Test public void approveArtifact(){ final DbArtifact doNotUseArtifact = new DbArtifact(); doNotUseArtifact.setDoNotUse(true); final DbArtifact artifactThatCanBeUsed = new DbArtifact(); artifactThatCanBeUsed.setDoNotUse(false); DoNotUseFilter filter = new DoNotUseFilter(true); assertTrue(filter.filter(doNotUseArtifact)); assertFalse(filter.filter(artifactThatCanBeUsed)); filter = new DoNotUseFilter(false); assertFalse(filter.filter(doNotUseArtifact)); assertTrue(filter.filter(artifactThatCanBeUsed)); }