diff --git a/README.md b/README.md index 941c3521..cc7b2757 100644 --- a/README.md +++ b/README.md @@ -250,7 +250,7 @@ Because of this we should wait for a busy state after increasing the engine time ## Examples -For example tests the best place to look right now is the tests in the QA module. +[Examples](examples/README.md) ## Engine lifecycle diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000..654fbcf3 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,34 @@ +# Examples + +This module contains examples on how to use the assertions to test processes. + +## Example: _Pull Request Process_ + +This example demonstrates how to ... +* Annotate a unit tests +* Deploy processes to the test engine +* Control process execution +* Protect tests from flakiness caused by asynchronous processing in the engine +* Manipulate the time of the engine to trigger timer events +* Assert that deployment was successful +* Assert a certain path was taken / not taken +* Assert state of process instance variables +* Navigate from the main process to spawned child process + +**Processes** + +The example is based on the following process: +![Pull Request Created Process](assets/pr-created.png) + +[Source](src/test/resources/pr-created.bpmn) + +Which calls a subprocess _Automated tests_: + +![Automated Tests Process](assets/automated-tests.png) + +[Source](src/test/resources/automated-tests.bpmn) + +**Tests** + +[Source](src/test/java/io/camunda/zeebe/process/test/examples/PullRequestProcessTest.java) + diff --git a/examples/assets/automated-tests.png b/examples/assets/automated-tests.png new file mode 100644 index 00000000..ba00e12d Binary files /dev/null and b/examples/assets/automated-tests.png differ diff --git a/examples/assets/pr-created.png b/examples/assets/pr-created.png new file mode 100644 index 00000000..11ec5665 Binary files /dev/null and b/examples/assets/pr-created.png differ diff --git a/examples/pom.xml b/examples/pom.xml new file mode 100644 index 00000000..d7e59221 --- /dev/null +++ b/examples/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + io.camunda + zeebe-process-test-root + 8.1.0-alpha3-SNAPSHOT + + + zeebe-process-test-examples + + Zeebe Process Test Examples + + + 17 + 17 + + + + + org.junit.jupiter + junit-jupiter-api + test + + + + io.camunda + zeebe-process-test-assertions + test + + + + io.camunda + zeebe-process-test-extension + test + + + + io.camunda + zeebe-client-java + test + + + + io.camunda + zeebe-process-test-api + test + + + + org.slf4j + slf4j-simple + test + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + true + + + org.slf4j:slf4j-simple + + + + + + + diff --git a/examples/src/test/java/io/camunda/zeebe/process/test/examples/PullRequestProcessTest.java b/examples/src/test/java/io/camunda/zeebe/process/test/examples/PullRequestProcessTest.java new file mode 100644 index 00000000..33d369c3 --- /dev/null +++ b/examples/src/test/java/io/camunda/zeebe/process/test/examples/PullRequestProcessTest.java @@ -0,0 +1,326 @@ +/* + * Copyright © 2021 camunda services GmbH (info@camunda.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.camunda.zeebe.process.test.examples; + +import static java.util.Collections.singletonMap; + +import io.camunda.zeebe.client.ZeebeClient; +import io.camunda.zeebe.client.api.command.DeployResourceCommandStep1; +import io.camunda.zeebe.client.api.response.ActivatedJob; +import io.camunda.zeebe.client.api.response.DeploymentEvent; +import io.camunda.zeebe.client.api.response.PublishMessageResponse; +import io.camunda.zeebe.process.test.api.ZeebeTestEngine; +import io.camunda.zeebe.process.test.assertions.BpmnAssert; +import io.camunda.zeebe.process.test.extension.ZeebeProcessTest; +import java.time.Duration; +import java.util.Map; +import java.util.concurrent.TimeoutException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@ZeebeProcessTest +/* + * This annotation {@code import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;} + * is recommended for Java 17+. It uses an embedded engine and is the fastest way + * to run the tests. + * + * For Java 8+ use {@code import io.camunda.zeebe.process.test.extension.testcontainer.ZeebeProcessTest;) + * It will start the embedded engine in a Docker container. + * + * Both implementations are interchangeable + */ +public class PullRequestProcessTest { + + private static final String PULL_REQUEST_PROCESS_RESOURCE_NAME = "pr-created.bpmn"; + private static final String AUTOMATED_TESTS_PROCESS_RESOURCE_NAME = "automated-tests.bpmn"; + private static final String AUTOMATED_TESTS_PROCESS_ID = "automatedTestsProcess"; + private static final String AUTOMATED_TESTS_RUN_TESTS = "runTests"; + private static final String PR_CREATED_MSG = "prCreated"; + private static final String REVIEW_RECEIVED_MSG = "reviewReceived"; + private static final String PR_ID_VAR = "prId"; + private static final String REVIEW_RESULT_VAR = "reviewResult"; + private static final String REQUEST_REVIEW = "requestReview"; + private static final String REMIND_REVIEWER = "remindReviewer"; + private static final String MAKE_CHANGES = "makeChanges"; + private static final String MERGE_CODE = "mergeCode"; + private static final String DEPLOY_SNAPSHOT = "deploySnapshot"; + + // injected by ZeebeProcessTest annotation + private ZeebeTestEngine engine; + // injected by ZeebeProcessTest annotation + private ZeebeClient client; + + @BeforeEach + void deployProcesses() { + // The embedded engine is completely reset before each test run. + + // Therefore, we need to deploy the process each time + final DeploymentEvent deploymentEvent = + deployResources(PULL_REQUEST_PROCESS_RESOURCE_NAME, AUTOMATED_TESTS_PROCESS_RESOURCE_NAME); + + BpmnAssert.assertThat(deploymentEvent) + .containsProcessesByResourceName( + PULL_REQUEST_PROCESS_RESOURCE_NAME, AUTOMATED_TESTS_PROCESS_RESOURCE_NAME); + } + + @Test + void testPullRequestCreatedHappyPath() throws InterruptedException, TimeoutException { + // Given + final String pullRequestId = "123"; + + // When + + // -> send message to create process instance + final PublishMessageResponse publishMessageResponse = + sendMessage(PR_CREATED_MSG, "", singletonMap(PR_ID_VAR, pullRequestId)); + + // -> complete user task + completeUserTask(REQUEST_REVIEW); + + // -> send another message to drive the process forward + sendMessage(REVIEW_RECEIVED_MSG, pullRequestId, singletonMap(REVIEW_RESULT_VAR, "approved")); + + /* -> on a parallel branch of the process, a sub process is called, which spawns three service + * tasks as part of a multi instance embedded sub process. These lines complete the called + * service tasks + */ + completeServiceTasks(AUTOMATED_TESTS_RUN_TESTS, 3); + + // -> back on the main process, there are two more tasks to complete to reach the end + completeUserTask(MERGE_CODE); + completeServiceTask(DEPLOY_SNAPSHOT); + + // Then + BpmnAssert.assertThat(publishMessageResponse) + .hasCreatedProcessInstance() + .extractingProcessInstance() + .hasPassedElementsInOrder(REQUEST_REVIEW, MERGE_CODE, DEPLOY_SNAPSHOT) + .hasNotPassedElement(REMIND_REVIEWER) + .hasNotPassedElement(MAKE_CHANGES) + .hasVariableWithValue(REVIEW_RESULT_VAR, "approved") + .extractingLatestCalledProcess(AUTOMATED_TESTS_PROCESS_ID) + .hasPassedElement(AUTOMATED_TESTS_RUN_TESTS, 3) + .isCompleted(); + } + + @Test + void testRemindReviewer() throws InterruptedException, TimeoutException { + // Given + final String prId = "123"; + + // When + final PublishMessageResponse publishMessageResponse = + sendMessage(PR_CREATED_MSG, "", singletonMap(PR_ID_VAR, prId)); + completeUserTask(REQUEST_REVIEW); + + completeServiceTasks(AUTOMATED_TESTS_RUN_TESTS, 3); + + // This is how you can manipulate the time of the engine to trigger timer events + increaseTime(Duration.ofDays(1)); + + completeServiceTask(REMIND_REVIEWER); + + sendMessage(REVIEW_RECEIVED_MSG, prId, singletonMap(REVIEW_RESULT_VAR, "approved")); + + completeUserTask(MERGE_CODE); + completeServiceTask(DEPLOY_SNAPSHOT); + + // Then + BpmnAssert.assertThat(publishMessageResponse) + .hasCreatedProcessInstance() + .extractingProcessInstance() + .hasPassedElementsInOrder(REQUEST_REVIEW, REMIND_REVIEWER, MERGE_CODE, DEPLOY_SNAPSHOT) + .hasNotPassedElement(MAKE_CHANGES) + .isCompleted(); + } + + @Test + void testRejectReview() throws InterruptedException, TimeoutException { + // Given + final String prId = "123"; + + // When + final PublishMessageResponse publishMessageResponse = + sendMessage(PR_CREATED_MSG, "", singletonMap(PR_ID_VAR, prId)); + + completeUserTask(REQUEST_REVIEW); + + completeServiceTasks(AUTOMATED_TESTS_RUN_TESTS, 3); + + sendMessage(REVIEW_RECEIVED_MSG, prId, singletonMap(REVIEW_RESULT_VAR, "rejected")); + + completeUserTask(MAKE_CHANGES); + + completeUserTask(REQUEST_REVIEW); + + sendMessage(REVIEW_RECEIVED_MSG, prId, singletonMap(REVIEW_RESULT_VAR, "approved")); + + completeUserTask(MERGE_CODE); + completeServiceTask(DEPLOY_SNAPSHOT); + + // Then + BpmnAssert.assertThat(publishMessageResponse) + .hasCreatedProcessInstance() + .extractingProcessInstance() + .hasPassedElementsInOrder( + REQUEST_REVIEW, MAKE_CHANGES, REQUEST_REVIEW, MERGE_CODE, DEPLOY_SNAPSHOT) + .hasNotPassedElement(REMIND_REVIEWER) + .isCompleted(); + } + + private DeploymentEvent deployResources(final String... resources) { + final DeployResourceCommandStep1 commandStep1 = client.newDeployResourceCommand(); + + DeployResourceCommandStep1.DeployResourceCommandStep2 commandStep2 = null; + for (final String process : resources) { + if (commandStep2 == null) { + commandStep2 = commandStep1.addResourceFromClasspath(process); + } else { + commandStep2 = commandStep2.addResourceFromClasspath(process); + } + } + + return commandStep2.send().join(); + } + + /* These two methods deal with the asynchronous nature of the engine. It is recommended + * to wait for an idle state before you assert on the state of the engine. Otherwise, you + * may run into race conditions and flaky tests, depending on whether the engine + * is still busy processing your last commands. + * + * Also note that many of the helper functions used in this test (e.g. {@code sendMessage(..)} + * have a call to this method at the end. This is to ensure that each command sent to the engine + * is fully processed before moving on. Without that you can run into issues, where e.g. you want + * to complete a task, but the task has not been activated yet. + * + * Note that the duration is not like a {@code Thread.sleep()}. The tests will continue as soon as + * an idle state is reached. Only if no idle state is reached during the {@code duration} + * passed in as argument, then a timeout exception will be thrown. + */ + private void waitForIdleState(final Duration duration) + throws InterruptedException, TimeoutException { + engine.waitForIdleState(duration); + } + + private void waitForBusyState(final Duration duration) + throws InterruptedException, TimeoutException { + engine.waitForBusyState(duration); + } + + private PublishMessageResponse sendMessage( + final String messageName, final String correlationKey, final Map variables) + throws InterruptedException, TimeoutException { + final PublishMessageResponse response = + client + .newPublishMessageCommand() + .messageName(messageName) + .correlationKey(correlationKey) + .variables(variables) + .send() + .join(); + waitForIdleState(Duration.ofSeconds(1)); + return response; + } + + private void increaseTime(final Duration duration) throws InterruptedException, TimeoutException { + // this method increases the time in a deterministic manner + + /* Process all existing commands to make sure that timer subscriptions related to the process + * so far have been created + */ + waitForIdleState(Duration.ofSeconds(1)); + + /* Increase time in the engine. This will not take immediate effect, though. There is a + * real-time delay of a couple of ms until the updated time is picked up by the scheduler + */ + engine.increaseTime(duration); + + try { + /* This code assumes that the increase of time will trigger timer events. Therefore, we wait + * until the engine is busy. This means that it started triggering events. + * + * And after that, we wait for it to become idle again. That means it is waiting for new commands + */ + waitForBusyState(Duration.ofSeconds(1)); + waitForIdleState(Duration.ofSeconds(1)); + } catch (final TimeoutException e) { + // Do nothing. We've waited up to 1 second for processing to start, if it didn't start in this + // time the engine probably has not got anything left to process. + } + } + + private void completeServiceTask(final String jobType) + throws InterruptedException, TimeoutException { + completeServiceTasks(jobType, 1); + } + + private void completeServiceTasks(final String jobType, final int count) + throws InterruptedException, TimeoutException { + + final var activateJobsResponse = + client.newActivateJobsCommand().jobType(jobType).maxJobsToActivate(count).send().join(); + + final int activatedJobCount = activateJobsResponse.getJobs().size(); + if (activatedJobCount < count) { + Assertions.fail( + "Unable to activate %d jobs, because only %d were activated." + .formatted(count, activatedJobCount)); + } + + for (int i = 0; i < count; i++) { + final var job = activateJobsResponse.getJobs().get(i); + + client.newCompleteCommand(job.getKey()).send().join(); + } + + waitForIdleState(Duration.ofSeconds(1)); + } + + private void completeUserTask(final String elementId) + throws InterruptedException, TimeoutException { + // user tasks can be controlled similarly to service tasks + // all user tasks share a common job type + final var activateJobsResponse = + client + .newActivateJobsCommand() + .jobType("io.camunda.zeebe:userTask") + .maxJobsToActivate(100) + .send() + .join(); + + boolean userTaskWasCompleted = false; + + for (final ActivatedJob userTask : activateJobsResponse.getJobs()) { + if (userTask.getElementId().equals(elementId)) { + // complete the user task we care about + client.newCompleteCommand(userTask).send().join(); + userTaskWasCompleted = true; + } else { + // fail all other user tasks that were activated + // failing a task with a retry value >0 means the task can be reactivated in the future + client.newFailCommand(userTask).retries(Math.max(userTask.getRetries(), 1)).send().join(); + } + } + + waitForIdleState(Duration.ofSeconds(1)); + + if (!userTaskWasCompleted) { + Assertions.fail("Tried to complete task `%s`, but it was not found".formatted(elementId)); + } + } +} diff --git a/qa/abstracts/src/main/resources/automated-tests.bpmn b/examples/src/test/resources/automated-tests.bpmn similarity index 100% rename from qa/abstracts/src/main/resources/automated-tests.bpmn rename to examples/src/test/resources/automated-tests.bpmn diff --git a/qa/abstracts/src/main/resources/pr-created.bpmn b/examples/src/test/resources/pr-created.bpmn similarity index 100% rename from qa/abstracts/src/main/resources/pr-created.bpmn rename to examples/src/test/resources/pr-created.bpmn diff --git a/pom.xml b/pom.xml index 647adbd6..8fce5951 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ extension-testcontainer filters qa + examples diff --git a/qa/abstracts/src/main/java/io/camunda/zeebe/process/test/qa/abstracts/examples/AbstractPrCreatedTest.java b/qa/abstracts/src/main/java/io/camunda/zeebe/process/test/qa/abstracts/examples/AbstractPrCreatedTest.java deleted file mode 100644 index 8d2bfc5a..00000000 --- a/qa/abstracts/src/main/java/io/camunda/zeebe/process/test/qa/abstracts/examples/AbstractPrCreatedTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright © 2021 camunda services GmbH (info@camunda.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.camunda.zeebe.process.test.qa.abstracts.examples; - -import static io.camunda.zeebe.process.test.assertions.BpmnAssert.assertThat; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.AUTOMATED_TESTS_PROCESS_ID; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.AUTOMATED_TESTS_RESOURCE_NAME; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.AUTOMATED_TESTS_RUN_TESTS; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.DEPLOY_SNAPSHOT; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.MAKE_CHANGES; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.MERGE_CODE; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.PR_CREATED_MSG; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.PR_ID_VAR; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.REMIND_REVIEWER; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.REQUEST_REVIEW; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.RESOURCE_NAME; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.REVIEW_RECEIVED_MSG; -import static io.camunda.zeebe.process.test.qa.abstracts.util.Utilities.ProcessPackPRCreated.REVIEW_RESULT_VAR; - -import io.camunda.zeebe.client.ZeebeClient; -import io.camunda.zeebe.client.api.response.DeploymentEvent; -import io.camunda.zeebe.client.api.response.PublishMessageResponse; -import io.camunda.zeebe.process.test.api.ZeebeTestEngine; -import io.camunda.zeebe.process.test.qa.abstracts.util.Utilities; -import java.time.Duration; -import java.util.Collections; -import java.util.concurrent.TimeoutException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -/** - * This is an abstract test class so we can test these tests with both our extensions (embedded and - * testcontainer) without the need to duplicate our test code. - * - *

Users would not do this. They would create a regular test class and annotate this with the - * preferred annotation to include the extension they need. - */ -public abstract class AbstractPrCreatedTest { - - private ZeebeTestEngine engine; - private ZeebeClient client; - - @BeforeEach - void deployProcesses() { - // Normally these fields get injected by our annotation. Since we want to reuse these tests we - // need to use these abstract methods to obtain them, as they get injected in the extending test - // classes. Users would not need to do this. - engine = getEngine(); - client = getClient(); - - final DeploymentEvent deploymentEvent = - Utilities.deployResources(client, RESOURCE_NAME, AUTOMATED_TESTS_RESOURCE_NAME); - assertThat(deploymentEvent) - .containsProcessesByResourceName(RESOURCE_NAME, AUTOMATED_TESTS_RESOURCE_NAME); - } - - @Test - void testPRCreateddHappyPath() throws InterruptedException, TimeoutException { - // Given - final String prId = "123"; - final PublishMessageResponse prCreatedResponse = - Utilities.sendMessage( - engine, client, PR_CREATED_MSG, "", Collections.singletonMap(PR_ID_VAR, prId)); - - // When - completeTask(REQUEST_REVIEW); - Utilities.sendMessage( - engine, - client, - REVIEW_RECEIVED_MSG, - prId, - Collections.singletonMap(REVIEW_RESULT_VAR, "approved")); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - completeTask(MERGE_CODE); - completeTask(DEPLOY_SNAPSHOT); - - // Then - assertThat(prCreatedResponse) - .hasCreatedProcessInstance() - .extractingProcessInstance() - .hasPassedElementsInOrder(REQUEST_REVIEW, MERGE_CODE, DEPLOY_SNAPSHOT) - .hasNotPassedElement(REMIND_REVIEWER) - .hasNotPassedElement(MAKE_CHANGES) - .hasVariableWithValue(REVIEW_RESULT_VAR, "approved") - .extractingLatestCalledProcess(AUTOMATED_TESTS_PROCESS_ID) - .hasPassedElement(AUTOMATED_TESTS_RUN_TESTS, 3) - .isCompleted(); - } - - @Test - void testRemindReviewer() throws InterruptedException, TimeoutException { - // Given - final String prId = "123"; - final PublishMessageResponse prCreatedResponse = - Utilities.sendMessage( - engine, client, PR_CREATED_MSG, "", Collections.singletonMap(PR_ID_VAR, prId)); - - // When - completeTask(REQUEST_REVIEW); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - Utilities.increaseTime(engine, Duration.ofDays(1)); - completeTask(REMIND_REVIEWER); - Utilities.sendMessage( - engine, - client, - REVIEW_RECEIVED_MSG, - prId, - Collections.singletonMap(REVIEW_RESULT_VAR, "approved")); - completeTask(MERGE_CODE); - completeTask(DEPLOY_SNAPSHOT); - - // Then - assertThat(prCreatedResponse) - .hasCreatedProcessInstance() - .extractingProcessInstance() - .hasPassedElementsInOrder(REQUEST_REVIEW, REMIND_REVIEWER, MERGE_CODE, DEPLOY_SNAPSHOT) - .hasNotPassedElement(MAKE_CHANGES) - .isCompleted(); - } - - @Test - void testRejectReview() throws InterruptedException, TimeoutException { - // Given - final String prId = "123"; - final PublishMessageResponse prCreatedResponse = - Utilities.sendMessage( - engine, client, PR_CREATED_MSG, "", Collections.singletonMap(PR_ID_VAR, prId)); - - // When - completeTask(REQUEST_REVIEW); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - completeTask(AUTOMATED_TESTS_RUN_TESTS); - Utilities.sendMessage( - engine, - client, - REVIEW_RECEIVED_MSG, - prId, - Collections.singletonMap(REVIEW_RESULT_VAR, "rejected")); - completeTask(MAKE_CHANGES); - completeTask(REQUEST_REVIEW); - Utilities.sendMessage( - engine, - client, - REVIEW_RECEIVED_MSG, - prId, - Collections.singletonMap(REVIEW_RESULT_VAR, "approved")); - completeTask(MERGE_CODE); - completeTask(DEPLOY_SNAPSHOT); - - // Then - assertThat(prCreatedResponse) - .hasCreatedProcessInstance() - .extractingProcessInstance() - .hasPassedElementsInOrder( - REQUEST_REVIEW, MAKE_CHANGES, REQUEST_REVIEW, MERGE_CODE, DEPLOY_SNAPSHOT) - .hasNotPassedElement(REMIND_REVIEWER) - .isCompleted(); - } - - private void completeTask(final String taskId) throws InterruptedException, TimeoutException { - Utilities.completeTask(engine, client, taskId); - } - - public abstract ZeebeClient getClient(); - - public abstract ZeebeTestEngine getEngine(); -} diff --git a/qa/abstracts/src/main/java/io/camunda/zeebe/process/test/qa/abstracts/util/Utilities.java b/qa/abstracts/src/main/java/io/camunda/zeebe/process/test/qa/abstracts/util/Utilities.java index 662532d0..2cf9cc51 100644 --- a/qa/abstracts/src/main/java/io/camunda/zeebe/process/test/qa/abstracts/util/Utilities.java +++ b/qa/abstracts/src/main/java/io/camunda/zeebe/process/test/qa/abstracts/util/Utilities.java @@ -127,17 +127,6 @@ public static PublishMessageResponse sendMessage( engine, client, messageName, correlationKey, Duration.ofMinutes(1), Collections.emptyMap()); } - public static PublishMessageResponse sendMessage( - final ZeebeTestEngine engine, - final ZeebeClient client, - final String messageName, - final String correlationKey, - final Map variables) - throws InterruptedException, TimeoutException { - return sendMessage( - engine, client, messageName, correlationKey, Duration.ofMinutes(1), variables); - } - public static PublishMessageResponse sendMessage( final ZeebeTestEngine engine, final ZeebeClient client, @@ -270,24 +259,4 @@ public static final class ProcessPackStartEndEvent { public static final String RESOURCE_NAME = "start-end.bpmn"; public static final String PROCESS_ID = "start-end"; } - - public static final class ProcessPackPRCreated { - - public static final String RESOURCE_NAME = "pr-created.bpmn"; - public static final String PROCESS_ID = "prCreatedProcess"; - public static final String PR_CREATED_MSG = "prCreated"; - public static final String REVIEW_RECEIVED_MSG = "reviewReceived"; - public static final String PR_ID_VAR = "prId"; - public static final String REVIEW_RESULT_VAR = "reviewResult"; - public static final String REQUEST_REVIEW = "requestReview"; - public static final String REMIND_REVIEWER = "remindReviewer"; - public static final String MAKE_CHANGES = "makeChanges"; - public static final String MERGE_CODE = "mergeCode"; - public static final String DEPLOY_SNAPSHOT = "deploySnapshot"; - public static final String TRIGGER_TESTS = "triggerTests"; - - public static final String AUTOMATED_TESTS_RESOURCE_NAME = "automated-tests.bpmn"; - public static final String AUTOMATED_TESTS_PROCESS_ID = "automatedTestsProcess"; - public static final String AUTOMATED_TESTS_RUN_TESTS = "runTests"; - } } diff --git a/qa/embedded/src/test/java/io/camunda/zeebe/process/test/qa/embedded/examples/PrCreatedTest.java b/qa/embedded/src/test/java/io/camunda/zeebe/process/test/qa/embedded/examples/PrCreatedTest.java deleted file mode 100644 index 9a53c415..00000000 --- a/qa/embedded/src/test/java/io/camunda/zeebe/process/test/qa/embedded/examples/PrCreatedTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright © 2021 camunda services GmbH (info@camunda.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.camunda.zeebe.process.test.qa.embedded.examples; - -import io.camunda.zeebe.client.ZeebeClient; -import io.camunda.zeebe.process.test.api.ZeebeTestEngine; -import io.camunda.zeebe.process.test.extension.ZeebeProcessTest; -import io.camunda.zeebe.process.test.qa.abstracts.examples.AbstractPrCreatedTest; - -@ZeebeProcessTest -class PrCreatedTest extends AbstractPrCreatedTest { - - private ZeebeTestEngine engine; - private ZeebeClient client; - - @Override - public ZeebeClient getClient() { - return client; - } - - @Override - public ZeebeTestEngine getEngine() { - return engine; - } -} diff --git a/qa/testcontainers/src/test/java/io/camunda/zeebe/process/test/qa/testcontainer/examples/PrCreatedTest.java b/qa/testcontainers/src/test/java/io/camunda/zeebe/process/test/qa/testcontainer/examples/PrCreatedTest.java deleted file mode 100644 index 3a61db6b..00000000 --- a/qa/testcontainers/src/test/java/io/camunda/zeebe/process/test/qa/testcontainer/examples/PrCreatedTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2021 camunda services GmbH (info@camunda.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.camunda.zeebe.process.test.qa.testcontainer.examples; - -import io.camunda.zeebe.client.ZeebeClient; -import io.camunda.zeebe.process.test.api.ZeebeTestEngine; -import io.camunda.zeebe.process.test.extension.testcontainer.ZeebeProcessTest; -import io.camunda.zeebe.process.test.qa.abstracts.examples.AbstractPrCreatedTest; - -@ZeebeProcessTest -public class PrCreatedTest extends AbstractPrCreatedTest { - private ZeebeTestEngine engine; - private ZeebeClient client; - - @Override - public ZeebeClient getClient() { - return client; - } - - @Override - public ZeebeTestEngine getEngine() { - return engine; - } -}