diff --git a/taskana-adapter-camunda-spring-boot-test/pom.xml b/taskana-adapter-camunda-spring-boot-test/pom.xml
index 1b5c340b..51dfb517 100644
--- a/taskana-adapter-camunda-spring-boot-test/pom.xml
+++ b/taskana-adapter-camunda-spring-boot-test/pom.xml
@@ -119,6 +119,11 @@
taskana-adapter-camunda-outbox-rest-spring-boot-starter
${project.version}
+
+ org.awaitility
+ awaitility
+ test
+
org.assertj
assertj-core
@@ -142,7 +147,24 @@
okhttp
test
-
+
+ io.github.logrecorder
+ logrecorder-junit5
+ 2.9.1
+ test
+
+
+ io.github.logrecorder
+ logrecorder-logback
+ 2.9.1
+ test
+
+
+ io.github.logrecorder
+ logrecorder-assertions
+ 2.9.1
+ test
+
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/AbsIntegrationTest.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/AbsIntegrationTest.java
index ee6fb3fd..38bbd793 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/AbsIntegrationTest.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/AbsIntegrationTest.java
@@ -47,22 +47,19 @@ abstract class AbsIntegrationTest {
@Value("${taskana.adapter.scheduler.run.interval.for.complete.referenced.tasks.in.milliseconds}")
protected long adapterCompletionPollingInterval;
- @Value(
- "${taskana.adapter.scheduler.run.interval.for.check.finished.referenced.tasks.in.milliseconds}")
+ @Value("${taskana.adapter.scheduler.run.interval.for.check.finished.referenced.tasks.in.milliseconds}")
protected long adapterCancelledClaimPollingInterval;
@Value("${taskana.adapter.scheduler.run.interval.for.claim.referenced.tasks.in.milliseconds}")
protected long adapterClaimPollingInterval;
- @Value(
- "${taskana.adapter.scheduler.run.interval.for.cancel.claim.referenced.tasks.in.milliseconds}")
+ @Value("${taskana.adapter.scheduler.run.interval.for.cancel.claim.referenced.tasks.in.milliseconds}")
protected long adapterCancelPollingInterval;
@Value("${adapter.polling.inverval.adjustment.factor}")
protected double adapterPollingInvervalAdjustmentFactor;
- @Value(
- "${taskana.adapter.scheduler.run.interval.for.retries.and.blocking.taskevents.in.milliseconds}")
+ @Value("${taskana.adapter.scheduler.run.interval.for.retries.and.blocking.taskevents.in.milliseconds}")
protected long adapterRetryAndBlockingInterval;
protected CamundaProcessengineRequester camundaProcessengineRequester;
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/ArchitectureTest.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/ArchitectureTest.java
index 811dfe04..bb28ca39 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/ArchitectureTest.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/ArchitectureTest.java
@@ -12,7 +12,6 @@
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption.OnlyIncludeTests;
import java.util.List;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.TestTemplate;
@@ -65,7 +64,6 @@ void testClassesAndTestMethodsShouldBePackagePrivate() {
.check(IMPORTED_TEST_CLASSES);
}
- @Disabled("so long disabled until all tests using awaitibility")
@Test
void noMethodsShouldUseThreadSleep() {
noClasses()
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/CamundaProcessengineRequester.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/CamundaProcessengineRequester.java
index fc5472c4..92bb9098 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/CamundaProcessengineRequester.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/CamundaProcessengineRequester.java
@@ -210,14 +210,10 @@ public boolean isCorrectAssigneeFromHistory(String camundaTaskId, String assigne
restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
// no task found will only show in empty body
JSONArray taskHistoryRetrievalAnswerJson = new JSONArray(response.getBody());
- if (taskHistoryRetrievalAnswerJson.length() == 0) {
- return false;
- } else {
- String camundaTaskAssignee =
- (String) ((JSONObject) taskHistoryRetrievalAnswerJson.get(0)).get("assignee");
- if (assignee.equals(camundaTaskAssignee)) {
- return true;
- }
+ if (!taskHistoryRetrievalAnswerJson.isEmpty()) {
+ JSONObject jsonObject = (JSONObject) taskHistoryRetrievalAnswerJson.get(0);
+ Object jsonObjectAssignee = jsonObject.get("assignee");
+ return assignee.equals(jsonObjectAssignee);
}
return false;
}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/CamundaTaskEventErrorHandlerTest.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/CamundaTaskEventErrorHandlerTest.java
index 7b88d840..4362f3e5 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/CamundaTaskEventErrorHandlerTest.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/CamundaTaskEventErrorHandlerTest.java
@@ -1,8 +1,13 @@
package pro.taskana.adapter.integration;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Durations.ONE_HUNDRED_MILLISECONDS;
+import static org.awaitility.Durations.ONE_SECOND;
+import static org.awaitility.Durations.TWO_HUNDRED_MILLISECONDS;
import org.apache.commons.lang3.StringUtils;
+import org.hamcrest.Matchers;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.jupiter.api.AfterEach;
@@ -76,12 +81,14 @@ void should_CreateErrorLogWithOneCause_When_ExceptionWithOneCauseOccurred() {
connector.taskanaTaskFailedToBeCreatedForNewReferencedTask(
referencedTask, testException)));
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- CamundaTaskEvent camundaTaskEvent = taskanaOutboxRequester.getAllEvents().get(0);
+ CamundaTaskEvent camundaTaskEvent = await()
+ .atMost(ONE_SECOND)
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .pollDelay(TWO_HUNDRED_MILLISECONDS)
+ .until(
+ () -> taskanaOutboxRequester.getAllEvents(),
+ Matchers.hasSize(1)).get(0);
JSONObject errorJson = new JSONObject(camundaTaskEvent.getError());
assertThat(errorJson).hasToString(expectedErrorJson.toString());
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestCancelledTaskRetrieval.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestCancelledTaskRetrieval.java
index 42fb981e..595bec7a 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestCancelledTaskRetrieval.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestCancelledTaskRetrieval.java
@@ -2,8 +2,14 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Durations.ONE_HUNDRED_MILLISECONDS;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static pro.taskana.utils.AwaitilityUtils.checkCamundaTaskIsCompleted;
+import static pro.taskana.utils.AwaitilityUtils.getDuration;
+import static pro.taskana.utils.AwaitilityUtils.getTaskSummary;
-import java.time.Instant;
import java.util.List;
import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor;
import org.junit.jupiter.api.Test;
@@ -20,6 +26,7 @@
import pro.taskana.task.api.exceptions.InvalidCallbackStateException;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.TaskSummary;
+import pro.taskana.utils.TaskStateMatcher;
/**
* Test class to test the cancellation of camunda tasks upon cancellation of taskana tasks and vice
@@ -43,44 +50,45 @@ void should_DeleteCamundaTaskAndProcess_When_DeleteTaskanaTask() throws Exceptio
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(camundaTaskId).isEqualTo(taskanaTaskExternalId);
- String taskanaTaskId = taskanaTasks.get(0).getId();
-
- // complete taskana-task and wait
- this.taskService.claim(taskanaTaskId);
- this.taskService.completeTask(taskanaTaskId);
- assertThatThrownBy(() -> taskService.deleteTask(taskanaTaskId))
- .isInstanceOf(InvalidCallbackStateException.class)
- .hasMessageContaining(
- "Expected callback state of Task with id '%s' "
- + "to be: '[NONE, CLAIMED, CALLBACK_PROCESSING_COMPLETED]', "
- + "but found 'CALLBACK_PROCESSING_REQUIRED'",
- taskanaTaskId);
- Thread.sleep((long) (this.adapterCancelPollingInterval * 1.2));
-
- // assert camunda task was deleted
- boolean taskRetrievalSuccessful =
- this.camundaProcessengineRequester.getTaskFromTaskId(camundaTaskId);
- assertThat(taskRetrievalSuccessful).isFalse();
-
- // attempt to delete process instance, should fail because process instance should already be
- // deleted in
- // response
- boolean processInstanceDeletionSuccessful =
- this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, false);
- assertThat(processInstanceDeletionSuccessful).isFalse();
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ String taskanaTaskId = taskanaTaskSummary.getId();
+
+ // complete taskana-task and wait
+ this.taskService.claim(taskanaTaskId);
+ this.taskService.completeTask(taskanaTaskId);
+ assertThatThrownBy(() -> taskService.deleteTask(taskanaTaskId))
+ .isInstanceOf(InvalidCallbackStateException.class)
+ .hasMessageContaining(
+ "Expected callback state of Task with id '%s' "
+ + "to be: '[NONE, CLAIMED, CALLBACK_PROCESSING_COMPLETED]', "
+ + "but found 'CALLBACK_PROCESSING_REQUIRED'",
+ taskanaTaskId);
+
+ // assert camunda task was deleted
+ await()
+ .atMost(getDuration(adapterCancelPollingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () -> this.camundaProcessengineRequester.getTaskFromTaskId(camundaTaskId), is(false));
+
+ // attempt to delete process instance, should fail because process instance should already be
+ // deleted in response
+ boolean processInstanceDeletionSuccessful =
+ this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, false);
+ assertThat(processInstanceDeletionSuccessful).isFalse();
}
@WithAccessId(
@@ -91,40 +99,41 @@ void should_TerminateTaskanaTask_When_DeleteCamundaProcessInstance() throws Exce
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(camundaTaskId).isEqualTo(taskanaTaskExternalId);
-
- // delete camunda process instance and wait
- boolean camundaProcessCancellationSucessful =
- this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, false);
- assertThat(camundaProcessCancellationSucessful).isTrue();
-
- // assert deletion was successful by attempting to delete again
- boolean camundaProcessCancellationSucessful2 =
- this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, false);
- assertThat(camundaProcessCancellationSucessful2).isFalse();
- Thread.sleep((long) (this.adapterCancelPollingInterval * 1.2));
-
- // assert taskana task was completed but still exists
- taskanaTasks = this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- Instant taskanaTaskCompletion = taskanaTasks.get(0).getCompleted();
- Instant taskanaTaskCreation = taskanaTasks.get(0).getCreated();
- TaskState taskanaTaskState = taskanaTasks.get(0).getState();
- assertThat(taskanaTaskState).isEqualTo(TaskState.TERMINATED);
- assertThat(taskanaTaskCompletion).isNotNull();
- assertThat(taskanaTaskCompletion.compareTo(taskanaTaskCreation)).isEqualTo(1);
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ // delete camunda process instance and wait
+ boolean camundaProcessCancellationSucessful =
+ this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, false);
+ assertThat(camundaProcessCancellationSucessful).isTrue();
+
+ // assert deletion was successful by attempting to delete again
+ boolean camundaProcessCancellationSucessful2 =
+ this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, false);
+ assertThat(camundaProcessCancellationSucessful2).isFalse();
+
+ // assert taskana task was completed but still exists
+ TaskSummary canceledTaskanaTask =
+ await()
+ .atMost(getDuration(adapterCancelPollingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list().get(0),
+ new TaskStateMatcher(TaskState.TERMINATED));
+ assertThat(canceledTaskanaTask.getCompleted()).isNotNull();
+ assertThat(canceledTaskanaTask.getCompleted().compareTo(canceledTaskanaTask.getCreated()))
+ .isEqualTo(1);
}
@WithAccessId(
@@ -135,33 +144,47 @@ void should_BeAbleToDeleteTaskanaTask_When_DeleteCamundaTask() throws Exception
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
// delete camunda process without notifying the listeners
- boolean camundaProcessCancellationSucessful =
- this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, true);
- assertThat(camundaProcessCancellationSucessful).isTrue();
-
- for (String camundaTaskId : camundaTaskIds) {
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(camundaTaskId).isEqualTo(taskanaTaskExternalId);
- taskService.forceCompleteTask(taskanaTasks.get(0).getId());
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- // now it should be possible to delete the taskana task.
- taskService.deleteTask(taskanaTasks.get(0).getId());
-
- assertThatThrownBy(() -> taskService.getTask(taskanaTasks.get(0).getId()))
- .isInstanceOf(TaskNotFoundException.class);
- }
+ await()
+ .atMost(getDuration(adapterTaskPollingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () ->
+ this.camundaProcessengineRequester.deleteProcessInstanceWithId(
+ processInstanceId, true),
+ is(true));
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+ taskService.forceCompleteTask(taskanaTaskSummary.getId());
+
+ // now it should be possible to delete the taskana task.
+ await()
+ .atMost(getDuration(adapterTaskPollingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ // ignoring because, we need to wait for an undefined amount of time until deletion is
+ // successful
+ .ignoreException(InvalidCallbackStateException.class)
+ .until(
+ () -> {
+ taskService.deleteTask(taskanaTaskSummary.getId());
+ return true;
+ },
+ is(true));
+ assertThatThrownBy(() -> taskService.getTask(taskanaTaskSummary.getId()))
+ .isInstanceOf(TaskNotFoundException.class);
}
@WithAccessId(
@@ -172,40 +195,46 @@ void should_CancelTaskanaTask_When_InterruptionByTimerOfCamundaTaskOccurs() thro
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_timed_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(camundaTaskId).isEqualTo(taskanaTaskExternalId);
-
- // wait for the camunda task to be interrupted by the timer event (1 second), then the camunda
- // job poll.
- // Assert it was interrupted.
- Thread.sleep(1000 + (long) (this.jobExecutor.getMaxWait() * 1.2));
- boolean taskRetrievalSuccessful =
- this.camundaProcessengineRequester.getTaskFromTaskId(camundaTaskId);
- assertThat(taskRetrievalSuccessful).isFalse();
-
- // wait for the adapter to register the interruption
- Thread.sleep((long) (this.adapterCancelledClaimPollingInterval * 1.2));
-
- // assert taskana task was completed but still exists
- taskanaTasks = this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- Instant taskanaTaskCompletion = taskanaTasks.get(0).getCompleted();
- Instant taskanaTaskCreation = taskanaTasks.get(0).getCreated();
- TaskState taskanaTaskState = taskanaTasks.get(0).getState();
- assertThat(taskanaTaskCompletion).isNotNull();
- assertThat(taskanaTaskCompletion.compareTo(taskanaTaskCreation)).isEqualTo(1);
- assertThat(taskanaTaskState).isEqualTo(TaskState.CANCELLED);
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ // wait for the camunda task to be interrupted by the timer event (1 second), then the camunda
+ // job poll.
+ // Assert it was interrupted.
+ checkCamundaTaskIsCompleted(
+ jobExecutor,
+ camundaProcessengineRequester,
+ camundaTaskId
+ );
+
+ TaskSummary interruptedTask =
+ await()
+ .atMost(getDuration(adapterCancelledClaimPollingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () -> {
+ List interruptedTasks =
+ this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
+ if (!interruptedTasks.isEmpty()
+ && interruptedTasks.get(0).getState() == TaskState.CANCELLED) {
+ return interruptedTasks.get(0);
+ } else {
+ return null;
+ }
+ },
+ notNullValue());
+ assertThat(interruptedTask.getCompleted()).isAfter(interruptedTask.getCreated());
}
@WithAccessId(
@@ -216,27 +245,26 @@ void should_CompleteCamundaTask_When_CancellingTaskanaTask() throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(camundaTaskId).isEqualTo(taskanaTaskExternalId);
-
- taskService.cancelTask(taskanaTasks.get(0).getId());
-
- Thread.sleep(1000 + (long) (this.jobExecutor.getMaxWait() * 1.2));
-
- // check if camunda task got completed and therefore doesn't exist anymore
- boolean taskRetrievalSuccessful =
- this.camundaProcessengineRequester.getTaskFromTaskId(camundaTaskId);
- assertThat(taskRetrievalSuccessful).isFalse();
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ taskService.cancelTask(taskanaTaskSummary.getId());
+
+ // check if camunda task got completed and therefore doesn't exist anymore
+ checkCamundaTaskIsCompleted(
+ jobExecutor,
+ camundaProcessengineRequester,
+ camundaTaskId
+ );
}
}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestCompletedTaskRetrieval.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestCompletedTaskRetrieval.java
index 58a72811..6ef86336 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestCompletedTaskRetrieval.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestCompletedTaskRetrieval.java
@@ -1,19 +1,26 @@
package pro.taskana.adapter.integration;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Durations.ONE_HUNDRED_MILLISECONDS;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.read.ListAppender;
-import java.time.Instant;
-import java.util.HashMap;
+import static pro.taskana.utils.AwaitilityUtils.checkCamundaTaskIsCompleted;
+import static pro.taskana.utils.AwaitilityUtils.getCamundaTaskId;
+import static pro.taskana.utils.AwaitilityUtils.getDuration;
+import static pro.taskana.utils.AwaitilityUtils.getTaskSummary;
+import static pro.taskana.utils.AwaitilityUtils.verifyLogMessage;
+import static pro.taskana.utils.ResourceUtils.getResourcesAsString;
+
+import io.github.logrecorder.api.LogRecord;
+import io.github.logrecorder.junit5.RecordLoggers;
import java.util.List;
import java.util.Map;
+import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -39,6 +46,8 @@
@ContextConfiguration
class TestCompletedTaskRetrieval extends AbsIntegrationTest {
+ @Autowired private JobExecutor jobExecutor;
+
@WithAccessId(
user = "teamlead_1",
groups = {"admin"})
@@ -47,34 +56,35 @@ void should_CompleteCamundaTask_When_CompleteTaskanaTask() throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String taskanaTaskId = taskanaTasks.get(0).getId();
-
- // claim and complete taskanaTask and wait
- this.taskService.claim(taskanaTaskId);
- this.taskService.completeTask(taskanaTaskId);
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
- // assert camunda task was completed; it should no longer exists as an active task but in the
- // history
- boolean taskRetrievalSuccessful =
- this.camundaProcessengineRequester.getTaskFromTaskId(camundaTaskId);
- assertThat(taskRetrievalSuccessful).isFalse();
- boolean taskRetrievalFromHistorySuccessful =
- this.camundaProcessengineRequester.getTaskFromHistoryFromTaskId(camundaTaskId);
- assertThat(taskRetrievalFromHistorySuccessful).isTrue();
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+
+ String taskanaTaskId = taskanaTask.getId();
+
+ // claim and complete taskanaTask and wait
+ this.taskService.claim(taskanaTaskId);
+ this.taskService.completeTask(taskanaTaskId);
+
+ // assert camunda task was completed; it should no longer exists as an active task
+ // but in the history
+ checkCamundaTaskIsCompleted(jobExecutor, camundaProcessengineRequester, camundaTaskId);
+ await()
+ .atMost(getDuration(jobExecutor.getMaxWait()))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () -> this.camundaProcessengineRequester.getTaskFromHistoryFromTaskId(camundaTaskId),
+ is(true));
}
@WithAccessId(
@@ -85,38 +95,37 @@ void should_SetAssigneeAndCompleteCamundaTask_When_ForceCompleteTaskanaTask() th
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
-
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String taskanaTaskId = taskanaTasks.get(0).getId();
-
- // verify that assignee is not yet set for camunda task
- boolean assigneeNotYetSet =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null);
- assertThat(assigneeNotYetSet).isTrue();
-
- // force complete taskanaTask and wait
- this.taskService.forceCompleteTask(taskanaTaskId);
-
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
- // verify that assignee got set with forced completion
- Task taskanaTask = this.taskService.getTask(taskanaTaskId);
- boolean assigneeUpdatedSuccessfully =
- this.camundaProcessengineRequester.isCorrectAssigneeFromHistory(
- camundaTaskId, taskanaTask.getOwner());
- assertThat(assigneeUpdatedSuccessfully).isTrue();
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+
+ String taskanaTaskId = taskanaTask.getId();
+
+ // verify that assignee is not yet set for camunda task
+ assertThat(this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null)).isTrue();
+
+ // force complete taskanaTask and wait
+ this.taskService.forceCompleteTask(taskanaTaskId);
+
+ // verify that assignee got set with forced completion
+ await()
+ .atMost(getDuration(jobExecutor.getMaxWait()))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () ->
+ this.camundaProcessengineRequester.isCorrectAssigneeFromHistory(
+ camundaTaskId, this.taskService.getTask(taskanaTaskId).getOwner()),
+ is(true));
}
@WithAccessId(
@@ -127,33 +136,42 @@ void should_CompleteTaskanaTask_When_CompleteCamundaTask() throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
-
- // complete camunda task and wait
- boolean camundaTaskCompletionSucessful =
- this.camundaProcessengineRequester.completeTaskWithId(camundaTaskId);
- assertThat(camundaTaskCompletionSucessful).isTrue();
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
- // assert taskana task was completed and still exists
- taskanaTasks = this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- Instant taskanaTaskCompletion = taskanaTasks.get(0).getCompleted();
- Instant taskanaTaskCreation = taskanaTasks.get(0).getCreated();
- assertThat(taskanaTaskCompletion).isNotNull();
- assertThat(taskanaTaskCompletion).isAfter(taskanaTaskCreation);
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+
+ // complete camunda task and wait
+ boolean camundaTaskCompletionSucessful =
+ this.camundaProcessengineRequester.completeTaskWithId(camundaTaskId);
+ assertThat(camundaTaskCompletionSucessful).isTrue();
+
+ TaskSummary completedTaskanaTask =
+ await()
+ .atMost(getDuration(adapterCompletionPollingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () -> {
+ List completedTasks =
+ this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
+ if (!completedTasks.isEmpty()
+ && completedTasks.get(0).getState() == TaskState.COMPLETED) {
+ return completedTasks.get(0);
+ } else {
+ return null;
+ }
+ },
+ notNullValue());
+ assertThat(completedTaskanaTask.getCompleted()).isAfter(completedTaskanaTask.getCreated());
}
@WithAccessId(
@@ -166,43 +184,32 @@ void should_SetVariablesInCamunda_When_CompleteTaskanaTaskWithTheseNewProcessVar
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_multiple_user_tasks_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
// retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(0)).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskIds.get(0));
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ String taskanaTaskId = taskanaTaskSummary.getId();
// create map for new process variables and set new process variables in it
- Map newProcessVariables = new HashMap<>();
-
- newProcessVariables.put(
- "camunda:attribute1",
- "{\"type\":\"object\","
- + "\"value\":\"{\\\"stringField\\\":\\\"\\\\fForm feed \\\\b Backspace \\\\t Tab "
- + "\\\\\\\\Backslash \\\\n newLine \\\\r Carriage return \\\\\\\" DoubleQuote\\\","
- + "\\\"intField\\\":1,\\\"doubleField\\\":1.1,\\\"booleanField\\\":false,"
- + "\\\"processVariableTestObjectTwoField\\\":"
- + "[{\\\"stringFieldObjectTwo\\\":\\\"stringValueObjectTwo\\\","
- + "\\\"intFieldObjectTwo\\\":2,\\\"doubleFieldObjectTwo\\\":2.2,"
- + "\\\"booleanFieldObjectTwo\\\":true,\\\"dateFieldObjectTwo\\\":null}]}\","
- + "\"valueInfo\":{\"objectTypeName\":\"pro.taskana.impl.ProcessVariableTestObject\","
- + "\"serializationDataFormat\":\"application/json\"}}");
- newProcessVariables.put(
- "camunda:attribute2",
- "{\"valueInfo\":{\"objectTypeName\":\"java.lang.Boolean\"},"
- + "\"type\":\"boolean\",\"value\":true}");
- newProcessVariables.put(
- "attribute3",
- "{\"valueInfo\":{\"objectTypeName\":\"java.lang.Integer\"},"
- + "\"type\":\"integer\",\"value\":5}");
-
- Task taskanaTask = this.taskService.getTask(taskanaTasks.get(0).getId());
+ Map newProcessVariables =
+ Map.of(
+ "camunda:attribute1",
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute1.json"),
+ "camunda:attribute2",
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute2.json"),
+ "attribute3",
+ getResourcesAsString(this.getClass(), "process-variable-attribute3.json"));
+
+ Task taskanaTask = this.taskService.getTask(taskanaTaskId);
taskanaTask.setCustomAttributeMap(newProcessVariables);
// update the task to set the process variables
@@ -211,57 +218,80 @@ void should_SetVariablesInCamunda_When_CompleteTaskanaTaskWithTheseNewProcessVar
// complete task with setting process variables in camunda
// and wait for adapter to create next task from
// next user task in camunda
- taskanaTask = this.taskService.forceCompleteTask(taskanaTask.getId());
-
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
- List newCamundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ taskanaTask = this.taskService.forceCompleteTask(taskanaTaskId);
+
+ String updatedCamundaTaskId =
+ getCamundaTaskId(
+ adapterCompletionPollingInterval,
+ () -> {
+ List updatedCamundaTaskIds =
+ this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(
+ processInstanceId);
+ if (!updatedCamundaTaskIds.isEmpty()
+ && !camundaTaskId.contentEquals(updatedCamundaTaskIds.get(0))) {
+ return updatedCamundaTaskIds.get(0);
+ } else {
+ return null;
+ }
+ });
// retrieve and check taskanaTaskId
- taskanaTasks = this.taskService.createTaskQuery().externalIdIn(newCamundaTaskIds.get(0)).list();
- assertThat(taskanaTasks).hasSize(1);
- taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(newCamundaTaskIds.get(0));
+ TaskSummary updatedTaskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(updatedCamundaTaskId).list());
+ assertThat(updatedCamundaTaskId).isEqualTo(updatedTaskanaTaskSummary.getExternalId());
+
+ String updatedTaskanaTaskId = updatedTaskanaTaskSummary.getId();
// retrieve the new created task from the new user task in camunda
- Task taskanaTask2 = this.taskService.getTask(taskanaTasks.get(0).getId());
+ Task updatedTaskanaTask = this.taskService.getTask(updatedTaskanaTaskId);
// make sure the task actually got completed
- assertThat(taskanaTask.getId()).isNotEqualTo(taskanaTask2.getId());
+ assertThat(taskanaTaskId).isNotEqualTo(updatedTaskanaTaskId);
// make sure that the prefixed process variables were set and successfully transfered back over
// the outbox
- assertThat(taskanaTask2.getCustomAttributeMap()).hasSize(2);
+ assertThat(updatedTaskanaTask.getCustomAttributeMap()).hasSize(2);
assertThat(
taskanaTask.getCustomAttributeMap().get("camunda:attribute1"),
- SameJSONAs.sameJSONAs(taskanaTask2.getCustomAttributeMap().get("camunda:attribute1")));
-
- this.taskService.forceCompleteTask(taskanaTask2.getId());
-
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
- newCamundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ SameJSONAs.sameJSONAs(
+ updatedTaskanaTask.getCustomAttributeMap().get("camunda:attribute1")));
+
+ this.taskService.forceCompleteTask(updatedTaskanaTaskId);
+
+ String completedCamundaTaskId =
+ getCamundaTaskId(
+ adapterCompletionPollingInterval,
+ () -> {
+ List completedCamundaTaskIds =
+ this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(
+ processInstanceId);
+ if (!completedCamundaTaskIds.isEmpty()
+ && !updatedCamundaTaskId.contentEquals(completedCamundaTaskIds.get(0))) {
+ return completedCamundaTaskIds.get(0);
+ } else {
+ return null;
+ }
+ });
// retrieve and check taskanaTaskId
- taskanaTasks = this.taskService.createTaskQuery().externalIdIn(newCamundaTaskIds.get(0)).list();
- assertThat(taskanaTasks).hasSize(1);
- taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(newCamundaTaskIds.get(0));
+ TaskSummary completedTaskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(completedCamundaTaskId).list());
+ assertThat(completedCamundaTaskId).isEqualTo(completedTaskanaTaskSummary.getExternalId());
+
+ String completedTaskanaTaskId = completedTaskanaTaskSummary.getId();
// retrieve the new created task from the new user task in camunda
- Task taskanaTask3 = this.taskService.getTask(taskanaTasks.get(0).getId());
+ Task completedTaskanaTask = this.taskService.getTask(completedTaskanaTaskId);
- assertThat(taskanaTask2.getId()).isNotEqualTo(taskanaTask3.getId());
+ assertThat(updatedTaskanaTaskId).isNotEqualTo(completedTaskanaTaskId);
// make sure that the process variables were set and transfered successfully over the outbox
- assertThat(taskanaTask2.getCustomAttributeMap())
- .isEqualTo(taskanaTask3.getCustomAttributeMap());
+ assertThat(updatedTaskanaTask.getCustomAttributeMap())
+ .isEqualTo(completedTaskanaTask.getCustomAttributeMap());
}
@WithAccessId(
@@ -274,19 +304,22 @@ void should_UpdateCamundaVariables_When_CompleteTaskanaTaskWithTheseUpdatedProce
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_with_complex_variables_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
// retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(0)).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskIds.get(0));
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
- Task taskanaTask = this.taskService.getTask(taskanaTasks.get(0).getId());
+ String taskanaTaskId = taskanaTaskSummary.getId();
+
+ Task taskanaTask = this.taskService.getTask(taskanaTaskId);
String alreadyExistingComplexProcessVariable =
taskanaTask.getCustomAttributeMap().get("camunda:attribute1");
@@ -304,10 +337,10 @@ void should_UpdateCamundaVariables_When_CompleteTaskanaTaskWithTheseUpdatedProce
String updatedExistingPrimitiveProcessVariable =
alreadyExistingPrimitiveProcessVariable.replaceAll("\"value\":true", "\"value\":false");
- Map updatedProcessVariables = new HashMap<>();
-
- updatedProcessVariables.put("camunda:attribute1", updatedExistingComplexProcessVariable);
- updatedProcessVariables.put("camunda:attribute3", updatedExistingPrimitiveProcessVariable);
+ Map updatedProcessVariables =
+ Map.of(
+ "camunda:attribute1", updatedExistingComplexProcessVariable,
+ "camunda:attribute3", updatedExistingPrimitiveProcessVariable);
taskanaTask.setCustomAttributeMap(updatedProcessVariables);
@@ -317,89 +350,85 @@ void should_UpdateCamundaVariables_When_CompleteTaskanaTaskWithTheseUpdatedProce
// complete task with setting process variables in camunda
// and wait for adapter to create next askana task from
// next user task in camunda
- this.taskService.forceCompleteTask(taskanaTask.getId());
-
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
- List newCamundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ this.taskService.forceCompleteTask(taskanaTaskId);
+
+ String completedCamundaTaskId =
+ getCamundaTaskId(
+ adapterCompletionPollingInterval,
+ () -> {
+ List completedCamundaTaskIds =
+ this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(
+ processInstanceId);
+ if (!completedCamundaTaskIds.isEmpty()
+ && !camundaTaskId.contentEquals(completedCamundaTaskIds.get(0))) {
+ return completedCamundaTaskIds.get(0);
+ } else {
+ return null;
+ }
+ });
+ assertThat(completedCamundaTaskId).isNotEqualTo(camundaTaskId);
// retrieve and check taskanaTaskId
- taskanaTasks = this.taskService.createTaskQuery().externalIdIn(newCamundaTaskIds.get(0)).list();
- assertThat(taskanaTasks).hasSize(1);
- taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(newCamundaTaskIds.get(0));
+ TaskSummary completedTaskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(completedCamundaTaskId).list());
+ assertThat(completedCamundaTaskId).isEqualTo(completedTaskanaTaskSummary.getExternalId());
- // retrieve the newly created task from the new user task in camunda
- Task taskanaTask2 = this.taskService.getTask(taskanaTasks.get(0).getId());
+ String completedTaskanaTaskId = completedTaskanaTaskSummary.getId();
// make sure the task actually got completed
- assertThat(taskanaTask.getId()).isNotEqualTo(taskanaTask2.getId());
+ assertThat(taskanaTaskId).isNotEqualTo(completedTaskanaTaskId);
+
+ // retrieve the newly created task from the new user task in camunda
+ Task completedTaskanaTask = this.taskService.getTask(completedTaskanaTaskId);
// make sure that the process variables were updated and transfered over the outbox
assertThat(
updatedExistingComplexProcessVariable,
- SameJSONAs.sameJSONAs(taskanaTask2.getCustomAttributeMap().get("camunda:attribute1")));
+ SameJSONAs.sameJSONAs(
+ completedTaskanaTask.getCustomAttributeMap().get("camunda:attribute1")));
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_PreventLoopFromScheduledMethod_When_TryingToCompleteNoLongerExistingCamundaTask()
- throws Exception {
-
- Logger camundaUtilRequesterLogger =
- (Logger) LoggerFactory.getLogger(CamundaUtilRequester.class);
-
- camundaUtilRequesterLogger.setLevel(Level.DEBUG);
- ListAppender listAppender = new ListAppender<>();
- listAppender.start();
- camundaUtilRequesterLogger.addAppender(listAppender);
-
+ @RecordLoggers(CamundaUtilRequester.class)
+ void should_PreventLoopFromScheduledMethod_When_TryingToCompleteNoLongerExistingCamundaTask(
+ LogRecord log) throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
-
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
-
- // delete camunda process without notifying the listeners
- boolean camundaProcessCancellationSucessful =
- this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, true);
- assertThat(camundaProcessCancellationSucessful).isTrue();
-
- // complete task in taskana and verify updated TaskState to be 'COMPLETED'
- String taskanaTaskId = taskanaTasks.get(0).getId();
- this.taskService.forceCompleteTask(taskanaTaskId);
- TaskState updatedTaskState = this.taskService.getTask(taskanaTaskId).getState();
- assertThat(updatedTaskState).isEqualTo(TaskState.COMPLETED);
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
- // wait for the adapter to try to complete the not anymore existing camunda task
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- List logsList = listAppender.list;
-
- // verify that the CamundaUtilRequester log contains 1 entry for
- // the failed try to complete the not existing camunda task
- assertThat(logsList).hasSize(1);
-
- String camundaUtilRequesterLogMessage = logsList.get(0).getFormattedMessage();
-
- assertThat(camundaUtilRequesterLogMessage)
- .isEqualTo("Camunda Task " + camundaTaskId + " is not existing. Returning silently");
- }
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ String taskanaTaskId = taskanaTaskSummary.getId();
+
+ // delete camunda process without notifying the listeners
+ boolean camundaProcessCancellationSucessful =
+ this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, true);
+ assertThat(camundaProcessCancellationSucessful).isTrue();
+
+ // complete task in taskana and verify updated TaskState to be 'COMPLETED'
+ this.taskService.forceCompleteTask(taskanaTaskId);
+ TaskState updatedTaskState = this.taskService.getTask(taskanaTaskId).getState();
+ assertThat(updatedTaskState).isEqualTo(TaskState.COMPLETED);
+
+ // wait for the adapter to claim the not anymore existing camunda task
+ verifyLogMessage(
+ adapterTaskPollingInterval,
+ log,
+ "Camunda Task " + camundaTaskId + " is not existing. Returning silently");
}
}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestDisabledTaskClaim.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestDisabledTaskClaim.java
index 7e9ff5d2..ffbbc7ac 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestDisabledTaskClaim.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestDisabledTaskClaim.java
@@ -1,9 +1,13 @@
package pro.taskana.adapter.integration;
-import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
+import static pro.taskana.utils.AwaitilityUtils.getTaskSummary;
+import static pro.taskana.utils.AwaitilityUtils.verifyLogMessage;
+import io.github.logrecorder.api.LogRecord;
+import io.github.logrecorder.junit5.RecordLoggers;
import java.lang.reflect.Field;
-import java.util.List;
+import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +31,8 @@
@AutoConfigureWebTestClient
@ContextConfiguration
@ExtendWith(JaasExtension.class)
+// This Test must be executed at the beginning, so that the logger test is working as expected
+@Order(1)
class TestDisabledTaskClaim extends AbsIntegrationTest {
@Autowired CamundaTaskClaimer camundaTaskClaimer;
@@ -39,28 +45,28 @@ class TestDisabledTaskClaim extends AbsIntegrationTest {
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_NotClaimOrCancelClaimCamundaTask_When_CamundaClaimingDisabled() throws Exception {
-
+ @RecordLoggers({CamundaTaskClaimer.class, CamundaTaskClaimCanceler.class})
+ void should_NotClaimOrCancelClaimCamundaTask_When_CamundaClaimingDisabled(LogRecord log)
+ throws Exception {
setClaimingEnabled(false);
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_with_assignee_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- // check that one new UserTask was started
- assertThat(camundaTaskIds).hasSize(1);
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
- // retrieve and check external task id of created taskana task
- String camundaTaskId = camundaTaskIds.get(0);
- TaskSummary taskanaTask =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).single();
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
- String taskanaTaskExternalId = taskanaTask.getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
+ String taskanaTaskId = taskanaTaskSummary.getId();
// verify that assignee is already set
boolean assigneeAlreadySet =
@@ -68,7 +74,6 @@ void should_NotClaimOrCancelClaimCamundaTask_When_CamundaClaimingDisabled() thro
assertThat(assigneeAlreadySet).isTrue();
// verify that TaskState of taskana task is 'READY' first
- String taskanaTaskId = taskanaTask.getId();
Task task = this.taskService.getTask(taskanaTaskId);
assertThat(task.getState()).isEqualTo(TaskState.READY);
@@ -77,7 +82,11 @@ void should_NotClaimOrCancelClaimCamundaTask_When_CamundaClaimingDisabled() thro
Task updatedTask = this.taskService.getTask(taskanaTaskId);
assertThat(updatedTask.getState()).isEqualTo(TaskState.CLAIMED);
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.3));
+ verifyLogMessage(
+ adapterClaimPollingInterval,
+ log,
+ "Synchronizing claim of tasks in TASKANA to Camunda is set to false");
+
// verify assignee for camunda task did not get updated
boolean assigneeNotUpdated =
this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "someAssignee");
@@ -86,7 +95,10 @@ void should_NotClaimOrCancelClaimCamundaTask_When_CamundaClaimingDisabled() thro
// cancel claim TASKANA task
taskService.forceCancelClaim(task.getId());
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.3));
+ verifyLogMessage(
+ adapterCancelledClaimPollingInterval,
+ log,
+ "Synchronizing CancelClaim of Tasks in TASKANA to Camunda is set to false");
// verify assignee for camunda task did not get updated
assigneeNotUpdated =
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestFailedTaskCreation.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestFailedTaskCreation.java
index 41740fdd..773a9678 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestFailedTaskCreation.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestFailedTaskCreation.java
@@ -1,6 +1,10 @@
package pro.taskana.adapter.integration;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Durations.ONE_HUNDRED_MILLISECONDS;
+import static org.hamcrest.Matchers.hasSize;
+import static pro.taskana.utils.AwaitilityUtils.getDuration;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
@@ -24,6 +28,7 @@
@AutoConfigureWebTestClient
@ExtendWith(JaasExtension.class)
@ContextConfiguration
+@SuppressWarnings("checkstyle:LineLength")
class TestFailedTaskCreation extends AbsIntegrationTest {
@AfterEach
@@ -37,8 +42,7 @@ void resetOutbox() {
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_CountDownRetriesAndAddToFailedEvents_When_TaskCreationFailedInTaskana()
- throws Exception {
+ void should_CountDownRetriesAndAddToFailedEvents_When_TaskCreationFailedInTaskana() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -49,27 +53,27 @@ void should_CountDownRetriesAndAddToFailedEvents_When_TaskCreationFailedInTaskan
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
// retries still above 0
-
- List failedEvents = taskanaOutboxRequester.getFailedEvents();
-
- assertThat(failedEvents).isEmpty();
+ await()
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .pollDelay(getDuration(adapterTaskPollingInterval))
+ .until(() -> taskanaOutboxRequester.getFailedEvents(), hasSize(0));
// adapter makes retries
- Thread.sleep(this.adapterRetryAndBlockingInterval);
-
- failedEvents = taskanaOutboxRequester.getFailedEvents();
// retries = 0, no retries left
- assertThat(failedEvents).hasSize(3);
+ await()
+ .atMost(getDuration(adapterRetryAndBlockingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(() -> taskanaOutboxRequester.getFailedEvents(), hasSize(3));
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_LogError_When_TaskCreationFailedInTaskana() throws Exception {
+ void should_LogError_When_TaskCreationFailedInTaskana() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -80,20 +84,21 @@ void should_LogError_When_TaskCreationFailedInTaskana() throws Exception {
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- List failedEvents = taskanaOutboxRequester.getFailedEvents();
-
// retries still above 0
- assertThat(failedEvents).isEmpty();
+ await()
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .pollDelay(getDuration(adapterTaskPollingInterval))
+ .until(() -> taskanaOutboxRequester.getFailedEvents(), hasSize(0));
// adapter makes retries
- Thread.sleep(this.adapterRetryAndBlockingInterval);
-
- failedEvents = taskanaOutboxRequester.getFailedEvents();
// retries = 0, no retries left
-
- assertThat(failedEvents).hasSize(3);
+ List failedEvents =
+ await()
+ .atMost(getDuration(adapterRetryAndBlockingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(() -> taskanaOutboxRequester.getFailedEvents(), hasSize(3));
assertThat(failedEvents)
.extracting(CamundaTaskEvent::getCamundaTaskId)
@@ -115,7 +120,7 @@ void should_LogError_When_TaskCreationFailedInTaskana() throws Exception {
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_DeleteFailedEvent_When_CallingDeleteEndpoint() throws Exception {
+ void should_DeleteFailedEvent_When_CallingDeleteEndpoint() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -127,13 +132,12 @@ void should_DeleteFailedEvent_When_CallingDeleteEndpoint() throws Exception {
assertThat(camundaTaskIds).hasSize(3);
// adapter makes retries
- Thread.sleep(
- (long) (this.adapterTaskPollingInterval * 1.2 + this.adapterRetryAndBlockingInterval));
-
- // retries = 0, no retries left
- List failedEvents = taskanaOutboxRequester.getFailedEvents();
-
- assertThat(failedEvents).hasSize(3);
+ List failedEvents =
+ await()
+ .atMost(getDuration((long) (adapterTaskPollingInterval * 1.2 + adapterRetryAndBlockingInterval)))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(() -> taskanaOutboxRequester.getFailedEvents(), hasSize(3));
boolean eventDeleted = taskanaOutboxRequester.deleteFailedEvent(failedEvents.get(0).getId());
@@ -146,7 +150,7 @@ void should_DeleteFailedEvent_When_CallingDeleteEndpoint() throws Exception {
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_DeleteAllFailedEvents_When_CallingDeleteAllFailedEndpoint() throws Exception {
+ void should_DeleteAllFailedEvents_When_CallingDeleteAllFailedEndpoint() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -157,28 +161,25 @@ void should_DeleteAllFailedEvents_When_CallingDeleteAllFailedEndpoint() throws E
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep(
- (long) (this.adapterTaskPollingInterval * 1.2 + this.adapterRetryAndBlockingInterval));
-
- // retries = 0, no retries left
-
- List failedEvents = taskanaOutboxRequester.getFailedEvents();
- assertThat(failedEvents).hasSize(3);
+ // adapter makes retries
+ await()
+ .atMost(getDuration((long) (adapterTaskPollingInterval * 1.2 + adapterRetryAndBlockingInterval)))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(() -> taskanaOutboxRequester.getFailedEvents(), hasSize(3));
boolean eventsDeleted = taskanaOutboxRequester.deleteAllFailedEvents();
assertThat(eventsDeleted).isTrue();
- failedEvents = taskanaOutboxRequester.getFailedEvents();
-
- assertThat(failedEvents).isEmpty();
+ assertThat(taskanaOutboxRequester.getFailedEvents()).isEmpty();
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_SetRetryForFailedEvent_When_CallingSetRetriesEndpoint() throws Exception {
+ void should_SetRetryForFailedEvent_When_CallingSetRetriesEndpoint() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -189,13 +190,13 @@ void should_SetRetryForFailedEvent_When_CallingSetRetriesEndpoint() throws Excep
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep(
- (long) (this.adapterTaskPollingInterval * 1.2 + this.adapterRetryAndBlockingInterval));
-
- // retries = 0, no retries left
- List failedEvents = taskanaOutboxRequester.getFailedEvents();
-
- assertThat(failedEvents).hasSize(3);
+ // adapter makes retries
+ List failedEvents =
+ await()
+ .atMost(getDuration((long) (adapterTaskPollingInterval * 1.2 + adapterRetryAndBlockingInterval)))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(() -> taskanaOutboxRequester.getFailedEvents(), hasSize(3));
// reset specific failedEvent
boolean remainingRetriesSet =
@@ -212,8 +213,7 @@ void should_SetRetryForFailedEvent_When_CallingSetRetriesEndpoint() throws Excep
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_SetRetryForAllFailedEvents_When_CallingSetRetriesForAllFailedEndpoint()
- throws Exception {
+ void should_SetRetryForAllFailedEvents_When_CallingSetRetriesForAllFailedEndpoint() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -224,21 +224,18 @@ void should_SetRetryForAllFailedEvents_When_CallingSetRetriesForAllFailedEndpoin
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep(
- (long) (this.adapterTaskPollingInterval * 1.2 + this.adapterRetryAndBlockingInterval));
-
- // retries = 0, no retries left
- List failedEvents = taskanaOutboxRequester.getFailedEvents();
-
- assertThat(failedEvents).hasSize(3);
+ // adapter makes retries
+ await()
+ .atMost(getDuration((long) (adapterTaskPollingInterval * 1.2 + adapterRetryAndBlockingInterval)))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(() -> taskanaOutboxRequester.getFailedEvents(), hasSize(3));
// reset specific failedEvent
boolean remainingRetriesSet = taskanaOutboxRequester.setRemainingRetriesForAll(3);
assertThat(remainingRetriesSet).isTrue();
- failedEvents = taskanaOutboxRequester.getFailedEvents();
-
- assertThat(failedEvents).isEmpty();
+ assertThat(taskanaOutboxRequester.getFailedEvents()).isEmpty();
}
}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskAcquisition.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskAcquisition.java
index ffe55c48..d791c07c 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskAcquisition.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskAcquisition.java
@@ -1,7 +1,13 @@
package pro.taskana.adapter.integration;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Durations.ONE_HUNDRED_MILLISECONDS;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static pro.taskana.utils.AwaitilityUtils.getDuration;
+import static pro.taskana.utils.AwaitilityUtils.getTaskSummary;
+import static pro.taskana.utils.ResourceUtils.getResourcesAsString;
import java.time.Instant;
import java.util.ArrayList;
@@ -61,9 +67,7 @@ class TestTaskAcquisition extends AbsIntegrationTest {
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void
- should_CreateTaskanaTasksWithVariablesInCustomAttributes_When_StartCamundaTaskWithTheseComplexVariables()
- throws Exception {
+ void should_CreateTaskanaTasksWithVariablesInCustomAttributes_When_StartCamundaTaskWithTheseComplexVariables() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -71,27 +75,14 @@ class TestTaskAcquisition extends AbsIntegrationTest {
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
String expectedComplexProcessVariable =
- "{\"type\":\"object\","
- + "\"value\":\""
- + "{\\\"stringField\\\":\\\"\\\\fForm feed \\\\b Backspace \\\\t Tab"
- + " \\\\\\\\Backslash \\\\n newLine \\\\r Carriage return \\\\\\\" DoubleQuote\\\","
- + "\\\"intField\\\":1,\\\"doubleField\\\":1.1,\\\"booleanField\\\":false,"
- + "\\\"processVariableTestObjectTwoField\\\":["
- + "{\\\"stringFieldObjectTwo\\\":\\\"stringValueObjectTwo\\\","
- + "\\\"intFieldObjectTwo\\\":2,\\\"doubleFieldObjectTwo\\\":2.2,"
- + "\\\"booleanFieldObjectTwo\\\":true,"
- + "\\\"dateFieldObjectTwo\\\":\\\"1970-01-01 13:12:11\\\"}]}\","
- + "\"valueInfo\":{\"objectTypeName\":\"pro.taskana.impl.ProcessVariableTestObject\","
- + "\"serializationDataFormat\":\"application/json\"}}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute1.json");
String expectedPrimitiveProcessVariable1 =
- "{\"type\":\"integer\",\"value\":5," + "\"valueInfo\":null}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute2.json");
String expectedPrimitiveProcessVariable2 =
- "{\"type\":\"boolean\",\"value\":true," + "\"valueInfo\":null}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute3.json");
camundaTaskIds.forEach(
camundaTaskId -> {
@@ -114,7 +105,7 @@ class TestTaskAcquisition extends AbsIntegrationTest {
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_CreateTaskanaTask_When_StartUserTaskProcessInstanceInCamunda() throws Exception {
+ void should_CreateTaskanaTask_When_StartUserTaskProcessInstanceInCamunda() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -122,27 +113,24 @@ void should_CreateTaskanaTask_When_StartUserTaskProcessInstanceInCamunda() throw
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTasks.get(0);
- String taskanaTaskExternalId = taskanaTaskSummary.getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String businessProcessId = taskanaTaskSummary.getBusinessProcessId();
- assertThat(processInstanceId).isEqualTo(businessProcessId);
- }
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+ });
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void
- should_CreateTaskanaTask_When_StartUserTaskProcessInstanceWithEmptyExtensionPropertyInCamunda()
- throws Exception {
+ void should_CreateTaskanaTask_When_StartUserTaskProcessInstanceWithEmptyExtensionPropertyInCamunda() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -150,38 +138,26 @@ void should_CreateTaskanaTask_When_StartUserTaskProcessInstanceInCamunda() throw
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTasks.get(0);
- String taskanaTaskExternalId = taskanaTaskSummary.getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String businessProcessId = taskanaTaskSummary.getBusinessProcessId();
- assertThat(processInstanceId).isEqualTo(businessProcessId);
- }
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+ });
String expectedComplexProcessVariable =
- "{\"type\":\"object\","
- + "\"value\":\""
- + "{\\\"stringField\\\":\\\"\\\\fForm feed \\\\b Backspace \\\\t Tab"
- + " \\\\\\\\Backslash \\\\n newLine \\\\r Carriage return \\\\\\\" DoubleQuote\\\","
- + "\\\"intField\\\":1,\\\"doubleField\\\":1.1,\\\"booleanField\\\":false,"
- + "\\\"processVariableTestObjectTwoField\\\":["
- + "{\\\"stringFieldObjectTwo\\\":\\\"stringValueObjectTwo\\\","
- + "\\\"intFieldObjectTwo\\\":2,\\\"doubleFieldObjectTwo\\\":2.2,"
- + "\\\"booleanFieldObjectTwo\\\":true,"
- + "\\\"dateFieldObjectTwo\\\":\\\"1970-01-01 13:12:11\\\"}]}\","
- + "\"valueInfo\":{\"objectTypeName\":\"pro.taskana.impl.ProcessVariableTestObject\","
- + "\"serializationDataFormat\":\"application/json\"}}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute1.json");
String expectedPrimitiveProcessVariable1 =
- "{\"type\":\"integer\",\"value\":5," + "\"valueInfo\":null}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute2.json");
String expectedPrimitiveProcessVariable2 =
- "{\"type\":\"boolean\",\"value\":true," + "\"valueInfo\":null}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute3.json");
camundaTaskIds.forEach(
camundaTaskId -> {
@@ -204,8 +180,7 @@ void should_CreateTaskanaTask_When_StartUserTaskProcessInstanceInCamunda() throw
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_CreateMultipleTaskanaTasks_When_StartMultipleUserTaskProcessInstanceInCamunda()
- throws Exception {
+ void should_CreateMultipleTaskanaTasks_When_StartMultipleUserTaskProcessInstanceInCamunda() {
int numberOfProcesses = 10;
List> camundaTaskIdsList = new ArrayList<>();
@@ -216,40 +191,49 @@ void should_CreateMultipleTaskanaTasks_When_StartMultipleUserTaskProcessInstance
camundaTaskIdsList.add(
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId));
}
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (List camundaTaskIds : camundaTaskIdsList) {
- for (String camundaTaskId : camundaTaskIds) {
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- }
- }
+
+ camundaTaskIdsList.forEach(
+ camundaTaskIds ->
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ }));
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_CreateTaskanaTask_When_StartCamundaTaskWithPrimitiveVariables() throws Exception {
+ void should_CreateTaskanaTask_When_StartCamundaTaskWithPrimitiveVariables() {
String variables =
- "\"variables\": {\"amount\": {\"value\":555, "
- + "\"type\":\"long\"},\"item\": {\"value\": \"item-xyz\"}}";
+ """
+ "variables": {
+ "amount": {
+ "value":555,
+ "type":"long"
+ },
+ "item": {
+ "value": "item-xyz"
+ }
+ }""";
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", variables);
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- String expectedPrimitiveVariable1 = "{\"type\":\"long\",\"value\":555,\"valueInfo\":null}";
+ String expectedPrimitiveVariable1 =
+ getResourcesAsString(this.getClass(), "process-variable-camunda-amount.json");
String expectedPrimitiveVariable2 =
- "{\"type\":\"string\",\"value\":\"item-xyz\",\"valueInfo\":null}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-item.json");
camundaTaskIds.forEach(
camundaTaskId -> {
@@ -268,33 +252,41 @@ void should_CreateTaskanaTask_When_StartCamundaTaskWithPrimitiveVariables() thro
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_CreateTaskanaTaskWithManualPriority_When_StartCamundaTaskWithThisManualPriority()
- throws Exception {
+ void should_CreateTaskanaTaskWithManualPriority_When_StartCamundaTaskWithThisManualPriority() {
String variables =
- "\"variables\": {\"taskana.manual-priority\": {\"value\":\"555\", "
- + "\"type\":\"string\"}}";
+ """
+ "variables": {
+ "taskana.manual-priority": {
+ "value":"555",
+ "type":"string"
+ }
+ }""";
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", variables);
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- TaskSummary taskanaTask =
- taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(0)).single();
-
- assertThat(taskanaTask.getManualPriority()).isEqualTo(555);
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+ assertThat(taskanaTask.getManualPriority()).isEqualTo(555);
+ });
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void
- should_CreateTaskanaTaskWithDefaultManualPriority_When_StartCamundaTaskWithoutManualPriority()
- throws Exception {
+ void should_CreateTaskanaTaskWithDefaultManualPriority_When_StartCamundaTaskWithoutManualPriority() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -302,57 +294,58 @@ void should_CreateTaskanaTaskWithManualPriority_When_StartCamundaTaskWithThisMan
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- TaskSummary taskanaTask =
- taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(0)).single();
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
- assertThat(taskanaTask.getManualPriority()).isEqualTo(-1);
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+ assertThat(taskanaTask.getManualPriority()).isEqualTo(-1);
+ });
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_SetCustomIntegersInTaskanaTask_When_CamundaTaskHasCustomIntegers() throws Exception {
- String variables =
- "\"variables\": {"
- + "\"taskana.custom-int-1\": {\"value\":\"1\", \"type\":\"string\"},"
- + "\"taskana.custom-int-2\": {\"value\":\"2\", \"type\":\"string\"},"
- + "\"taskana.custom-int-3\": {\"value\":\"3\", \"type\":\"string\"},"
- + "\"taskana.custom-int-4\": {\"value\":\"4\", \"type\":\"string\"},"
- + "\"taskana.custom-int-5\": {\"value\":\"5\", \"type\":\"string\"},"
- + "\"taskana.custom-int-6\": {\"value\":\"6\", \"type\":\"string\"},"
- + "\"taskana.custom-int-7\": {\"value\":\"7\", \"type\":\"string\"},"
- + "\"taskana.custom-int-8\": {\"value\":\"8\", \"type\":\"string\"}"
- + "}";
+ void should_SetCustomIntegersInTaskanaTask_When_CamundaTaskHasCustomIntegers() {
+ String variables = getResourcesAsString(this.getClass(), "variables-custom-integer.txt");
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", variables);
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- TaskSummary taskanaTask =
- taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(0)).single();
-
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_1)).isOne();
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_2)).isEqualTo(2);
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_3)).isEqualTo(3);
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_4)).isEqualTo(4);
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_5)).isEqualTo(5);
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_6)).isEqualTo(6);
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_7)).isEqualTo(7);
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_8)).isEqualTo(8);
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_1)).isOne();
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_2)).isEqualTo(2);
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_3)).isEqualTo(3);
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_4)).isEqualTo(4);
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_5)).isEqualTo(5);
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_6)).isEqualTo(6);
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_7)).isEqualTo(7);
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_8)).isEqualTo(8);
+ });
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_SetDefaultCustomIntegerInTaskanaTask_When_CamundaTaskHasDefaultCustomInteger()
- throws Exception {
+ void should_SetDefaultCustomIntegerInTaskanaTask_When_CamundaTaskHasDefaultCustomInteger() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -360,44 +353,50 @@ void should_SetDefaultCustomIntegerInTaskanaTask_When_CamundaTaskHasDefaultCusto
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- TaskSummary taskanaTask =
- taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(0)).single();
-
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_1)).isNull();
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_2)).isNull();
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_3)).isNull();
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_4)).isNull();
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_5)).isNull();
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_6)).isNull();
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_7)).isNull();
- assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_8)).isNull();
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_1)).isNull();
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_2)).isNull();
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_3)).isNull();
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_4)).isNull();
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_5)).isNull();
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_6)).isNull();
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_7)).isNull();
+ assertThat(taskanaTask.getCustomIntField(TaskCustomIntField.CUSTOM_INT_8)).isNull();
+ });
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void
- should_CreateTaskanaTaskWithComplexVariablesInCustomAttributes_When_StartCamundaTaskWithTheseVariables()
- throws Exception {
+ void should_CreateTaskanaTaskWithComplexVariablesInCustomAttributes_When_StartCamundaTaskWithTheseVariables()
+ throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_with_big_complex_variables_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(0)).list();
- assertThat(taskanaTasks).hasSize(1);
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
- TaskSummary taskanaTaskSummary = taskanaTasks.get(0);
- String taskanaTaskExternalId = taskanaTaskSummary.getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskIds.get(0));
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
Task taskanaTask = this.taskService.getTask(taskanaTaskSummary.getId());
Map taskanaTaskCustomAttributes = taskanaTask.getCustomAttributeMap();
@@ -411,9 +410,7 @@ void should_SetDefaultCustomIntegerInTaskanaTask_When_CamundaTaskHasDefaultCusto
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void
- should_CreateTaskanaTasksWithComplexVariablesInCustomAttributes_When_ParentExecutionOfCamundaTasksStarted()
- throws Exception {
+ void should_CreateTaskanaTasksWithComplexVariablesInCustomAttributes_When_ParentExecutionOfCamundaTasksStarted() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -422,41 +419,38 @@ void should_SetDefaultCustomIntegerInTaskanaTask_When_CamundaTaskHasDefaultCusto
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep(this.adapterTaskPollingInterval);
-
assertThat(camundaTaskIds).hasSize(3);
- // complete first 3 parallel tasks, one of which starts another task after completion that will
- // be checked for the process variables
camundaTaskIds.forEach(
- camundaTaskId -> this.camundaProcessengineRequester.completeTaskWithId(camundaTaskId));
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+
+ // complete first 3 parallel tasks, one of which starts another task after completion that
+ // will be checked for the process variables
+ this.camundaProcessengineRequester.completeTaskWithId(camundaTaskId);
+ });
camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
assertThat(camundaTaskIds).hasSize(1);
- Thread.sleep(this.adapterTaskPollingInterval);
-
String expectedComplexProcessVariable =
- "{\"type\":\"object\","
- + "\"value\":\""
- + "{\\\"stringField\\\":\\\"\\\\fForm feed \\\\b Backspace \\\\t Tab"
- + " \\\\\\\\Backslash \\\\n newLine \\\\r Carriage return \\\\\\\" DoubleQuote\\\","
- + "\\\"intField\\\":1,\\\"doubleField\\\":1.1,\\\"booleanField\\\":false,"
- + "\\\"processVariableTestObjectTwoField\\\":["
- + "{\\\"stringFieldObjectTwo\\\":\\\"stringValueObjectTwo\\\","
- + "\\\"intFieldObjectTwo\\\":2,\\\"doubleFieldObjectTwo\\\":2.2,"
- + "\\\"booleanFieldObjectTwo\\\":true,"
- + "\\\"dateFieldObjectTwo\\\":\\\"1970-01-01 13:12:11\\\"}]}\","
- + "\"valueInfo\":{\"objectTypeName\":\"pro.taskana.impl.ProcessVariableTestObject\","
- + "\"serializationDataFormat\":\"application/json\"}}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute1.json");
String expectedPrimitiveProcessVariable1 =
- "{\"type\":\"integer\",\"value\":5," + "\"valueInfo\":null}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute2.json");
String expectedPrimitiveProcessVariable2 =
- "{\"type\":\"boolean\",\"value\":true," + "\"valueInfo\":null}";
+ getResourcesAsString(this.getClass(), "process-variable-camunda-attribute3.json");
+
camundaTaskIds.forEach(
camundaTaskId -> {
Map customAttributes =
@@ -478,8 +472,7 @@ void should_SetDefaultCustomIntegerInTaskanaTask_When_CamundaTaskHasDefaultCusto
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_CreateMultipleTaskanaTasks_When_StartProcessInstanceWithMultipleExecutionsInCamunda()
- throws Exception {
+ void should_CreateMultipleTaskanaTasks_When_StartProcessInstanceWithMultipleExecutionsInCamunda() {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -488,23 +481,24 @@ void should_CreateMultipleTaskanaTasks_When_StartProcessInstanceWithMultipleExec
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
- for (String camundaTaskId : camundaTaskIds) {
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- }
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+ });
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_CreateTaskanaTask_When_SystemConnectorHasCorrectSystemEngineIdentifier()
- throws Exception {
+ void should_CreateTaskanaTask_When_SystemConnectorHasCorrectSystemEngineIdentifier() {
final Map originalSystemConnectors =
new HashMap<>(adapterManager.getSystemConnectors());
@@ -517,18 +511,17 @@ void should_CreateTaskanaTask_When_SystemConnectorHasCorrectSystemEngineIdentifi
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTasks.get(0);
- String taskanaTaskExternalId = taskanaTaskSummary.getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String businessProcessId = taskanaTaskSummary.getBusinessProcessId();
- assertThat(processInstanceId).isEqualTo(businessProcessId);
- }
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTask = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTask.getExternalId());
+ assertThat(processInstanceId).isEqualTo(taskanaTask.getBusinessProcessId());
+ });
adapterManager.getSystemConnectors().clear();
adapterManager.getSystemConnectors().putAll(originalSystemConnectors);
@@ -543,12 +536,10 @@ void should_CreateTaskanaTasksWithCorrectDomains_When_StartProcessWithDomainsInP
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process_with_different_domains",
- "\"variables\": "
- + "{\"taskana.domain\": {\"value\":\"DOMAIN_B\", \"type\":\"string\"}}");
+ getResourcesAsString(this.getClass(), "variables-taskana-domain.txt"));
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
List> variablesToTaskList =
Arrays.asList(
@@ -557,25 +548,25 @@ void should_CreateTaskanaTasksWithCorrectDomains_When_StartProcessWithDomainsInP
Pair.of("DOMAIN_B", camundaTaskIds.get(2)));
for (Pair variablesToTask : variablesToTaskList) {
- List taskanaTaskSummaryList =
- this.taskService.createTaskQuery().externalIdIn(variablesToTask.getRight()).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTaskSummaryList.get(0);
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(variablesToTask.getRight()).list()
+ );
Task taskanaTask = taskService.getTask(taskanaTaskSummary.getId());
assertThat(taskanaTask.getDomain()).isEqualTo(variablesToTask.getLeft());
}
this.camundaProcessengineRequester.completeTaskWithId(camundaTaskIds.get(2));
- camundaTaskIds =
+ List camundaTaskIds2 =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ assertThat(camundaTaskIds2).hasSize(3);
+
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskIds2.get(2)).list()
+ );
- List taskanaTaskSummaryList =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(2)).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTaskSummaryList.get(0);
Task taskanaTask = taskService.getTask(taskanaTaskSummary.getId());
assertThat(taskanaTask.getDomain()).isEqualTo("DOMAIN_B");
}
@@ -584,9 +575,8 @@ void should_CreateTaskanaTasksWithCorrectDomains_When_StartProcessWithDomainsInP
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void
- should_CreateTaskanaTasksWithCorrectDomains_When_StartProcessWithDomainsInExtensionProperties()
- throws Exception {
+ void should_CreateTaskanaTasksWithCorrectDomains_When_StartProcessWithDomainsInExtensionProperties()
+ throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -594,7 +584,6 @@ void should_CreateTaskanaTasksWithCorrectDomains_When_StartProcessWithDomainsInP
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
List> variablesToTaskList =
Arrays.asList(
@@ -603,25 +592,24 @@ void should_CreateTaskanaTasksWithCorrectDomains_When_StartProcessWithDomainsInP
Pair.of("DOMAIN_B", camundaTaskIds.get(2)));
for (Pair variablesToTask : variablesToTaskList) {
- List taskanaTaskSummaryList =
- this.taskService.createTaskQuery().externalIdIn(variablesToTask.getRight()).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTaskSummaryList.get(0);
-
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(variablesToTask.getRight()).list()
+ );
Task taskanaTask = taskService.getTask(taskanaTaskSummary.getId());
assertThat(taskanaTask.getDomain()).isEqualTo(variablesToTask.getLeft());
}
this.camundaProcessengineRequester.completeTaskWithId(camundaTaskIds.get(2));
- camundaTaskIds =
+ List camundaTaskIds2 =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ assertThat(camundaTaskIds2).hasSize(3);
+
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskIds2.get(2)).list()
+ );
- List taskanaTaskSummaryList =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(2)).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTaskSummaryList.get(0);
Task taskanaTask = taskService.getTask(taskanaTaskSummary.getId());
assertThat(taskanaTask.getDomain()).isEqualTo("DOMAIN_A");
}
@@ -630,8 +618,7 @@ void should_CreateTaskanaTasksWithCorrectDomains_When_StartProcessWithDomainsInP
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_NotCreateTaskanaTask_When_SystemConnectorHasIncorrectSystemEngineIdentifier()
- throws Exception {
+ void should_NotCreateTaskanaTask_When_SystemConnectorHasIncorrectSystemEngineIdentifier() {
final Map originalSystemConnectors =
new HashMap<>(adapterManager.getSystemConnectors());
@@ -648,13 +635,16 @@ void should_NotCreateTaskanaTask_When_SystemConnectorHasIncorrectSystemEngineIde
assertThat(taskanaOutboxRequester.getAllEvents()).hasSize(1);
- Thread.sleep((this.adapterTaskPollingInterval * 2));
-
- for (String camundaTaskId : camundaTaskIds) {
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).isEmpty();
- }
+ camundaTaskIds.forEach(
+ camundaTaskId -> {
+ await()
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .pollDelay(getDuration(adapterTaskPollingInterval))
+ .until(
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list(),
+ hasSize(0));
+ });
assertThat(taskanaOutboxRequester.getAllEvents()).hasSize(1);
@@ -666,9 +656,8 @@ void should_NotCreateTaskanaTask_When_SystemConnectorHasIncorrectSystemEngineIde
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void
- should_CreateTaskanaTasksWithVariablesInCustomAttributes_When_StartProcessWithTheseDifferentVariablesInCamunda()
- throws Exception {
+ void should_CreateTaskanaTasksWithVariablesInCustomAttributes_When_StartProcessWithTheseDifferentVariablesInCamunda()
+ throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
@@ -676,7 +665,6 @@ void should_NotCreateTaskanaTask_When_SystemConnectorHasIncorrectSystemEngineIde
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
List, String>> variablesToTaskList =
Arrays.asList(
@@ -688,10 +676,11 @@ void should_NotCreateTaskanaTask_When_SystemConnectorHasIncorrectSystemEngineIde
camundaTaskIds.get(2)));
for (Pair, String> variablesToTask : variablesToTaskList) {
- List taskanaTaskSummaryList =
- this.taskService.createTaskQuery().externalIdIn(variablesToTask.getRight()).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTaskSummaryList.get(0);
+
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(variablesToTask.getRight()).list()
+ );
Task taskanaTask = taskService.getTask(taskanaTaskSummary.getId());
assertThat(taskanaTask.getCustomAttributeMap().keySet())
@@ -699,15 +688,15 @@ void should_NotCreateTaskanaTask_When_SystemConnectorHasIncorrectSystemEngineIde
}
this.camundaProcessengineRequester.completeTaskWithId(camundaTaskIds.get(2));
- camundaTaskIds =
+ List camundaTaskIds2 =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
assertThat(camundaTaskIds).hasSize(3);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
- List taskanaTaskSummaryList =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskIds.get(2)).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTaskSummaryList.get(0);
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskIds2.get(2)).list()
+ );
+
Task taskanaTask = taskService.getTask(taskanaTaskSummary.getId());
assertThat(taskanaTask.getCustomAttributeMap().keySet())
.containsExactlyInAnyOrderElementsOf(
@@ -725,38 +714,34 @@ void should_SetPlannedDateInTaskanaTask_When_StartCamundaTaskWithFollowUpDate()
"simple_user_task_process_with_plannedDate", "");
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
// Make sure we only have one Camunda Task, so we don't need a for-loop
assertThat(camundaTaskIds).hasSize(1);
String camundaTaskId = camundaTaskIds.get(0);
+
// retrieve and check taskanaTaskId
- List taskanaTaskSummaryList =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- String taskanaTaskExternalId = taskanaTaskSummaryList.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String taskanaTaskId = taskanaTaskSummaryList.get(0).getId();
- Task taskanaTask = this.taskService.getTask(taskanaTaskId);
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+ assertThat(taskanaTaskSummary.getExternalId()).isEqualTo(camundaTaskId);
+ Task taskanaTask = taskService.getTask(taskanaTaskSummary.getId());
+
// Check if followUp Date from Camunda task is equal to plannedDate from Taskana task
Instant expectedDate = DateTimeUtil.parseDateTime("2015-06-26T09:54:00").toDate().toInstant();
assertThat(taskanaTask.getPlanned()).isEqualTo(expectedDate);
this.camundaProcessengineRequester.completeTaskWithId(camundaTaskId);
- camundaTaskIds =
+ List camundaTaskIds2 =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
// Make sure we only have one Camunda Task, so we don't need a for-loop
- assertThat(camundaTaskIds).hasSize(1);
- camundaTaskId = camundaTaskIds.get(0);
- taskanaTaskSummaryList = this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- taskanaTaskExternalId = taskanaTaskSummaryList.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- taskanaTaskId = taskanaTaskSummaryList.get(0).getId();
- taskanaTask = this.taskService.getTask(taskanaTaskId);
+ assertThat(camundaTaskIds2).hasSize(1);
+ String camundaTaskId2 = camundaTaskIds2.get(0);
+ TaskSummary taskanaTaskSummary2 = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId2).list()
+ );
+ assertThat(taskanaTaskSummary2.getExternalId()).isEqualTo(camundaTaskId2);
+ taskanaTask = this.taskService.getTask(taskanaTaskSummary2.getId());
// Check if plannedDate was set to Instant.now during setTimestampsInTaskanaTask() method call.
// This is the desired behaviour since no followUpDate is set in this Camunda Task.
assertThat(taskanaTask.getPlanned()).isAfter(now);
@@ -771,13 +756,14 @@ Stream should_CreateTaskanaTask_When_StartCamundaTaskWithManualPrio
Stream.of(
Pair.of(
"manual priority is empty",
- "\"variables\": {\"taskana.manual-priority\": {\"value\":\"\", "
- + "\"type\":\"string\"}}"),
+ getResourcesAsString(this.getClass(), "variables-manual-priority-is-empty.txt")),
Pair.of(
"manual priority is null",
- "\"variables\": {\"taskana.manual-priority\": {\"value\":\"null\", "
- + "\"type\":\"string\"}}"),
- Pair.of("manual priority does not exist", "\"variables\": {}"));
+ getResourcesAsString(this.getClass(), "variables-manual-priority-is-null.txt")),
+ Pair.of(
+ "manual priority does not exist",
+ getResourcesAsString(
+ this.getClass(), "variables-manual-priority-does-not-exists.txt")));
ThrowingConsumer> test =
p -> {
@@ -788,19 +774,17 @@ Stream should_CreateTaskanaTask_When_StartCamundaTaskWithManualPrio
List camundaTaskIds =
this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
- Thread.sleep((long) (this.adapterCompletionPollingInterval * 1.2));
-
// Make sure we only have one Camunda Task, so we don't need a for-loop
assertThat(camundaTaskIds).hasSize(1);
String camundaTaskId = camundaTaskIds.get(0);
+
// retrieve and check taskanaTaskId
- List taskanaTaskSummaryList =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTaskSummaryList).hasSize(1);
- String taskanaTaskExternalId = taskanaTaskSummaryList.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String taskanaTaskId = taskanaTaskSummaryList.get(0).getId();
- Task taskanaTask = this.taskService.getTask(taskanaTaskId);
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+ assertThat(taskanaTaskSummary.getExternalId()).isEqualTo(camundaTaskId);
+ Task taskanaTask = taskService.getTask(taskanaTaskSummary.getId());
assertThat(taskanaTask.getManualPriority()).isEqualTo(-1);
};
@@ -828,12 +812,13 @@ private Map retrieveCustomAttributesFromNewTaskanaTask(String ca
Map customAttributes = new HashMap<>();
try {
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- TaskSummary taskanaTaskSummary = taskanaTasks.get(0);
- String taskanaTaskExternalId = taskanaTaskSummary.getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary = getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list()
+ );
+
+ assertThat(taskanaTaskSummary.getExternalId()).isEqualTo(camundaTaskId);
// get the actual task instead of summary to access custom attributes
Task taskanaTask = this.taskService.getTask(taskanaTaskSummary.getId());
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskClaim.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskClaim.java
index 78897d69..4fc3aca1 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskClaim.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskClaim.java
@@ -1,15 +1,14 @@
package pro.taskana.adapter.integration;
import static org.assertj.core.api.Assertions.assertThat;
+import static pro.taskana.utils.AwaitilityUtils.getTaskSummary;
+import static pro.taskana.utils.AwaitilityUtils.verifyAssigneeForCamundaTask;
+import static pro.taskana.utils.AwaitilityUtils.verifyLogMessage;
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.read.ListAppender;
-import java.util.List;
+import io.github.logrecorder.api.LogRecord;
+import io.github.logrecorder.junit5.RecordLoggers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.LoggerFactory;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
@@ -18,7 +17,6 @@
import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.TaskState;
-import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary;
/**
@@ -41,42 +39,34 @@ void should_ClaimUnclaimedCamundaTask_When_ClaimTaskanaTask() throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
-
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String taskanaTaskId = taskanaTasks.get(0).getId();
-
- // verify that no assignee for camunda task is set yet
- boolean noAssigneeSet =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null);
- assertThat(noAssigneeSet).isTrue();
-
- // verify that TaskState of taskana task is 'READY' first
- Task task = this.taskService.getTask(taskanaTaskId);
- assertThat(task.getState()).isEqualTo(TaskState.READY);
-
- // claim task in taskana and verify updated TaskState to be 'CLAIMED'
- this.taskService.claim(taskanaTaskId);
- Task updatedTask = this.taskService.getTask(taskanaTaskId);
- assertThat(updatedTask.getState()).isEqualTo(TaskState.CLAIMED);
-
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.2));
-
- // verify updated assignee for camunda task
- boolean assigneeSetSuccessfully =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1");
- assertThat(assigneeSetSuccessfully).isTrue();
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+ // verify that no assignee for camunda task is set yet
+ assertThat(this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null)).isTrue();
+
+ String taskanaTaskId = taskanaTaskSummary.getId();
+
+ // verify that TaskState of taskana task is 'READY' first
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
+
+ // claim task in taskana and verify updated TaskState to be 'CLAIMED'
+ this.taskService.claim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.CLAIMED);
+
+ // verify updated assignee for camunda task
+ verifyAssigneeForCamundaTask(
+ adapterClaimPollingInterval,
+ () -> this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1"));
}
@WithAccessId(
@@ -88,42 +78,34 @@ void should_ClaimAlreadyClaimedCamundaTaska_When_ClaimTaskanaTask() throws Excep
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process_with_assignee_set", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
-
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String taskanaTaskId = taskanaTasks.get(0).getId();
-
- // verify that an assignee for camunda task is already set
- boolean noAssigneeSet =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null);
- assertThat(noAssigneeSet).isFalse();
-
- // verify that TaskState of taskana task is 'READY' first
- Task task = this.taskService.getTask(taskanaTaskId);
- assertThat(task.getState()).isEqualTo(TaskState.READY);
-
- // claim task in taskana and verify updated TaskState to be 'CLAIMED'
- this.taskService.claim(taskanaTaskId);
- Task updatedTask = this.taskService.getTask(taskanaTaskId);
- assertThat(updatedTask.getState()).isEqualTo(TaskState.CLAIMED);
-
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.2));
-
- // verify updated assignee for camunda task
- boolean assigneeSetSuccessfully =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1");
- assertThat(assigneeSetSuccessfully).isTrue();
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ // verify that an assignee for camunda task is already set
+ assertThat(this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null)).isFalse();
+
+ String taskanaTaskId = taskanaTaskSummary.getId();
+
+ // verify that TaskState of taskana task is 'READY' first
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
+
+ // claim task in taskana and verify updated TaskState to be 'CLAIMED'
+ this.taskService.claim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.CLAIMED);
+
+ // verify updated assignee for camunda task
+ verifyAssigneeForCamundaTask(
+ adapterClaimPollingInterval,
+ () -> this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1"));
}
@WithAccessId(
@@ -135,49 +117,40 @@ void should_CancelClaimCamundaTask_When_CancelClaimTaskanaTask() throws Exceptio
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
- for (String camundaTaskId : camundaTaskIds) {
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String taskanaTaskId = taskanaTasks.get(0).getId();
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
- // verify that TaskState of taskana task is 'READY' first
- Task task = this.taskService.getTask(taskanaTaskId);
- assertThat(task.getState()).isEqualTo(TaskState.READY);
+ String taskanaTaskId = taskanaTaskSummary.getId();
- // claim task in taskana and verify updated TaskState to be 'CLAIMED'
- this.taskService.claim(taskanaTaskId);
- Task updatedTask = this.taskService.getTask(taskanaTaskId);
- assertThat(updatedTask.getState()).isEqualTo(TaskState.CLAIMED);
+ // verify that TaskState of taskana task is 'READY' first
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.2));
+ // claim task in taskana and verify updated TaskState to be 'CLAIMED'
+ this.taskService.claim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.CLAIMED);
- // verify updated assignee for camunda task
- boolean assigneeSetSuccessfully =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1");
- assertThat(assigneeSetSuccessfully).isTrue();
+ // verify updated assignee for camunda task
+ verifyAssigneeForCamundaTask(
+ adapterClaimPollingInterval,
+ () -> this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1"));
- // cancel claim taskana task and verify updated TaskState to be 'READY'
- this.taskService.cancelClaim(taskanaTaskId);
- Task taskWithCancelledClaim = this.taskService.getTask(taskanaTaskId);
- assertThat(taskWithCancelledClaim.getState()).isEqualTo(TaskState.READY);
+ // cancel claim taskana task and verify updated TaskState to be 'READY'
+ this.taskService.cancelClaim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.2));
-
- // verify that the assignee for camunda task is no longer set
- boolean noAssigneeSet =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null);
- assertThat(noAssigneeSet).isTrue();
- }
+ // verify that the assignee for camunda task is no longer set
+ verifyAssigneeForCamundaTask(
+ adapterClaimPollingInterval,
+ () -> this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null));
}
@WithAccessId(
@@ -189,189 +162,151 @@ void should_ClaimCamundaTaskAgain_When_ClaimTaskanaTaskAfterCancelClaim() throws
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
- for (String camundaTaskId : camundaTaskIds) {
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
- String taskanaTaskId = taskanaTasks.get(0).getId();
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
- // verify that TaskState of taskana task is 'READY' first
- Task task = this.taskService.getTask(taskanaTaskId);
- assertThat(task.getState()).isEqualTo(TaskState.READY);
+ String taskanaTaskId = taskanaTaskSummary.getId();
- // claim task in taskana and verify updated TaskState to be 'CLAIMED'
- this.taskService.claim(taskanaTaskId);
- Task updatedTask = this.taskService.getTask(taskanaTaskId);
- assertThat(updatedTask.getState()).isEqualTo(TaskState.CLAIMED);
+ // verify that TaskState of taskana task is 'READY' first
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.2));
+ // claim task in taskana and verify updated TaskState to be 'CLAIMED'
+ this.taskService.claim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.CLAIMED);
- // verify updated assignee for camunda task
- boolean assigneeSetSuccessfully =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1");
- assertThat(assigneeSetSuccessfully).isTrue();
+ // verify updated assignee for camunda task
+ verifyAssigneeForCamundaTask(
+ adapterClaimPollingInterval,
+ () -> this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1"));
- // cancel claim taskana task and verify updated TaskState to be 'READY'
- this.taskService.cancelClaim(taskanaTaskId);
- Task taskWithCancelledClaim = this.taskService.getTask(taskanaTaskId);
- assertThat(taskWithCancelledClaim.getState()).isEqualTo(TaskState.READY);
+ // cancel claim taskana task and verify updated TaskState to be 'READY'
+ this.taskService.cancelClaim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.2));
+ // verify that the assignee for camunda task is no longer set
+ verifyAssigneeForCamundaTask(
+ adapterClaimPollingInterval,
+ () -> this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null));
- // verify that the assignee for camunda task is no longer set
- boolean noAssigneeSet =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, null);
- assertThat(noAssigneeSet).isTrue();
+ // claim task in taskana and verify updated TaskState to be 'CLAIMED' again
+ this.taskService.claim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.CLAIMED);
- // claim task in taskana and verify updated TaskState to be 'CLAIMED' again
- this.taskService.claim(taskanaTaskId);
- Task updatedTaskAfterAnotherClaim = this.taskService.getTask(taskanaTaskId);
- assertThat(updatedTaskAfterAnotherClaim.getState()).isEqualTo(TaskState.CLAIMED);
-
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.2));
-
- // verify updated assignee for camunda task again
- boolean assigneeSetSuccessfullyAgain =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1");
- assertThat(assigneeSetSuccessfullyAgain).isTrue();
- }
+ // verify updated assignee for camunda task again
+ verifyAssigneeForCamundaTask(
+ adapterClaimPollingInterval,
+ () -> this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1"));
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_ReventLoopFromScheduledMethod_When_TryingToClaimNotAnymoreExistingCamundaTask()
- throws Exception {
-
- Logger camundaUtilRequesterLogger =
- (Logger) LoggerFactory.getLogger(CamundaUtilRequester.class);
-
- camundaUtilRequesterLogger.setLevel(Level.DEBUG);
- ListAppender listAppender = new ListAppender<>();
- listAppender.start();
- camundaUtilRequesterLogger.addAppender(listAppender);
+ @RecordLoggers(CamundaUtilRequester.class)
+ void should_ReventLoopFromScheduledMethod_When_TryingToClaimNotAnymoreExistingCamundaTask(
+ LogRecord log
+ ) throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
-
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
-
- // delete camunda process without notifying the listeners
- boolean camundaProcessCancellationSucessful =
- this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, true);
- assertThat(camundaProcessCancellationSucessful).isTrue();
-
- // claim task in taskana and verify updated TaskState to be 'CLAIMED'
- String taskanaTaskId = taskanaTasks.get(0).getId();
- this.taskService.claim(taskanaTaskId);
- TaskState updatedTaskState = this.taskService.getTask(taskanaTaskId).getState();
- assertThat(updatedTaskState).isEqualTo(TaskState.CLAIMED);
-
- // wait for the adapter to claim the not anymore existing camunda task
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- List logsList = listAppender.list;
-
- // verify that the CamundaUtilRequester log contains 1 entry for
- // the failed try to claim the not existing camunda task
- assertThat(logsList).hasSize(1);
-
- String camundaUtilRequesterLogMessage = logsList.get(0).getFormattedMessage();
-
- assertThat(camundaUtilRequesterLogMessage)
- .isEqualTo("Camunda Task " + camundaTaskId + " is not existing. Returning silently");
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ String taskanaTaskId = taskanaTaskSummary.getId();
+
+ // verify that TaskState of taskana task is 'READY' first
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
+
+ // delete camunda process without notifying the listeners
+ boolean camundaProcessCancellationSucessful =
+ this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, true);
+ assertThat(camundaProcessCancellationSucessful).isTrue();
+
+ // claim task in taskana and verify updated TaskState to be 'CLAIMED'
+ this.taskService.claim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.CLAIMED);
+
+ // wait for the adapter to claim the not anymore existing camunda task
+ // verify that the CamundaUtilRequester log contains 1 entry for
+ // the failed try to claim the not existing camunda task
+ verifyLogMessage(
+ adapterTaskPollingInterval,
+ log,
+ "Camunda Task " + camundaTaskId + " is not existing. Returning silently"
+ );
}
@WithAccessId(
user = "teamlead_1",
groups = {"taskadmin"})
@Test
- void should_PreventLoopFromScheduledMethod_When_TryingToCancelClaimNotAnymoreExistingCamundaTask()
- throws Exception {
-
- Logger camundaUtilRequesterLogger =
- (Logger) LoggerFactory.getLogger(CamundaUtilRequester.class);
-
- camundaUtilRequesterLogger.setLevel(Level.DEBUG);
- ListAppender listAppender = new ListAppender<>();
- listAppender.start();
- camundaUtilRequesterLogger.addAppender(listAppender);
+ @RecordLoggers(CamundaUtilRequester.class)
+ void should_PreventLoopFromScheduledMethod_When_TryingToCancelClaimNotAnymoreExistingCamundaTask(
+ LogRecord log
+ ) throws Exception {
String processInstanceId =
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
-
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- for (String camundaTaskId : camundaTaskIds) {
-
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(taskanaTaskExternalId).isEqualTo(camundaTaskId);
-
- // claim task in taskana and verify updated TaskState to be 'CLAIMED'
- String taskanaTaskId = taskanaTasks.get(0).getId();
- this.taskService.claim(taskanaTaskId);
- TaskState updatedTaskState = this.taskService.getTask(taskanaTaskId).getState();
- assertThat(updatedTaskState).isEqualTo(TaskState.CLAIMED);
- Thread.sleep((long) (this.adapterClaimPollingInterval * 1.2));
-
- // verify updated assignee for camunda task
- boolean assigneeSetSuccessfully =
- this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1");
- assertThat(assigneeSetSuccessfully).isTrue();
-
- // delete camunda process without notifying the listeners
- boolean camundaProcessCancellationSucessful =
- this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, true);
- assertThat(camundaProcessCancellationSucessful).isTrue();
-
- // cancel claim taskana task and verify updated TaskState to be 'READY'
- this.taskService.cancelClaim(taskanaTaskId);
- TaskState taskWithCancelledClaimState = this.taskService.getTask(taskanaTaskId).getState();
- assertThat(taskWithCancelledClaimState).isEqualTo(TaskState.READY);
-
- // wait for the adapter to try to cancel claim the not anymore existing camunda task
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
-
- List logsList = listAppender.list;
-
- // verify that the CamundaUtilRequester log contains 1 entry for
- // the failed try to cancel claim the not existing camunda task
- assertThat(logsList).hasSize(1);
-
- String camundaUtilRequesterLogMessage = logsList.get(0).getFormattedMessage();
-
- assertThat(camundaUtilRequesterLogMessage)
- .isEqualTo("Camunda Task " + camundaTaskId + " is not existing. Returning silently");
- }
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
+
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
+
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
+
+ String taskanaTaskId = taskanaTaskSummary.getId();
+
+ // verify that TaskState of taskana task is 'READY' first
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
+
+ this.taskService.claim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.CLAIMED);
+
+ verifyAssigneeForCamundaTask(
+ adapterClaimPollingInterval,
+ () -> this.camundaProcessengineRequester.isCorrectAssignee(camundaTaskId, "teamlead_1"));
+
+ // delete camunda process without notifying the listeners
+ boolean camundaProcessCancellationSucessful =
+ this.camundaProcessengineRequester.deleteProcessInstanceWithId(processInstanceId, true);
+ assertThat(camundaProcessCancellationSucessful).isTrue();
+
+ // cancel claim taskana task and verify updated TaskState to be 'READY'
+ this.taskService.cancelClaim(taskanaTaskId);
+ assertThat(this.taskService.getTask(taskanaTaskId).getState()).isEqualTo(TaskState.READY);
+
+ // wait for the adapter to claim the not anymore existing camunda task
+ // verify that the CamundaUtilRequester log contains 1 entry for
+ // the failed try to claim the not existing camunda task
+ verifyLogMessage(
+ adapterTaskPollingInterval,
+ log,
+ "Camunda Task " + camundaTaskId + " is not existing. Returning silently"
+ );
}
}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskTermination.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskTermination.java
index 455345a3..eb95a262 100644
--- a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskTermination.java
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/adapter/integration/TestTaskTermination.java
@@ -1,8 +1,8 @@
package pro.taskana.adapter.integration;
import static org.assertj.core.api.Assertions.assertThat;
+import static pro.taskana.utils.AwaitilityUtils.getTaskSummary;
-import java.util.List;
import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -15,6 +15,7 @@
import pro.taskana.common.test.security.JaasExtension;
import pro.taskana.common.test.security.WithAccessId;
import pro.taskana.task.api.models.TaskSummary;
+import pro.taskana.utils.AwaitilityUtils;
/** Test class to test the completion of camunda tasks upon termination of taskana tasks. */
@SpringBootTest(
@@ -37,27 +38,23 @@ void should_CompleteCamundaTask_When_TerminatingTaskanaTask() throws Exception {
this.camundaProcessengineRequester.startCamundaProcessAndReturnId(
"simple_user_task_process", "");
- List camundaTaskIds =
- this.camundaProcessengineRequester.getTaskIdsFromProcessInstanceId(processInstanceId);
+ String camundaTaskId =
+ this.camundaProcessengineRequester
+ .getTaskIdsFromProcessInstanceId(processInstanceId)
+ .get(0);
- Thread.sleep((long) (this.adapterTaskPollingInterval * 1.2));
+ // retrieve and check taskanaTaskId
+ TaskSummary taskanaTaskSummary =
+ getTaskSummary(
+ adapterTaskPollingInterval,
+ () -> this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list());
- for (String camundaTaskId : camundaTaskIds) {
- // retrieve and check taskanaTaskId
- List taskanaTasks =
- this.taskService.createTaskQuery().externalIdIn(camundaTaskId).list();
- assertThat(taskanaTasks).hasSize(1);
- String taskanaTaskExternalId = taskanaTasks.get(0).getExternalId();
- assertThat(camundaTaskId).isEqualTo(taskanaTaskExternalId);
+ assertThat(camundaTaskId).isEqualTo(taskanaTaskSummary.getExternalId());
- taskService.terminateTask(taskanaTasks.get(0).getId());
+ taskService.terminateTask(taskanaTaskSummary.getId());
- Thread.sleep(1000 + (long) (this.jobExecutor.getMaxWait() * 1.2));
-
- // check if camunda task got completed and therefore doesn't exist anymore
- boolean taskRetrievalSuccessful =
- this.camundaProcessengineRequester.getTaskFromTaskId(camundaTaskId);
- assertThat(taskRetrievalSuccessful).isFalse();
- }
+ // check if camunda task got completed and therefore doesn't exist anymore
+ AwaitilityUtils.checkCamundaTaskIsCompleted(
+ jobExecutor, camundaProcessengineRequester, camundaTaskId);
}
}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/AwaitilityUtils.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/AwaitilityUtils.java
new file mode 100644
index 00000000..872fbcae
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/AwaitilityUtils.java
@@ -0,0 +1,99 @@
+package pro.taskana.utils;
+
+import static java.time.temporal.ChronoUnit.MILLIS;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Durations.ONE_HUNDRED_MILLISECONDS;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.Matchers.hasSize;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.read.ListAppender;
+import io.github.logrecorder.api.LogRecord;
+import java.time.Duration;
+import java.util.Collection;
+import java.util.concurrent.Callable;
+import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor;
+import pro.taskana.adapter.integration.CamundaProcessengineRequester;
+import pro.taskana.task.api.models.TaskSummary;
+
+public class AwaitilityUtils {
+
+ private AwaitilityUtils() {
+ // empty default constructor because all methods are static
+ }
+
+ public static Duration getDuration(long time) {
+ return Duration.of(time * 2, MILLIS);
+ }
+
+ public static TaskSummary getTaskSummary(
+ long adapterTaskPollingInterval, Callable> supplier) {
+ return await()
+ .atMost(getDuration(adapterTaskPollingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(supplier, hasSize(1))
+ .iterator()
+ .next();
+ }
+
+ public static String getCamundaTaskId(long pollingIntervall, Callable supplier) {
+ return await()
+ .atMost(getDuration(pollingIntervall))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(supplier, notNullValue());
+ }
+
+ public static boolean verifyAssigneeForCamundaTask(
+ long adapterClaimPollingInterval, Callable supplier) {
+ return await()
+ .atMost(getDuration(adapterClaimPollingInterval))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(supplier, is(true));
+ }
+
+ public static boolean verifyLogMessage(
+ long pollingIntervall, ListAppender appender, String logMessage) {
+ return await()
+ .atMost(getDuration(pollingIntervall))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () ->
+ !appender.list.stream()
+ .filter(
+ loggingEvent ->
+ loggingEvent.getFormattedMessage().contentEquals(logMessage))
+ .toList()
+ .isEmpty(),
+ is(true));
+ }
+
+ public static boolean verifyLogMessage(long pollingIntervall, LogRecord log, String logMessage) {
+ return await()
+ .atMost(getDuration(pollingIntervall))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(
+ () ->
+ !log.getMessages().stream()
+ .filter(message -> message.contentEquals(logMessage))
+ .toList()
+ .isEmpty(),
+ is(true));
+ }
+
+ public static void checkCamundaTaskIsCompleted(
+ JobExecutor jobExecutor,
+ CamundaProcessengineRequester camundaProcessengineRequester,
+ String camundaTaskId) {
+ await()
+ .atMost(getDuration(jobExecutor.getMaxWait()))
+ .with()
+ .pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .until(() -> camundaProcessengineRequester.getTaskFromTaskId(camundaTaskId), is(false));
+ }
+}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/ResourceUtils.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/ResourceUtils.java
new file mode 100644
index 00000000..d4ab450b
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/ResourceUtils.java
@@ -0,0 +1,30 @@
+package pro.taskana.utils;
+
+import static java.lang.System.lineSeparator;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.stream.Collectors.joining;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public final class ResourceUtils {
+ private ResourceUtils() {
+ // empty default constructor because all methods are static
+ }
+
+ public static String getResourcesAsString(Class clazz, String fileName) {
+ try (InputStream is = clazz.getResourceAsStream(clazz.getSimpleName() + "-" + fileName)) {
+ if (is == null) {
+ throw new RuntimeException("File not found");
+ }
+ try (InputStreamReader isr = new InputStreamReader(is, UTF_8);
+ BufferedReader reader = new BufferedReader(isr)) {
+ return reader.lines().collect(joining(lineSeparator()));
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/TaskStateMatcher.java b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/TaskStateMatcher.java
new file mode 100644
index 00000000..ec219177
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/java/pro/taskana/utils/TaskStateMatcher.java
@@ -0,0 +1,29 @@
+package pro.taskana.utils;
+
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import pro.taskana.task.api.TaskState;
+import pro.taskana.task.api.models.TaskSummary;
+
+public class TaskStateMatcher extends BaseMatcher {
+
+ private final TaskState expectedTaskState;
+
+ public TaskStateMatcher(TaskState expectedTaskState) {
+ this.expectedTaskState = expectedTaskState;
+ }
+
+ @Override
+ public boolean matches(Object currentTaskSummary) {
+ if (currentTaskSummary instanceof TaskSummary) {
+ return ((TaskSummary) currentTaskSummary).getState() == expectedTaskState;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("expecting TaskState = ").appendText(expectedTaskState.name());
+ }
+}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/junit-platform.properties b/taskana-adapter-camunda-spring-boot-test/src/test/resources/junit-platform.properties
new file mode 100644
index 00000000..b7f5acdc
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/junit-platform.properties
@@ -0,0 +1,2 @@
+junit.jupiter.testclass.order.default=org.junit.jupiter.api.ClassOrderer$OrderAnnotation
+
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-attribute3.json b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-attribute3.json
new file mode 100644
index 00000000..1c4fa1e3
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-attribute3.json
@@ -0,0 +1,7 @@
+{
+ "valueInfo": {
+ "objectTypeName": "java.lang.Integer"
+ },
+ "type": "integer",
+ "value": 5
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-camunda-attribute1.json b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-camunda-attribute1.json
new file mode 100644
index 00000000..4945a32a
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-camunda-attribute1.json
@@ -0,0 +1,8 @@
+{
+ "type": "object",
+ "value": "{\"stringField\":\"\\fForm feed \\b Backspace \\t Tab \\\\Backslash \\n newLine \\r Carriage return \\\" DoubleQuote\",\"intField\":1,\"doubleField\":1.1,\"booleanField\":false,\"processVariableTestObjectTwoField\":[{\"stringFieldObjectTwo\":\"stringValueObjectTwo\",\"intFieldObjectTwo\":2,\"doubleFieldObjectTwo\":2.2,\"booleanFieldObjectTwo\":true,\"dateFieldObjectTwo\":null}]}",
+ "valueInfo": {
+ "objectTypeName": "pro.taskana.impl.ProcessVariableTestObject",
+ "serializationDataFormat": "application/json"
+ }
+}
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-camunda-attribute2.json b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-camunda-attribute2.json
new file mode 100644
index 00000000..69273ac2
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestCompletedTaskRetrieval-process-variable-camunda-attribute2.json
@@ -0,0 +1,7 @@
+{
+ "valueInfo": {
+ "objectTypeName": "java.lang.Boolean"
+ },
+ "type": "boolean",
+ "value": true
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-amount.json b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-amount.json
new file mode 100644
index 00000000..a292c4af
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-amount.json
@@ -0,0 +1,5 @@
+{
+ "type": "long",
+ "value": 555,
+ "valueInfo": null
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute1.json b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute1.json
new file mode 100644
index 00000000..2824706c
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute1.json
@@ -0,0 +1,8 @@
+{
+ "type": "object",
+ "value": "{\"stringField\":\"\\fForm feed \\b Backspace \\t Tab \\\\Backslash \\n newLine \\r Carriage return \\\" DoubleQuote\",\"intField\":1,\"doubleField\":1.1,\"booleanField\":false,\"processVariableTestObjectTwoField\":[{\"stringFieldObjectTwo\":\"stringValueObjectTwo\",\"intFieldObjectTwo\":2,\"doubleFieldObjectTwo\":2.2,\"booleanFieldObjectTwo\":true,\"dateFieldObjectTwo\":\"1970-01-01 13:12:11\"}]}",
+ "valueInfo": {
+ "objectTypeName": "pro.taskana.impl.ProcessVariableTestObject",
+ "serializationDataFormat": "application/json"
+ }
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute2.json b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute2.json
new file mode 100644
index 00000000..7f91a70f
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute2.json
@@ -0,0 +1,5 @@
+{
+ "type": "integer",
+ "value": 5,
+ "valueInfo": null
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute3.json b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute3.json
new file mode 100644
index 00000000..d19ea1d9
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-attribute3.json
@@ -0,0 +1,5 @@
+{
+ "type": "boolean",
+ "value": true,
+ "valueInfo": null
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-item.json b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-item.json
new file mode 100644
index 00000000..d38c104f
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-process-variable-camunda-item.json
@@ -0,0 +1,5 @@
+{
+ "type": "string",
+ "value": "item-xyz",
+ "valueInfo": null
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-custom-integer.txt b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-custom-integer.txt
new file mode 100644
index 00000000..0ce83296
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-custom-integer.txt
@@ -0,0 +1,34 @@
+"variables": {
+ "taskana.custom-int-1": {
+ "value": "1",
+ "type": "string"
+ },
+ "taskana.custom-int-2": {
+ "value": "2",
+ "type": "string"
+ },
+ "taskana.custom-int-3": {
+ "value": "3",
+ "type": "string"
+ },
+ "taskana.custom-int-4": {
+ "value": "4",
+ "type": "string"
+ },
+ "taskana.custom-int-5": {
+ "value": "5",
+ "type": "string"
+ },
+ "taskana.custom-int-6": {
+ "value": "6",
+ "type": "string"
+ },
+ "taskana.custom-int-7": {
+ "value": "7",
+ "type": "string"
+ },
+ "taskana.custom-int-8": {
+ "value": "8",
+ "type": "string"
+ }
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-does-not-exists.txt b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-does-not-exists.txt
new file mode 100644
index 00000000..eccc3f3f
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-does-not-exists.txt
@@ -0,0 +1 @@
+"variables": {}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-is-empty.txt b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-is-empty.txt
new file mode 100644
index 00000000..8a3b5c3c
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-is-empty.txt
@@ -0,0 +1,6 @@
+"variables": {
+ "taskana.manual-priority": {
+ "value": "",
+ "type": "string"
+ }
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-is-null.txt b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-is-null.txt
new file mode 100644
index 00000000..1693a8a0
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-manual-priority-is-null.txt
@@ -0,0 +1,6 @@
+"variables": {
+ "taskana.manual-priority": {
+ "value": null,
+ "type": "string"
+ }
+}
\ No newline at end of file
diff --git a/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-taskana-domain.txt b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-taskana-domain.txt
new file mode 100644
index 00000000..dda7d875
--- /dev/null
+++ b/taskana-adapter-camunda-spring-boot-test/src/test/resources/pro/taskana/adapter/integration/TestTaskAcquisition-variables-taskana-domain.txt
@@ -0,0 +1,6 @@
+"variables": {
+ "taskana.domain": {
+ "value": "DOMAIN_B",
+ "type": "string"
+ }
+}
\ No newline at end of file