package org.camunda.bpm.extension.example.reactor;

import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.TaskListener;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.camunda.bpm.engine.test.assertions.ProcessEngineTests;
import org.camunda.bpm.engine.test.mock.Mocks;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.bridge.SLF4JBridgeHandler;

import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.runtimeService;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.task;

public class ProcessATest {
  static {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
  }

  @Rule
  public final ProcessEngineRule processEngineRule = new ProcessEngineRule(ProcessA.CONFIGURATION.buildProcessEngine());

  @Test
  @Deployment(resources = "ProcessA.bpmn")
  public void run_process() {
     new ProcessA().init();


    final ProcessInstance processInstance = runtimeService().startProcessInstanceByKey("process_a");

    assertThat(processInstance).isWaitingAt("task_a");
    assertThat(task()).hasDueDate(ProcessA.DUE_DATE);
    

    assertThat(task()).hasCandidateGroup(ProcessA.GROUP_1);
    assertThat(task()).hasCandidateGroup(ProcessA.GROUP_2);
    assertThat(task()).hasCandidateGroup(ProcessA.GROUP_3);
//    assertThat(task()).isAssignedTo("me");

    
  }
}


@@ -202,24 +202,65 @@
 ssInstance;%0A
+import org.camunda.bpm.engine.task.Task;%0A
 import org.c
@@ -636,24 +636,192 @@
 imeService;%0A
+import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.taskService;%0Aimport static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.taskQuery;%0A
 import stati
@@ -1569,35 +1569,123 @@
    %0A
-%0A    assertThat(task
+    %0A    Task t = taskService().createTaskQuery().singleResult();%0A    assertThat(taskQuery().taskId(t.getId
 ()).
-h
+t
 as
+k
 Cand
@@ -1716,36 +1716,110 @@
 P_1)
-;%0A    assertThat(task
+.includeAssignedTasks().singleResult()).isNotNull();%0A    assertThat(taskQuery().taskId(t.getId
 ()).
-h
+t
 as
+k
 Cand
@@ -1850,36 +1850,110 @@
 P_2)
-;%0A    assertThat(task
+.includeAssignedTasks().singleResult()).isNotNull();%0A    assertThat(taskQuery().taskId(t.getId
 ()).
-h
+t
 as
+k
 Cand
@@ -1984,12 +1984,258 @@
 P_3)
+.includeAssignedTasks().singleResult()).isNotNull();%0A    %0A    %0A%0A    //assertThat(task()).hasCandidateGroup(ProcessA.GROUP_1);%0A    //assertThat(task()).hasCandidateGroup(ProcessA.GROUP_2);%0A    //assertThat(task()).hasCandidateGroup(ProcessA.GROUP_2)
 ;%0A
-//
     

fix problem with assertj assertion on candidateGroups