Skip to content

Commit

Permalink
fix IT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Sep 3, 2024
1 parent 8aa89cf commit 848dbb4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ public class UserTaskKogitoWorkItemHandler extends DefaultKogitoWorkItemHandler

public static final WorkItemLifeCyclePhase TRANSITION_RESERVED_COMPLETE =
new DefaultWorkItemLifeCyclePhase("complete", RESERVED, COMPLETED, UserTaskKogitoWorkItemHandler::userTaskCompleteWorkItemHandler);
public static final WorkItemLifeCyclePhase TRANSITION_ACTIVATED_COMPLETE =
new DefaultWorkItemLifeCyclePhase("complete", ACTIVATED, COMPLETED, UserTaskKogitoWorkItemHandler::userTaskCompleteWorkItemHandler);
public static final WorkItemLifeCyclePhase TRANSITION_RESERVED_ABORT =
new DefaultWorkItemLifeCyclePhase("abort", RESERVED, ABORTED, UserTaskKogitoWorkItemHandler::userTaskAbortWorkItemHandler);
public static final WorkItemLifeCyclePhase TRANSITION_ACTIVATED_ABORT =
new DefaultWorkItemLifeCyclePhase("abort", ACTIVATED, ABORTED, UserTaskKogitoWorkItemHandler::userTaskAbortWorkItemHandler);
public static final WorkItemLifeCyclePhase TRANSITION_ACTIVATED_CLAIM =
new DefaultWorkItemLifeCyclePhase("claim", ACTIVATED, RESERVED, UserTaskKogitoWorkItemHandler::userTaskClaimWorkItemHandler);
public static final WorkItemLifeCyclePhase TRANSITION_CREATED_ACTIVE =
Expand All @@ -83,23 +87,29 @@ public String getName() {

@Override
public WorkItemLifeCycle initialize() {
return new DefaultWorkItemLifeCycle(TRANSITION_CREATED_ACTIVE, TRANSITION_ACTIVATED_CLAIM, TRANSITION_RESERVED_RELEASE, TRANSITION_RESERVED_ABORT,
return new DefaultWorkItemLifeCycle(
TRANSITION_CREATED_ACTIVE,
TRANSITION_ACTIVATED_CLAIM,
TRANSITION_ACTIVATED_ABORT,
TRANSITION_ACTIVATED_COMPLETE,
TRANSITION_RESERVED_RELEASE,
TRANSITION_RESERVED_ABORT,
TRANSITION_RESERVED_COMPLETE);
}

@Override
public WorkItemTransition startingTransition(Map<String, Object> data, Policy... policies) {
return workItemLifeCycle.newTransition(TRANSITION_CREATED_ACTIVE.id(), null, data, policies);
return workItemLifeCycle.newTransition("activate", null, data, policies);
}

@Override
public WorkItemTransition abortTransition(String phaseStatus, Policy... policies) {
return workItemLifeCycle.newTransition(TRANSITION_RESERVED_ABORT.id(), phaseStatus, emptyMap(), policies);
return workItemLifeCycle.newTransition("abort", phaseStatus, emptyMap(), policies);
}

@Override
public WorkItemTransition completeTransition(String phaseStatus, Map<String, Object> data, Policy... policies) {
return workItemLifeCycle.newTransition(TRANSITION_RESERVED_COMPLETE.id(), phaseStatus, data, policies);
return workItemLifeCycle.newTransition("complete", phaseStatus, data, policies);
}

static public Optional<WorkItemTransition> userTaskActivateWorkItemHandler(KogitoWorkItemManager manager, KogitoWorkItemHandler handler, KogitoWorkItem workItem, WorkItemTransition transition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
import org.kie.kogito.internal.process.workitem.Policy;
import org.kie.kogito.internal.process.workitem.WorkItemTransition;
import org.kie.kogito.jbpm.usertask.handler.UserTaskKogitoWorkItemHandler;
import org.kie.kogito.process.Process;
import org.kie.kogito.process.ProcessInstance;
import org.kie.kogito.process.Processes;
Expand Down Expand Up @@ -150,7 +151,7 @@ public void testCallActivityTaskWithExpressionsForIO() throws Exception {
assertThat(workItems).hasSize(1);
WorkItem wi = workItems.get(0);
assertThat(wi.getName()).isEqualTo("MyTask");
assertThat(wi.getPhaseStatus()).isEqualTo("Activated");
assertThat(wi.getPhaseStatus()).isEqualTo(UserTaskKogitoWorkItemHandler.RESERVED.getName());

KogitoWorkItemHandler handler = getWorkItemHandler(p, wi);
WorkItemTransition transition = handler.completeTransition(workItems.get(0).getPhaseStatus(), parameters, securityPolicy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void testIntermediateEndSignal() throws Exception {
public void testIntermediateSignalEventWithData() throws Exception {
Map<TYPE, List<String>> resourcesTypeMap = new HashMap<>();
resourcesTypeMap.put(TYPE.PROCESS, Collections.singletonList("signalevent/IntermediateCatchEventSignal.bpmn2"));
resourcesTypeMap.put(TYPE.USER_TASK, Collections.singletonList("signalevent/IntermediateCatchEventSignal.bpmn2"));
Application app = generateCode(resourcesTypeMap);
assertThat(app).isNotNull();

Expand Down Expand Up @@ -139,6 +140,7 @@ public void testIntermediateSignalEventWithData() throws Exception {
public void testBoundarySignalEventWithData() throws Exception {
Map<TYPE, List<String>> resourcesTypeMap = new HashMap<>();
resourcesTypeMap.put(TYPE.PROCESS, Collections.singletonList("signalevent/BoundarySignalEventOnTask.bpmn2"));
resourcesTypeMap.put(TYPE.USER_TASK, Collections.singletonList("signalevent/BoundarySignalEventOnTask.bpmn2"));
Application app = generateCode(resourcesTypeMap);
assertThat(app).isNotNull();

Expand Down Expand Up @@ -177,6 +179,7 @@ public void testBoundarySignalEventWithData() throws Exception {
public void testBoundaryInterruptingSignalEventWithData() throws Exception {
Map<TYPE, List<String>> resourcesTypeMap = new HashMap<>();
resourcesTypeMap.put(TYPE.PROCESS, Collections.singletonList("signalevent/BoundaryInterruptingSignalEventOnTask.bpmn2"));
resourcesTypeMap.put(TYPE.USER_TASK, Collections.singletonList("signalevent/BoundaryInterruptingSignalEventOnTask.bpmn2"));
Application app = generateCode(resourcesTypeMap);
assertThat(app).isNotNull();

Expand Down Expand Up @@ -204,6 +207,7 @@ public void testBoundaryInterruptingSignalEventWithData() throws Exception {
public void testIntermediateSignalEventWithDataControlledByUnitOfWork() throws Exception {
Map<TYPE, List<String>> resourcesTypeMap = new HashMap<>();
resourcesTypeMap.put(TYPE.PROCESS, Collections.singletonList("signalevent/IntermediateCatchEventSignal.bpmn2"));
resourcesTypeMap.put(TYPE.USER_TASK, Collections.singletonList("signalevent/IntermediateCatchEventSignal.bpmn2"));
Application app = generateCode(resourcesTypeMap);
assertThat(app).isNotNull();
// create first unit of work
Expand Down

0 comments on commit 848dbb4

Please sign in to comment.