ApprovedFilter implements Filter { @Override public boolean filter(final Object datamodelObj) { if(datamodelObj instanceof DbLicense){ return approved.equals( ((DbLicense)datamodelObj).isApproved()); } return false; } ApprovedFilter(final Boolean approved); @Override boolean filter(final Object datamodelObj); @Override Map<String, Object> moduleFilterFields(); @Override Map<String, Object> artifactFilterFields();  }
@Test public void approveNull(){ ApprovedFilter filter = new ApprovedFilter(true); assertFalse(filter.filter(null)); filter = new ApprovedFilter(false); assertFalse(filter.filter(null)); }
@Test public void approveLicense(){ final DbLicense approvedLicense = new DbLicense(); approvedLicense.setApproved(true); final DbLicense rejectLicense = new DbLicense(); rejectLicense.setApproved(false); final DbLicense toBeValidatedLicense = new DbLicense(); ApprovedFilter filter = new ApprovedFilter(true); assertTrue(filter.filter(approvedLicense)); assertFalse(filter.filter(rejectLicense)); assertFalse(filter.filter(toBeValidatedLicense)); filter = new ApprovedFilter(false); assertFalse(filter.filter(approvedLicense)); assertTrue(filter.filter(rejectLicense)); assertFalse(filter.filter(toBeValidatedLicense)); }