Skip to content

Commit

Permalink
Merge pull request #235 from camunda-cloud/217_extracting
Browse files Browse the repository at this point in the history
Rename extract methods to extracting
  • Loading branch information
pihme authored Mar 3, 2022
2 parents 6cfabc5 + 0392244 commit a47773a
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

/** Assertions for incidents. An incident is identified by its incident key. */
public class IncidentAssert extends AbstractAssert<IncidentAssert, Long> {

private final String LINE_SEPARATOR = System.lineSeparator();

private final RecordStream recordStream;
Expand Down Expand Up @@ -80,7 +81,7 @@ expectedErrorMessage, actualErrorMessage, composeIncidentDetails())
*
* @return {@link StringAssert} of error message
*/
public StringAssert extractErrorMessage() {
public StringAssert extractingErrorMessage() {
final IncidentRecordValue record = getIncidentCreatedRecordValue();
final String actualErrorMessage = record.getErrorMessage();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public JobAssert hasNoIncidents() {
*
* @return {@link IncidentAssert} for the latest incident
*/
public IncidentAssert extractLatestIncident() {
public IncidentAssert extractingLatestIncident() {
hasAnyIncidents();

final List<Record<IncidentRecordValue>> incidentCreatedRecords =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
import io.camunda.zeebe.protocol.record.value.IncidentRecordValue;
import io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue;
import io.camunda.zeebe.protocol.record.value.VariableRecordValue;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.SoftAssertions;
Expand Down Expand Up @@ -559,7 +564,7 @@ public ProcessInstanceAssert hasNoIncidents() {
*
* @return {@link IncidentAssert} for the latest incident
*/
public IncidentAssert extractLatestIncident() {
public IncidentAssert extractingLatestIncident() {
hasAnyIncidents();

final List<Record<IncidentRecordValue>> incidentCreatedRecords =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ void testHasErrorType() throws InterruptedException, TimeoutException {
final ActivatedJob actual = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
incidentAssert.hasErrorType(ErrorType.UNHANDLED_ERROR_EVENT);
Expand All @@ -68,7 +69,8 @@ void testHasErrorMessage() throws InterruptedException, TimeoutException {
final ActivatedJob actual = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
incidentAssert.hasErrorMessage(
Expand All @@ -89,9 +91,10 @@ void testExtractErrorMessage() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

final StringAssert messageAssert = incidentAssert.extractErrorMessage();
final StringAssert messageAssert = incidentAssert.extractingErrorMessage();

// then
Assertions.assertThat(messageAssert).isNotNull();
Expand All @@ -114,7 +117,8 @@ void testWasRaisedInProcessInstance() throws InterruptedException, TimeoutExcept

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
incidentAssert.wasRaisedInProcessInstance(processInstanceEvent);
Expand Down Expand Up @@ -143,7 +147,7 @@ void testOccurredOnElement() throws InterruptedException, TimeoutException {
Utilities.waitForIdleState(engine, Duration.ofSeconds(1));

final IncidentAssert incidentAssert =
BpmnAssert.assertThat(instanceEvent).extractLatestIncident();
BpmnAssert.assertThat(instanceEvent).extractingLatestIncident();

// then
incidentAssert.occurredOnElement(ProcessPackLoopingServiceTask.GATEWAY_ELEMENT_ID);
Expand All @@ -162,7 +166,7 @@ void testOccurredDuringJob() throws InterruptedException, TimeoutException {
final ActivatedJob job = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, job.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(job).extractLatestIncident();
final IncidentAssert incidentAssert = BpmnAssert.assertThat(job).extractingLatestIncident();

// then
incidentAssert.occurredDuringJob(job);
Expand All @@ -183,7 +187,8 @@ void testIsResolved() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

final long incidentKey = incidentAssert.getIncidentKey();
client.newResolveIncidentCommand(incidentKey).send().join();
Expand All @@ -208,7 +213,8 @@ void testIsUnresolved() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
incidentAssert.isUnresolved();
Expand Down Expand Up @@ -236,7 +242,8 @@ void testHasErrorTypeFailure() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.hasErrorType(ErrorType.IO_MAPPING_ERROR))
Expand All @@ -259,7 +266,8 @@ void testHasErrorMessageFailure() throws InterruptedException, TimeoutException

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.hasErrorMessage(WRONG_VALUE))
Expand All @@ -283,7 +291,8 @@ void testWasRaisedInProcessInstanceFailure() throws InterruptedException, Timeou

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.wasRaisedInProcessInstance(-1))
Expand Down Expand Up @@ -315,7 +324,7 @@ void testOccurredOnElementFailure() throws InterruptedException, TimeoutExceptio
Utilities.waitForIdleState(engine, Duration.ofSeconds(1));

final IncidentAssert incidentAssert =
BpmnAssert.assertThat(instanceEvent).extractLatestIncident();
BpmnAssert.assertThat(instanceEvent).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.occurredOnElement(WRONG_VALUE))
Expand All @@ -338,7 +347,7 @@ void testOccurredDuringJobFailure() throws InterruptedException, TimeoutExceptio
final ActivatedJob job = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, job.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(job).extractLatestIncident();
final IncidentAssert incidentAssert = BpmnAssert.assertThat(job).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.occurredDuringJob(-1))
Expand All @@ -362,7 +371,8 @@ void testIsResolvedFailure() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
assertThatThrownBy(incidentAssert::isResolved)
Expand All @@ -384,7 +394,8 @@ void testIsUnresolvedFailure() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

final long incidentKey = incidentAssert.getIncidentKey();
client.newResolveIncidentCommand(incidentKey).send().join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ void testExtractLatestIncident() throws InterruptedException, TimeoutException {
final ActivatedJob actual = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MSG);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
Assertions.assertThat(incidentAssert).isNotNull();
Expand Down Expand Up @@ -360,7 +361,7 @@ void testExtractLatestIncidentFailure() throws InterruptedException, TimeoutExce

// then
final ActivatedJob actual = jobActivationResponse.getJobs().get(0);
assertThatThrownBy(() -> BpmnAssert.assertThat(actual).extractLatestIncident())
assertThatThrownBy(() -> BpmnAssert.assertThat(actual).extractingLatestIncident())
.isInstanceOf(AssertionError.class)
.hasMessage("No incidents were raised for this job");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

@ZeebeProcessTest
class ProcessInstanceAssertTest {

private static final String LINE_SEPARATOR = System.lineSeparator();
private static final Map<String, Object> TYPED_TEST_VARIABLES = new HashMap<>();

Expand Down Expand Up @@ -482,7 +483,7 @@ void testExtractLatestIncident() throws InterruptedException, TimeoutException {
Utilities.completeTask(engine, client, ProcessPackLoopingServiceTask.ELEMENT_ID);

final IncidentAssert incidentAssert =
BpmnAssert.assertThat(instanceEvent).extractLatestIncident();
BpmnAssert.assertThat(instanceEvent).extractingLatestIncident();

// then

Expand Down Expand Up @@ -1104,7 +1105,7 @@ void testExtractLatestIncidentFailure() throws InterruptedException, TimeoutExce
Utilities.startProcessInstance(engine, client, ProcessPackLoopingServiceTask.PROCESS_ID);

// then
assertThatThrownBy(() -> BpmnAssert.assertThat(instanceEvent).extractLatestIncident())
assertThatThrownBy(() -> BpmnAssert.assertThat(instanceEvent).extractingLatestIncident())
.isInstanceOf(AssertionError.class)
.hasMessage("No incidents were raised for this process instance");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ void testHasErrorType() throws InterruptedException, TimeoutException {
final ActivatedJob actual = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
incidentAssert.hasErrorType(ErrorType.UNHANDLED_ERROR_EVENT);
Expand All @@ -68,7 +69,8 @@ void testHasErrorMessage() throws InterruptedException, TimeoutException {
final ActivatedJob actual = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
incidentAssert.hasErrorMessage(
Expand All @@ -89,9 +91,10 @@ void testExtractErrorMessage() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

final StringAssert messageAssert = incidentAssert.extractErrorMessage();
final StringAssert messageAssert = incidentAssert.extractingErrorMessage();

// then
Assertions.assertThat(messageAssert).isNotNull();
Expand All @@ -114,7 +117,8 @@ void testWasRaisedInProcessInstance() throws InterruptedException, TimeoutExcept

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
incidentAssert.wasRaisedInProcessInstance(processInstanceEvent);
Expand Down Expand Up @@ -143,7 +147,7 @@ void testOccurredOnElement() throws InterruptedException, TimeoutException {
Utilities.waitForIdleState(engine, Duration.ofSeconds(1));

final IncidentAssert incidentAssert =
BpmnAssert.assertThat(instanceEvent).extractLatestIncident();
BpmnAssert.assertThat(instanceEvent).extractingLatestIncident();

// then
incidentAssert.occurredOnElement(ProcessPackLoopingServiceTask.GATEWAY_ELEMENT_ID);
Expand All @@ -162,7 +166,7 @@ void testOccurredDuringJob() throws InterruptedException, TimeoutException {
final ActivatedJob job = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, job.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(job).extractLatestIncident();
final IncidentAssert incidentAssert = BpmnAssert.assertThat(job).extractingLatestIncident();

// then
incidentAssert.occurredDuringJob(job);
Expand All @@ -183,7 +187,8 @@ void testIsResolved() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

final long incidentKey = incidentAssert.getIncidentKey();
client.newResolveIncidentCommand(incidentKey).send().join();
Expand All @@ -208,7 +213,8 @@ void testIsUnresolved() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
incidentAssert.isUnresolved();
Expand Down Expand Up @@ -236,7 +242,8 @@ void testHasErrorTypeFailure() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.hasErrorType(ErrorType.IO_MAPPING_ERROR))
Expand All @@ -259,7 +266,8 @@ void testHasErrorMessageFailure() throws InterruptedException, TimeoutException

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.hasErrorMessage(WRONG_VALUE))
Expand All @@ -283,7 +291,8 @@ void testWasRaisedInProcessInstanceFailure() throws InterruptedException, Timeou

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.wasRaisedInProcessInstance(-1))
Expand Down Expand Up @@ -315,7 +324,7 @@ void testOccurredOnElementFailure() throws InterruptedException, TimeoutExceptio
Utilities.waitForIdleState(engine, Duration.ofSeconds(1));

final IncidentAssert incidentAssert =
BpmnAssert.assertThat(instanceEvent).extractLatestIncident();
BpmnAssert.assertThat(instanceEvent).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.occurredOnElement(WRONG_VALUE))
Expand All @@ -338,7 +347,7 @@ void testOccurredDuringJobFailure() throws InterruptedException, TimeoutExceptio
final ActivatedJob job = jobActivationResponse.getJobs().get(0);
Utilities.throwErrorCommand(engine, client, job.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(job).extractLatestIncident();
final IncidentAssert incidentAssert = BpmnAssert.assertThat(job).extractingLatestIncident();

// then
assertThatThrownBy(() -> incidentAssert.occurredDuringJob(-1))
Expand All @@ -362,7 +371,8 @@ void testIsResolvedFailure() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

// then
assertThatThrownBy(incidentAssert::isResolved)
Expand All @@ -384,7 +394,8 @@ void testIsUnresolvedFailure() throws InterruptedException, TimeoutException {

Utilities.throwErrorCommand(engine, client, actual.getKey(), ERROR_CODE, ERROR_MESSAGE);

final IncidentAssert incidentAssert = BpmnAssert.assertThat(actual).extractLatestIncident();
final IncidentAssert incidentAssert =
BpmnAssert.assertThat(actual).extractingLatestIncident();

final long incidentKey = incidentAssert.getIncidentKey();
client.newResolveIncidentCommand(incidentKey).send().join();
Expand Down
Loading

0 comments on commit a47773a

Please sign in to comment.