VersionFilter implements Filter { @Override public boolean filter(final Object datamodelObj) { if(datamodelObj instanceof DbModule){ return version.equals( ((DbModule)datamodelObj).getVersion()); } if(datamodelObj instanceof DbArtifact){ return version.equals( ((DbArtifact)datamodelObj).getVersion()); } return false; } VersionFilter(final String version); @Override boolean filter(final Object datamodelObj); @Override Map<String, Object> moduleFilterFields(); @Override Map<String, Object> artifactFilterFields();  }
@Test public void approveNull(){ VersionFilter filter = new VersionFilter("1.0.0"); assertFalse(filter.filter(null)); }
@Test public void approveArtifact(){ final DbArtifact artifact = new DbArtifact(); artifact.setVersion("1.0.0"); VersionFilter filter = new VersionFilter(artifact.getVersion()); assertTrue(filter.filter(artifact)); filter = new VersionFilter("test"); assertFalse(filter.filter(artifact)); }
@Test public void approveModule(){ final DbModule module = new DbModule(); module.setVersion("1.0.0"); VersionFilter filter = new VersionFilter(module.getVersion()); assertTrue(filter.filter(module)); filter = new VersionFilter("test"); assertFalse(filter.filter(module)); }