WorkflowDefinitionTitlePredicate 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.getTitle(), _keywords, delimiter); } WorkflowDefinitionTitlePredicate(String keywords); @Override boolean test(WorkflowDefinition workflowDefinition);  }
@Test public void testFilterWithoutSpace1() { WorkflowDefinitionTitlePredicate predicate = new WorkflowDefinitionTitlePredicate("Single"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "Single Approver"); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterWithoutSpace2() { WorkflowDefinitionTitlePredicate predicate = new WorkflowDefinitionTitlePredicate("Appr"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "Single Approver"); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterWithoutSpace3() { WorkflowDefinitionTitlePredicate predicate = new WorkflowDefinitionTitlePredicate("Approver"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "A Different Definition"); boolean result = predicate.test(workflowDefinition); Assert.assertFalse(result); }
@Test public void testFilterWithSpace1() { WorkflowDefinitionTitlePredicate predicate = new WorkflowDefinitionTitlePredicate("Single Approver"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "Single Approver Definition"); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterWithSpace2() { WorkflowDefinitionTitlePredicate predicate = new WorkflowDefinitionTitlePredicate("Single Approver"); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( null, "A Different Definition"); boolean result = predicate.test(workflowDefinition); Assert.assertFalse(result); }