WorkflowDefinitionDescriptionPredicate implements Predicate<WorkflowDefinition> { @Override public boolean test(WorkflowDefinition workflowDefinition) { if (Validator.isNull(_keywords)) { return true; } String delimiter = StringPool.SPACE; if (!StringUtil.contains(_keywords, StringPool.SPACE)) { delimiter = StringPool.BLANK; } return StringUtil.containsIgnoreCase( workflowDefinition.getDescription(), _keywords, delimiter); } WorkflowDefinitionDescriptionPredicate(String keywords); @Override boolean test(WorkflowDefinition workflowDefinition);  }
@Test public void testFilterWithoutSpace1() { WorkflowDefinitionDescriptionPredicate predicate = new WorkflowDefinitionDescriptionPredicate("Default"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "Single Approver", "Default Single Approver"); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterWithoutSpace2() { WorkflowDefinitionDescriptionPredicate predicate = new WorkflowDefinitionDescriptionPredicate("Def"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "Single Approver", "Default Single Approver"); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterWithoutSpace3() { WorkflowDefinitionDescriptionPredicate predicate = new WorkflowDefinitionDescriptionPredicate("Approver"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "A Different Definition", "Not that one"); boolean result = predicate.test(workflowDefinition); Assert.assertFalse(result); }
@Test public void testFilterWithSpace1() { WorkflowDefinitionDescriptionPredicate predicate = new WorkflowDefinitionDescriptionPredicate("Single Approver"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "Single Approver Definition", "Single Approver by Default Default "); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterWithSpace2() { WorkflowDefinitionDescriptionPredicate predicate = new WorkflowDefinitionDescriptionPredicate("Single Approver"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "A Different Definition", "Not that one"); boolean result = predicate.test(workflowDefinition); Assert.assertFalse(result); }