HasLicenseFilter implements Filter { @Override public boolean filter(final Object datamodelObj) { if(datamodelObj instanceof DbArtifact){ return hasLicense !=(((DbArtifact)datamodelObj).getLicenses().isEmpty()); } return false; } HasLicenseFilter(final Boolean hasLicense); @Override boolean filter(final Object datamodelObj); @Override Map<String, Object> moduleFilterFields(); @Override Map<String, Object> artifactFilterFields();  }
@Test public void approveNull(){ HasLicenseFilter filter = new HasLicenseFilter(true); assertFalse(filter.filter(null)); filter = new HasLicenseFilter(false); assertFalse(filter.filter(null)); }
@Test public void approveArtifact(){ final DbArtifact artifactWithLicense = new DbArtifact(); final DbLicense license = new DbLicense(); license.setName("licenseName"); artifactWithLicense.addLicense(license); final DbArtifact artifactWithoutLicense = new DbArtifact(); HasLicenseFilter filter = new HasLicenseFilter(true); assertTrue(filter.filter(artifactWithLicense)); assertFalse(filter.filter(artifactWithoutLicense)); filter = new HasLicenseFilter(false); assertFalse(filter.filter(artifactWithLicense)); assertTrue(filter.filter(artifactWithoutLicense)); }