WorkflowDefinitionActivePredicate implements Predicate<WorkflowDefinition> { @Override public boolean test(WorkflowDefinition workflowDefinition) { if (_status == WorkflowConstants.STATUS_ANY) { return true; } else if (_status == WorkflowConstants.STATUS_APPROVED) { return workflowDefinition.isActive(); } return !workflowDefinition.isActive(); } WorkflowDefinitionActivePredicate(int status); @Override boolean test(WorkflowDefinition workflowDefinition);  }
@Test public void testFilterAllIncludeActive() { WorkflowDefinitionActivePredicate predicate = new WorkflowDefinitionActivePredicate(WorkflowConstants.STATUS_ANY); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( true); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterAllIncludeInactive() { WorkflowDefinitionActivePredicate predicate = new WorkflowDefinitionActivePredicate(WorkflowConstants.STATUS_ANY); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( false); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterNotPublishedExcludeActive() { WorkflowDefinitionActivePredicate predicate = new WorkflowDefinitionActivePredicate( WorkflowConstants.STATUS_DRAFT); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( true); boolean result = predicate.test(workflowDefinition); Assert.assertFalse(result); }
@Test public void testFilterNotPublishedIncludeInactive() { WorkflowDefinitionActivePredicate predicate = new WorkflowDefinitionActivePredicate( WorkflowConstants.STATUS_DRAFT); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( false); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }
@Test public void testFilterPublishedExcludeInactive() { WorkflowDefinitionActivePredicate predicate = new WorkflowDefinitionActivePredicate( WorkflowConstants.STATUS_APPROVED); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( false); boolean result = predicate.test(workflowDefinition); Assert.assertFalse(result); }
@Test public void testFilterPublishedIncludeActive() { WorkflowDefinitionActivePredicate predicate = new WorkflowDefinitionActivePredicate( WorkflowConstants.STATUS_APPROVED); WorkflowDefinition workflowDefinition = new WorkflowDefinitionImpl( true); boolean result = predicate.test(workflowDefinition); Assert.assertTrue(result); }