Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tracefoss tracefoss 1859 harden cucumber #595

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,14 @@ public void iCheckIfQualityInvestigationHasProperValues(DataTable dataTable) {
.pollInterval(1, TimeUnit.SECONDS)
.ignoreExceptions()
.until(() -> {
QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv(), INVESTIGATION);
NotificationValidator.assertHasFields(result, normalize(dataTable.asMap()));
return true;
try {
QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv(), INVESTIGATION);
NotificationValidator.assertHasFields(result, normalize(dataTable.asMap()));
return true;
} catch (AssertionError assertionError) {
assertionError.printStackTrace();
return false;
}
}
);
}
Expand Down Expand Up @@ -215,7 +220,6 @@ private Long getNotificationIdBasedOnEnv() {
}



@And("I request assets with {string}")
public void iRequestAssetsWith(String ownerFilter) {
requestedAssets = restProvider.getAssets(ownerFilter);
Expand Down Expand Up @@ -308,9 +312,14 @@ public void iCheckIfQualityAlertHasProperValues(DataTable dataTable) {
.pollInterval(1, TimeUnit.SECONDS)
.ignoreExceptions()
.until(() -> {
QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv(), ALERT);
NotificationValidator.assertHasFields(result, normalize(dataTable.asMap()));
return true;
try {
QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv(), ALERT);
NotificationValidator.assertHasFields(result, normalize(dataTable.asMap()));
return true;
} catch (AssertionError assertionError) {
assertionError.printStackTrace();
return false;
}
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,24 @@
import io.restassured.specification.RequestSpecification;
import lombok.Getter;
import org.apache.http.HttpStatus;
import org.awaitility.Duration;
import org.eclipse.tractusx.traceability.test.tooling.EnvVariablesResolver;
import org.eclipse.tractusx.traceability.test.tooling.NotificationTypeEnum;
import org.eclipse.tractusx.traceability.test.tooling.TraceXEnvironmentEnum;
import org.eclipse.tractusx.traceability.test.tooling.rest.request.StartQualityNotificationRequest;
import org.eclipse.tractusx.traceability.test.tooling.rest.request.UpdateQualityNotificationRequest;
import org.eclipse.tractusx.traceability.test.tooling.rest.request.UpdateQualityNotificationStatusRequest;
import org.eclipse.tractusx.traceability.test.tooling.rest.response.QualityNotificationResponse;
import org.hamcrest.Matchers;
import qualitynotification.base.response.QualityNotificationIdResponse;

import java.time.Instant;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES;
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
import static com.fasterxml.jackson.databind.DeserializationFeature.READ_ENUMS_USING_TO_STRING;
import static com.fasterxml.jackson.databind.DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE;
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS;
import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.eclipse.tractusx.traceability.test.tooling.TraceXEnvironmentEnum.TRACE_X_A;
import static org.eclipse.tractusx.traceability.test.tooling.TraceXEnvironmentEnum.TRACE_X_B;

Expand Down Expand Up @@ -189,23 +185,18 @@ public List<QualityNotificationResponse> getReceivedNotifications(NotificationTy
}

public QualityNotificationResponse getNotification(Long investigationId, NotificationTypeEnum notificationType) {
return await()
.atMost(Duration.TWO_MINUTES)
.pollInterval(1, TimeUnit.SECONDS)
.until(() -> given().spec(getRequestSpecification())
.contentType(ContentType.JSON)
.when()
.get("/api/" + notificationType.label + "/" + investigationId)
.then()
.statusCode(HttpStatus.SC_OK)
.log()
.body()
.extract()
.body().as(QualityNotificationResponse.class), Matchers.notNullValue()
);
return given().spec(getRequestSpecification())
.contentType(ContentType.JSON)
.when()
.get("/api/" + notificationType.label + "/" + investigationId)
.then()
.statusCode(HttpStatus.SC_OK)
.log()
.body()
.extract()
.body().as(QualityNotificationResponse.class);
}


private RequestSpecification getRequestSpecification() {
final String accessToken = authentication.obtainAccessToken();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Feature: ⭐ [BE][QUALITY_ALERTS] Create (POST) quality alerts (Rest API)
Then I check, if quality alert has proper values
| "status" | "DECLINED" |
And I check, if quality alert has proper values
| "description" | "declined in TRACEFOSS-1545" |
| "declineReason" | "declined in TRACEFOSS-1545" |

#Check if *ACCEPTANCE* of quality alerts is processed correctly which contains following checks:
#* correct ACCEPTANCE on receiver side
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Feature: ⭐ [BE][QUALITY_ALERTS] Enable Quality Alerts
Then I check, if quality alert has proper values
| "status" | "DECLINED" |
And I check, if quality alert has proper values
| "description" | "declined in TRACEFOSS-1545" |
| "declineReason" | "declined in TRACEFOSS-1545" |

#Check if *ACCEPTANCE* of quality alerts is processed correctly which contains following checks:
#* correct ACCEPTANCE on receiver side
Expand Down