diff --git a/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/TraceabilityTestStepDefinition.java b/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/TraceabilityTestStepDefinition.java index 5cb7455899..987c9e9e7f 100644 --- a/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/TraceabilityTestStepDefinition.java +++ b/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/TraceabilityTestStepDefinition.java @@ -121,7 +121,7 @@ public void iCheckIfQualityInvestigationHasProperValues(DataTable dataTable) { .ignoreExceptions() .until(() -> { try { - QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv(), INVESTIGATION); + QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv()); NotificationValidator.assertHasFields(result, normalize(dataTable.asMap())); return true; } catch (AssertionError assertionError) { @@ -134,27 +134,27 @@ public void iCheckIfQualityInvestigationHasProperValues(DataTable dataTable) { @When("I approve quality investigation") public void iApproveQualityInvestigation() { - restProvider.approveNotification(getNotificationIdBasedOnEnv(), INVESTIGATION); + restProvider.approveNotification(getNotificationIdBasedOnEnv()); } @When("I cancel quality investigation") public void iCancelQualityInvestigation() { - restProvider.cancelNotification(getNotificationIdBasedOnEnv(), INVESTIGATION); + restProvider.cancelNotification(getNotificationIdBasedOnEnv()); } @When("I cancel quality alert") public void iCancelQualityAlert() { - restProvider.cancelNotification(getNotificationIdBasedOnEnv(), ALERT); + restProvider.cancelNotification(getNotificationIdBasedOnEnv()); } @When("I close quality investigation") public void iCloseQualityInvestigation() { - restProvider.closeNotification(getNotificationIdBasedOnEnv(), INVESTIGATION); + restProvider.closeNotification(getNotificationIdBasedOnEnv()); } @When("I close quality alert") public void iCloseQualityAlert() { - restProvider.closeNotification(getNotificationIdBasedOnEnv(), ALERT); + restProvider.closeNotification(getNotificationIdBasedOnEnv()); } @When("I check, if quality investigation has been received") @@ -164,7 +164,7 @@ public void iCanSeeNotificationWasReceived() { .atMost(Duration.FIVE_MINUTES) .pollInterval(1, TimeUnit.SECONDS) .until(() -> { - final List result = restProvider.getReceivedNotifications(INVESTIGATION); + final List result = restProvider.getReceivedNotifications(); result.stream().map(QualityNotificationResponse::getDescription).forEach(System.out::println); return result.stream().filter(qn -> Objects.equals(qn.getDescription(), notificationDescription)).findFirst().orElse(null); }, Matchers.notNullValue() @@ -177,7 +177,7 @@ public void iCanSeeNotificationWasReceived() { @When("I check, if quality investigation has not been received") public void iCanSeeInvestigationWasNotReceived() { - final List result = restProvider.getReceivedNotifications(INVESTIGATION); + final List result = restProvider.getReceivedNotifications(); Optional first = result.stream() .filter(qualityNotificationResponse -> Objects.equals(qualityNotificationResponse.getId(), getNotificationIdBasedOnEnv())) .findFirst(); @@ -186,7 +186,7 @@ public void iCanSeeInvestigationWasNotReceived() { @When("I check, if quality alert has not been received") public void iCanSeeAlertWasNotReceived() { - final List result = restProvider.getReceivedNotifications(ALERT); + final List result = restProvider.getReceivedNotifications(); Optional first = result.stream() .filter(qualityNotificationResponse -> Objects.equals(qualityNotificationResponse.getId(), getNotificationIdBasedOnEnv())) .findFirst(); @@ -195,28 +195,28 @@ public void iCanSeeAlertWasNotReceived() { @When("I acknowledge quality investigation") public void iAcknowledgeQualityInvestigation() { - restProvider.updateNotification(INVESTIGATION, getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACKNOWLEDGED, ""); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACKNOWLEDGED, ""); } @When("I accept quality investigation") public void iAcceptQualityInvestigation(DataTable dataTable) { String reason = normalize(dataTable.asMap()).get("reason"); System.out.println("reason: " + reason); - restProvider.updateNotification(INVESTIGATION, getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACCEPTED, reason); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACCEPTED, reason); } @When("I decline quality investigation") public void iDeclineQualityInvestigation(DataTable dataTable) { String reason = normalize(dataTable.asMap()).get("reason"); System.out.println("reason: " + reason); - restProvider.updateNotification(INVESTIGATION, getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.DECLINED, reason); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.DECLINED, reason); } @When("I decline quality alert") public void iDeclineQualityAlert(DataTable dataTable) { String reason = normalize(dataTable.asMap()).get("reason"); System.out.println("reason: " + reason); - restProvider.updateNotification(ALERT, getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.DECLINED, reason); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.DECLINED, reason); } private Long getNotificationIdBasedOnEnv() { @@ -275,7 +275,7 @@ public void iCheckIfQualityAlertHasProperValues(DataTable dataTable) { .ignoreExceptions() .until(() -> { try { - QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv(), ALERT); + QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv()); NotificationValidator.assertHasFields(result, normalize(dataTable.asMap())); return true; } catch (AssertionError assertionError) { @@ -289,7 +289,7 @@ public void iCheckIfQualityAlertHasProperValues(DataTable dataTable) { @When("I approve quality alert") public void iApproveQualityAlert() { - restProvider.approveNotification(getNotificationIdBasedOnEnv(), ALERT); + restProvider.approveNotification(getNotificationIdBasedOnEnv()); } @@ -300,7 +300,7 @@ public void iCanSeeQualityAlertWasReceived() { .atMost(Duration.FIVE_MINUTES) .pollInterval(1, TimeUnit.SECONDS) .until(() -> { - final List result = restProvider.getReceivedNotifications(ALERT); + final List result = restProvider.getReceivedNotifications(); result.stream().map(QualityNotificationResponse::getDescription).forEach(System.out::println); return result.stream().filter(qn -> Objects.equals(qn.getDescription(), notificationDescription)).findFirst().orElse(null); }, Matchers.notNullValue() @@ -313,7 +313,7 @@ public void iCanSeeQualityAlertWasReceived() { @When("I acknowledge quality alert") public void iAcknowledgeQualityAlert() { - restProvider.updateNotification(ALERT, getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACKNOWLEDGED, ""); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACKNOWLEDGED, ""); } @@ -321,6 +321,6 @@ public void iAcknowledgeQualityAlert() { public void iAcceptQualityAlert(DataTable dataTable) { String reason = normalize(dataTable.asMap()).get("reason"); System.out.println("reason: " + reason); - restProvider.updateNotification(ALERT, getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACCEPTED, reason); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACCEPTED, reason); } } diff --git a/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/tooling/NotificationTypeEnum.java b/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/tooling/NotificationTypeEnum.java index c9a4cb750a..20265f9c10 100644 --- a/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/tooling/NotificationTypeEnum.java +++ b/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/tooling/NotificationTypeEnum.java @@ -18,14 +18,14 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.test.tooling; -public enum NotificationTypeEnum { - ALERT("alerts"), +import qualitynotification.base.request.QualityNotificationTypeRequest; - INVESTIGATION("investigations"); +public enum NotificationTypeEnum { + ALERT, - public final String label; + INVESTIGATION; - NotificationTypeEnum(String label) { - this.label = label; + public QualityNotificationTypeRequest toRequest() { + return QualityNotificationTypeRequest.fromValue(this.name()); } } diff --git a/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/tooling/rest/RestProvider.java b/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/tooling/rest/RestProvider.java index fe913c4d7f..81f102c5d1 100644 --- a/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/tooling/rest/RestProvider.java +++ b/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/tooling/rest/RestProvider.java @@ -104,6 +104,7 @@ public QualityNotificationIdResponse createNotification( .description(description) .targetDate(targetDate) .severity(QualityNotificationSeverityRequest.fromValue(severity)) + .type(notificationType.toRequest()) .receiverBpn(receiverBpn) .build(); return given().log().body() @@ -111,7 +112,7 @@ public QualityNotificationIdResponse createNotification( .contentType(ContentType.JSON) .body(requestBody) .when() - .post("/api/" + notificationType.label) + .post("/api/notifications") .then() .statusCode(HttpStatus.SC_CREATED) .extract() @@ -119,7 +120,7 @@ public QualityNotificationIdResponse createNotification( } - public void approveNotification(final Long notificationId, NotificationTypeEnum notificationType) { + public void approveNotification(final Long notificationId) { await() .atMost(Duration.FIVE_MINUTES) .pollInterval(10, TimeUnit.SECONDS) @@ -128,7 +129,7 @@ public void approveNotification(final Long notificationId, NotificationTypeEnum ValidatableResponse validatableResponse = given().spec(getRequestSpecification()) .contentType(ContentType.JSON) .when() - .post("api/" + notificationType.label + "/{notificationId}/approve".replace( + .post("api/notifications/{notificationId}/approve".replace( "{notificationId}", notificationId.toString() )) @@ -144,12 +145,12 @@ public void approveNotification(final Long notificationId, NotificationTypeEnum } - public void cancelNotification(final Long notificationId, NotificationTypeEnum notificationType) { + public void cancelNotification(final Long notificationId) { given().spec(getRequestSpecification()) .contentType(ContentType.JSON) .when() - .post("api/" + notificationType.label + "/{notificationId}/cancel".replace( + .post("api/notifications/{notificationId}/cancel".replace( "{notificationId}", notificationId.toString() )) @@ -157,7 +158,7 @@ public void cancelNotification(final Long notificationId, NotificationTypeEnum n .statusCode(HttpStatus.SC_NO_CONTENT); } - public void closeNotification(final Long notificationId, NotificationTypeEnum notificationType) { + public void closeNotification(final Long notificationId) { await() .atMost(Duration.FIVE_MINUTES) .pollInterval(10, TimeUnit.SECONDS) @@ -167,7 +168,7 @@ public void closeNotification(final Long notificationId, NotificationTypeEnum no .contentType(ContentType.JSON) .when() .body("{\"reason\": \"stringstringstr\"}") - .post("api/" + notificationType.label + "/{notificationId}/close".replace( + .post("api/notifications/{notificationId}/close".replace( "{notificationId}", notificationId.toString() )) @@ -182,7 +183,7 @@ public void closeNotification(final Long notificationId, NotificationTypeEnum no } - public void updateNotification(NotificationTypeEnum notificationType, final Long notificationId, + public void updateNotification(final Long notificationId, UpdateQualityNotificationStatusRequest status, String reason) { UpdateQualityNotificationRequest requestBody = UpdateQualityNotificationRequest.builder() .status(status) @@ -198,7 +199,7 @@ public void updateNotification(NotificationTypeEnum notificationType, final Long .contentType(ContentType.JSON) .body(requestBody) .when() - .post("api/" + notificationType.label + "/{notificationId}/update".replace( + .post("api/notifications/{notificationId}/update".replace( "{notificationId}", notificationId.toString() )) @@ -215,7 +216,7 @@ public void updateNotification(NotificationTypeEnum notificationType, final Long } - public List getReceivedNotifications(NotificationTypeEnum notificationType) { + public List getReceivedNotifications() { return given().spec(getRequestSpecification()) .contentType(ContentType.JSON) @@ -230,7 +231,7 @@ public List getReceivedNotifications(NotificationTy " ]\n" + " }\n" + "}") - .post("/api/" + notificationType.label + "/filter") + .post("/api/notifications/filter") .then() .statusCode(HttpStatus.SC_OK) .extract() @@ -238,11 +239,11 @@ public List getReceivedNotifications(NotificationTy .jsonPath().getList("content", QualityNotificationResponse.class); } - public QualityNotificationResponse getNotification(Long investigationId, NotificationTypeEnum notificationType) { + public QualityNotificationResponse getNotification(Long investigationId) { return given().spec(getRequestSpecification()) .contentType(ContentType.JSON) .when() - .get("/api/" + notificationType.label + "/" + investigationId) + .get("/api/notifications/" + investigationId) .then() .statusCode(HttpStatus.SC_OK) .log()