private ActivityInstance complete(ActivityInstance ai, String context, Map<String, ?> data) {
   WorkflowService ws = sf.getWorkflowService();
   if (ai.getState() != ActivityInstanceState.Application) {
     ai = ws.activate(ai.getOID());
   }
   ai = ws.complete(ai.getOID(), context, data);
   return ai;
 }
 @SuppressWarnings("unchecked")
 private List<ActivityInstance> getWorklist(EvaluationPolicy... policies) {
   WorkflowService ws = sf.getWorkflowService();
   WorklistQuery query = WorklistQuery.findCompleteWorklist();
   if (policies != null) {
     for (EvaluationPolicy policy : policies) {
       query.setPolicy(policy);
     }
   }
   Worklist worklist = ws.getWorklist(query);
   return worklist.getCumulatedItems();
 }
 @SuppressWarnings("unchecked")
 private List<ActivityInstance> getWorklist(ProcessInstance pi, EvaluationPolicy... policies) {
   WorkflowService ws = sf.getWorkflowService();
   WorklistQuery query = WorklistQuery.findCompleteWorklist();
   if (policies != null) {
     for (EvaluationPolicy policy : policies) {
       query.setPolicy(policy);
     }
   }
   query.getFilter().add(new ProcessInstanceFilter(pi.getOID(), false));
   Worklist worklist = ws.getWorklist(query);
   return worklist.getCumulatedItems();
 }
 @Test
 public void testListWorkflows() {
   workflowService.listWorkflows(DUMMY_ID, null, null);
   verify(workflowRevisionService, times(1)).listWorkflows(DUMMY_ID, Optional.empty(), null, null);
 }
 @Test
 public void testGetWorkflowMetadata() {
   workflowService.getWorkflowMetadata(DUMMY_ID, DUMMY_ID, Optional.empty());
   verify(workflowRevisionService, times(1))
       .getWorkflow(DUMMY_ID, DUMMY_ID, Optional.empty(), Optional.empty());
 }
 @Test
 public void testCreateWorkflow() {
   workflowService.createWorkflow(DUMMY_ID, null);
   verify(workflowRevisionService, times(1))
       .createWorkflowRevision(DUMMY_ID, Optional.empty(), null);
 }