Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
feat(AAE-1291): add multi instance cloud connector and test error con…
Browse files Browse the repository at this point in the history
…nector scenarios (#919)

* feat(AAE-1291): add multi instance cloud connector test scenario

* fix: add connector error propagation test scenario
  • Loading branch information
igdianov authored Apr 1, 2020
1 parent b3836c7 commit 352ebf3
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,31 @@

package org.activiti.cloud.qa.story;

import static org.activiti.api.process.model.events.IntegrationEvent.IntegrationEvents.INTEGRATION_ERROR_RECEIVED;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;
import static org.awaitility.Awaitility.await;

import java.util.Collection;

import net.thucydides.core.annotations.Steps;
import org.activiti.cloud.acc.core.steps.audit.AuditSteps;
import org.activiti.cloud.acc.core.steps.query.ProcessQuerySteps;
import org.activiti.cloud.acc.core.steps.runtime.ProcessRuntimeBundleSteps;
import org.activiti.cloud.acc.core.steps.runtime.ProcessVariablesRuntimeBundleSteps;
import org.activiti.cloud.acc.shared.steps.VariableBufferSteps;
import org.activiti.cloud.api.model.shared.CloudVariableInstance;
import org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent;
import org.activiti.cloud.api.process.model.CloudProcessInstance;
import org.activiti.cloud.api.process.model.events.CloudIntegrationErrorReceivedEvent;
import org.activiti.cloud.api.task.model.CloudTask;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.springframework.hateoas.Resources;

import net.serenitybdd.core.Serenity;
import net.thucydides.core.annotations.Steps;

public class ProcessInstanceConnectors {

@Steps
Expand All @@ -45,6 +52,12 @@ public class ProcessInstanceConnectors {
@Steps
private ProcessVariablesRuntimeBundleSteps processVariablesRuntimeBundleSteps;

@Steps
private ProcessQuerySteps processQuerySteps;

@Steps
private AuditSteps auditSteps;

private CloudProcessInstance processInstance;

@Given("the user provides a variable named $variableName with value $variableValue")
Expand All @@ -54,20 +67,31 @@ public void givenVariable(String variableName,
variableValue);
}


@Given("the user provides an integer variable named $variableName with value $variableValue")
public void givenVariable(String variableName,
Integer variableValue) {
variableBufferSteps.addVariable(variableName,
variableValue);
}

@When("the user starts an instance of process called $processDefinitionKey with the provided variables")
public void startProcessWithAvailableVariables(String processDefinitionKey) {
processInstance = processRuntimeBundleSteps.startProcessWithVariables(processDefinitionKey,
variableBufferSteps.availableVariables());

Serenity.setSessionVariable("processInstanceId").to(processInstance.getId());
}

@Then("the process instance has a task named $taskName")
public void processHasTask(String taskName) {

String processInstanceId = Serenity.sessionVariableCalled("processInstanceId");

await().untilAsserted(
() ->
{
assertThat(processInstance).isNotNull();
Collection<CloudTask> tasks = processRuntimeBundleSteps.getTaskByProcessInstanceId(processInstance.getId());
Collection<CloudTask> tasks = processRuntimeBundleSteps.getTaskByProcessInstanceId(processInstanceId);
assertThat(tasks).isNotNull();
assertThat(tasks)
.extracting(CloudTask::getName)
Expand All @@ -79,9 +103,12 @@ public void processHasTask(String taskName) {
@Then("the process instance has a variable named $variableName with value $variableValue")
public void assertThatHasVariable(String variableName,
String variableValue) {
assertThat(processInstance).isNotNull();

String processInstanceId = Serenity.sessionVariableCalled("processInstanceId");

assertThat(processInstanceId).isNotNull();
await().untilAsserted(() -> {
Resources<CloudVariableInstance> processVariables = processVariablesRuntimeBundleSteps.getVariables(processInstance.getId());
Resources<CloudVariableInstance> processVariables = processVariablesRuntimeBundleSteps.getVariables(processInstanceId);
assertThat(processVariables.getContent()).isNotNull();
assertThat(processVariables.getContent())
.extracting(CloudVariableInstance::getName,
Expand All @@ -90,4 +117,38 @@ public void assertThatHasVariable(String variableName,
variableValue));
});
}

@Then("the query process instance has an integer variable named $variableName with value $variableValue")
public void assertThatQueryHasVariable(String variableName,
Integer variableValue) {
String processInstanceId = Serenity.sessionVariableCalled("processInstanceId");

processQuerySteps.checkProcessInstanceHasVariableValue(processInstanceId,
variableName,
variableValue);
}

@Then("integration error event is emitted for the process")
public void verifyIntegrationEventsForProcesses() throws Exception {

String processId = Serenity.sessionVariableCalled("processInstanceId");

await().untilAsserted(() -> {
Collection<CloudRuntimeEvent> events = auditSteps.getEventsByProcessInstanceId(processId);

assertThat(events)
.filteredOn(CloudIntegrationErrorReceivedEvent.class::isInstance)
.isNotEmpty()
.extracting("eventType",
"errorMessage",
"errorClassName"
)
.containsExactly(
tuple(INTEGRATION_ERROR_RECEIVED,
"TestErrorConnector",
"java.lang.RuntimeException"
));
});
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
Meta:
Narrative:
As a user
I want to perform operations os processes containing connectors
I want to perform operations of processes containing connectors

Scenario: Start a process containing cloud connector
Given the user is authenticated as testuser
And the user provides a variable named movieToRank with value The Lord of The Rings
When the user starts an instance of process called RankMovieId with the provided variables
Then the process instance has a variable named movieToRank with value The Lord of The Rings
And the process instance has a variable named movieDesc with value The Lord of the Rings is an epic high fantasy novel written by English author and scholar J. R. R. Tolkien
And the process instance has a task named Add Rating
And the process instance has a task named Add Rating

Scenario: Complete a process containing multi-instance cloud connector
Given the user is authenticated as testuser
And the user provides an integer variable named instanceCount with value 3
When the user starts an instance of process called miParallelCloudConnector with the provided variables
Then the query process instance has an integer variable named instanceCount with value 3
And the query process instance has an integer variable named executionCount with value 3
And the query process instance has an integer variable named nrOfInstances with value 3
And the query process instance has an integer variable named nrOfCompletedInstances with value 3
And the query process instance has an integer variable named nrOfActiveInstances with value 0
And the query process instance has an integer variable named loopCounter with value 0
And the status of the process is changed to completed

Scenario: Propagate integration error for a process containing cloud connector to audit
Given the user is authenticated as testuser
And the user provides a variable named var with value test
When the user starts an instance of process called testErrorConnectorProcess with the provided variables
Then integration error event is emitted for the process

0 comments on commit 352ebf3

Please sign in to comment.