ToBeValidatedFilter implements Filter { @Override public boolean filter(final Object datamodelObj) { if(datamodelObj instanceof DbLicense){ if(toBeValidated){ return ((DbLicense)datamodelObj).isApproved() == null; } else{ return ((DbLicense)datamodelObj).isApproved() != null; } } return false; } ToBeValidatedFilter(final Boolean toBeValidated); @Override boolean filter(final Object datamodelObj); @Override Map<String, Object> moduleFilterFields(); @Override Map<String, Object> artifactFilterFields();  }
@Test public void approveNull(){ ToBeValidatedFilter filter = new ToBeValidatedFilter(true); assertFalse(filter.filter(null)); filter = new ToBeValidatedFilter(false); assertFalse(filter.filter(null)); }
@Test public void approveArtifact(){ final DbLicense unvalidatedLicense = new DbLicense(); unvalidatedLicense.setApproved(false); final DbLicense validatedLicense = new DbLicense(); validatedLicense.setApproved(true); final DbLicense toBeValidatedLicense = new DbLicense(); ToBeValidatedFilter filter = new ToBeValidatedFilter(true); assertTrue(filter.filter(toBeValidatedLicense)); assertFalse(filter.filter(validatedLicense)); assertFalse(filter.filter(unvalidatedLicense)); filter = new ToBeValidatedFilter(false); assertFalse(filter.filter(toBeValidatedLicense)); assertTrue(filter.filter(validatedLicense)); assertTrue(filter.filter(unvalidatedLicense)); }