diff --git a/CHANGELOG.md b/CHANGELOG.md index 6857e53d51..43d9cbb26c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha - #630 Updated user manual with new part detailed view also for supplier and customer parts - #736 fixed bug in request logic of contracts detailed view - Improved the release documentation +- #706 QualityNotification naming in code replaced with Notification ### Removed - Shedlock, resilence4j, templateResolver as not used anymore diff --git a/docs/src/uml-diagrams/arc42/cross-cutting/domain-model/domain-model-quality-notifications.puml b/docs/src/uml-diagrams/arc42/cross-cutting/domain-model/domain-model-quality-notifications.puml index 03b2bd71af..e4841e2afe 100644 --- a/docs/src/uml-diagrams/arc42/cross-cutting/domain-model/domain-model-quality-notifications.puml +++ b/docs/src/uml-diagrams/arc42/cross-cutting/domain-model/domain-model-quality-notifications.puml @@ -3,41 +3,41 @@ skinparam monochrome true skinparam shadowing false skinparam defaultFontName "Architects daughter" skinparam linetype ortho -title: Quality Notification Domain +title: Notification Domain -class QualityNotification { +class Notification { bpn : BPN; title : String; - type: QualityNotificationType; - notificationId : QualityNotificationId; - notificationStatus : QualityNotificationStatus; + type: NotificationType; + notificationId : NotificationId; + notificationStatus : NotificationStatus; description: String; createdAt: Instant; - notificationSide: QualityNotificationSide; + notificationSide: NotificationSide; assetIds: ArrayList(); closeReason: String; acceptReason: String; declineReason: String; - messages: List; + messages: List; } -enum QualityNotificationType{ +enum NotificationType{ ALERT; INVESTIGATION; } -class QualityNotificationId { +class NotificationId { id: Long; } -enum QualityNotificationSide{ +enum NotificationSide{ SENDER; RECEIVER; } class BPN{ bpn: String; } -class QualityNotificationMessage { +class NotificationMessage { id: String createdBy: String createdByName: String @@ -46,31 +46,31 @@ class QualityNotificationMessage { contractAgreementId: String notificationReferenceId: String targetDate: Instant - severity: QualityNotificationSeverity; + severity: NotificationSeverity; edcNotificationId: String; created: LocalDateTime; updated: LocalDateTime; messageId: String; - status: QualityNotificationStatus; + status: NotificationStatus; errorMessage: String; } -enum QualityNotificationStatus{ - CREATED(QualityNotificationSide.SENDER, emptySet()), - SENT(QualityNotificationSide.SENDER, Set.of(QualityNotificationSide.SENDER)), - RECEIVED(QualityNotificationSide.RECEIVER, emptySet()), - ACKNOWLEDGED(QualityNotificationSide.RECEIVER, Set.of(QualityNotificationSide.RECEIVER, QualityNotificationSide.SENDER)), - ACCEPTED(QualityNotificationSide.RECEIVER, Set.of(QualityNotificationSide.RECEIVER)), - DECLINED(QualityNotificationSide.RECEIVER, Set.of(QualityNotificationSide.RECEIVER)), - CANCELED(QualityNotificationSide.SENDER, Set.of(QualityNotificationSide.SENDER)), - CLOSED(QualityNotificationSide.SENDER, of(QualityNotificationSide.SENDER, QualityNotificationSide.RECEIVER)); +enum NotificationStatus{ + CREATED(NotificationSide.SENDER, emptySet()), + SENT(NotificationSide.SENDER, Set.of(NotificationSide.SENDER)), + RECEIVED(NotificationSide.RECEIVER, emptySet()), + ACKNOWLEDGED(NotificationSide.RECEIVER, Set.of(NotificationSide.RECEIVER, NotificationSide.SENDER)), + ACCEPTED(NotificationSide.RECEIVER, Set.of(NotificationSide.RECEIVER)), + DECLINED(NotificationSide.RECEIVER, Set.of(NotificationSide.RECEIVER)), + CANCELED(NotificationSide.SENDER, Set.of(NotificationSide.SENDER)), + CLOSED(NotificationSide.SENDER, of(NotificationSide.SENDER, NotificationSide.RECEIVER)); } -QualityNotification --> QualityNotificationId -QualityNotification --> BPN -QualityNotification --> QualityNotificationType -QualityNotification --> QualityNotificationStatus -QualityNotification --> QualityNotificationSide -QualityNotification *-- QualityNotificationMessage +Notification --> NotificationId +Notification --> BPN +Notification --> NotificationType +Notification --> NotificationStatus +Notification --> NotificationSide +Notification *-- NotificationMessage @enduml diff --git a/tx-backend/openapi/traceability-foss-backend.json b/tx-backend/openapi/traceability-foss-backend.json index 28730f3a68..134b058921 100644 --- a/tx-backend/openapi/traceability-foss-backend.json +++ b/tx-backend/openapi/traceability-foss-backend.json @@ -31,18 +31,23 @@ "description" : "The endpoint returns a result of BPN EDC URL mappings.", "operationId" : "getBpnEdcs", "responses" : { - "403" : { - "description" : "Forbidden.", + "200" : { + "description" : "Returns the paged result found", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "maxItems" : 2147483647, + "minItems" : 0, + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BpnEdcMappingResponse" + } } } } }, - "415" : { - "description" : "Unsupported media type", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -51,8 +56,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "415" : { + "description" : "Unsupported media type", "content" : { "application/json" : { "schema" : { @@ -61,8 +66,8 @@ } } }, - "404" : { - "description" : "Not found.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -71,23 +76,18 @@ } } }, - "200" : { - "description" : "Returns the paged result found", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { - "maxItems" : 2147483647, - "minItems" : 0, - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/BpnEdcMappingResponse" - } + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -96,8 +96,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -106,8 +106,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -148,8 +148,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -168,8 +168,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -178,23 +178,18 @@ } } }, - "200" : { - "description" : "Returns the paged result found for BpnEdcMapping", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { - "maxItems" : 2147483647, - "minItems" : 0, - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/BpnEdcMappingResponse" - } + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "404" : { - "description" : "Not found.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -203,8 +198,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -213,18 +208,23 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "200" : { + "description" : "Returns the paged result found for BpnEdcMapping", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "maxItems" : 2147483647, + "minItems" : 0, + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BpnEdcMappingResponse" + } } } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -265,8 +265,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -285,8 +285,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -295,23 +295,18 @@ } } }, - "200" : { - "description" : "Returns the paged result found for BpnEdcMapping", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { - "maxItems" : 2147483647, - "minItems" : 0, - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/BpnEdcMappingResponse" - } + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "404" : { - "description" : "Not found.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -320,8 +315,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -330,18 +325,23 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "200" : { + "description" : "Returns the paged result found for BpnEdcMapping", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "maxItems" : 2147483647, + "minItems" : 0, + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BpnEdcMappingResponse" + } } } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -379,8 +379,8 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -399,8 +399,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -409,18 +409,18 @@ } } }, - "200" : { - "description" : "Returns submodel payload", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { - "type" : "string" + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "404" : { - "description" : "Not found.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -429,18 +429,18 @@ } } }, - "400" : { - "description" : "Bad request.", + "200" : { + "description" : "Returns submodel payload", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "type" : "string" } } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -449,8 +449,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -496,8 +496,11 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "200" : { + "description" : "Ok." + }, + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -516,8 +519,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -526,11 +529,8 @@ } } }, - "200" : { - "description" : "Ok." - }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -539,8 +539,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -552,8 +552,8 @@ "204" : { "description" : "No Content." }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -562,8 +562,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -594,15 +594,15 @@ "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/StartQualityNotificationRequest" + "$ref" : "#/components/schemas/StartNotificationRequest" } } }, "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -621,8 +621,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -631,8 +631,8 @@ } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -641,8 +641,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -656,13 +656,13 @@ "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/QualityNotificationIdResponse" + "$ref" : "#/components/schemas/NotificationIdResponse" } } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -671,8 +671,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -714,15 +714,18 @@ "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/UpdateQualityNotificationRequest" + "$ref" : "#/components/schemas/UpdateNotificationRequest" } } }, "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "204" : { + "description" : "No content." + }, + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -741,8 +744,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -751,8 +754,8 @@ } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -761,8 +764,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -771,11 +774,8 @@ } } }, - "204" : { - "description" : "No content." - }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -784,8 +784,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -827,15 +827,21 @@ "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/CloseQualityNotificationRequest" + "$ref" : "#/components/schemas/CloseNotificationRequest" } } }, "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "204" : { + "description" : "No content." + }, + "200" : { + "description" : "Ok." + }, + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -854,8 +860,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -864,11 +870,8 @@ } } }, - "200" : { - "description" : "Ok." - }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -877,8 +880,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -887,11 +890,8 @@ } } }, - "204" : { - "description" : "No content." - }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -900,8 +900,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -940,8 +940,11 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "200" : { + "description" : "Ok." + }, + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -960,8 +963,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -970,11 +973,8 @@ } } }, - "200" : { - "description" : "Ok." - }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -983,11 +983,8 @@ } } }, - "204" : { - "description" : "No content." - }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -996,8 +993,11 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "204" : { + "description" : "No content." + }, + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -1006,8 +1006,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -1046,8 +1046,11 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "200" : { + "description" : "Ok." + }, + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -1066,8 +1069,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -1076,11 +1079,8 @@ } } }, - "200" : { - "description" : "Ok." - }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -1089,11 +1089,8 @@ } } }, - "204" : { - "description" : "No content." - }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -1102,8 +1099,11 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "204" : { + "description" : "No content." + }, + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -1112,8 +1112,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -1151,8 +1151,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -1171,6 +1171,36 @@ } } }, + "403" : { + "description" : "Forbidden.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "400" : { + "description" : "Bad request.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "429" : { + "description" : "Too many requests.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, "500" : { "description" : "Internal server error.", "content" : { @@ -1271,7 +1301,7 @@ ] }, "reason" : { - "$ref" : "#/components/schemas/QualityNotificationReasonResponse" + "$ref" : "#/components/schemas/NotificationReasonResponse" }, "sendTo" : { "maxLength" : 255, @@ -1316,7 +1346,7 @@ "messages" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/QualityNotificationMessageResponse" + "$ref" : "#/components/schemas/NotificationMessageResponse" } } } @@ -1334,36 +1364,6 @@ } } } - }, - "400" : { - "description" : "Bad request.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "401" : { - "description" : "Authorization failed.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "429" : { - "description" : "Too many requests.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } } }, "security" : [ @@ -1394,8 +1394,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -1414,8 +1414,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -1424,8 +1424,8 @@ } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -1434,8 +1434,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -1454,8 +1454,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -1464,8 +1464,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -1503,108 +1503,108 @@ "required" : true }, "responses" : { - "401" : { - "description" : "Authorization failed.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { "type" : "string", "example" : { - "message" : "Authorization failed." + "message" : "Too many requests." } } } } }, - "200" : { - "description" : "Ok.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { - "maxItems" : 2147483647, - "minItems" : 0, - "type" : "array", - "description" : "PageResults", - "items" : { - "$ref" : "#/components/schemas/PageResultContractResponse" + "type" : "string", + "example" : { + "message" : "Authorization failed." } } } } }, - "400" : { - "description" : "Bad request.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { "type" : "string", "example" : { - "message" : "Bad request." + "message" : "Not found." } } } } }, - "404" : { - "description" : "Not found.", + "200" : { + "description" : "Ok.", "content" : { "application/json" : { "schema" : { - "type" : "string", - "example" : { - "message" : "Not found." + "maxItems" : 2147483647, + "minItems" : 0, + "type" : "array", + "description" : "PageResults", + "items" : { + "$ref" : "#/components/schemas/PageResultContractResponse" } } } } }, - "429" : { - "description" : "Too many requests.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { "type" : "string", "example" : { - "message" : "Too many requests." + "message" : "Internal server error." } } } } }, - "415" : { - "description" : "Unsupported media type.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { "type" : "string", "example" : { - "message" : "Unsupported media type." + "message" : "Forbidden." } } } } }, - "500" : { - "description" : "Internal server error.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { "type" : "string", "example" : { - "message" : "Internal server error." + "message" : "Bad request." } } } } }, - "403" : { - "description" : "Forbidden.", + "415" : { + "description" : "Unsupported media type.", "content" : { "application/json" : { "schema" : { "type" : "string", "example" : { - "message" : "Forbidden." + "message" : "Unsupported media type." } } } @@ -1651,14 +1651,11 @@ "required" : true }, "responses" : { - "200" : { - "description" : "OK.", - "content" : { - "application/json" : {} - } + "204" : { + "description" : "No Content." }, - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -1677,8 +1674,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -1687,8 +1684,8 @@ } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -1697,11 +1694,8 @@ } } }, - "204" : { - "description" : "No Content." - }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -1710,8 +1704,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -1720,8 +1714,14 @@ } } }, - "429" : { - "description" : "Too many requests.", + "200" : { + "description" : "OK.", + "content" : { + "application/json" : {} + } + }, + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -1767,8 +1767,11 @@ } }, "responses" : { - "403" : { - "description" : "Forbidden.", + "204" : { + "description" : "No Content." + }, + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -1787,8 +1790,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -1797,19 +1800,16 @@ } } }, - "404" : { - "description" : "Not found.", + "200" : { + "description" : "OK.", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "$ref" : "#/components/schemas/ImportResponse" } } } }, - "204" : { - "description" : "No Content." - }, "400" : { "description" : "Bad request.", "content" : { @@ -1820,18 +1820,18 @@ } } }, - "200" : { - "description" : "OK.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ImportResponse" + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -1840,8 +1840,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -1879,8 +1879,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -1899,8 +1899,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -1909,8 +1909,8 @@ } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -1919,8 +1919,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -1932,8 +1932,8 @@ "201" : { "description" : "Created." }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -1942,8 +1942,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -1981,8 +1981,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -2001,8 +2001,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -2011,8 +2011,8 @@ } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -2021,8 +2021,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -2223,8 +2223,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -2233,8 +2233,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -2272,8 +2272,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -2292,8 +2292,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -2302,8 +2302,8 @@ } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -2312,8 +2312,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -2325,8 +2325,8 @@ "201" : { "description" : "Created." }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -2335,8 +2335,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -2374,8 +2374,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -2394,8 +2394,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -2404,8 +2404,8 @@ } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -2414,8 +2414,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -2616,8 +2616,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -2626,8 +2626,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -2665,8 +2665,8 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -2685,8 +2685,28 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "400" : { + "description" : "Bad request.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -2882,28 +2902,8 @@ } } }, - "404" : { - "description" : "Not found.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "400" : { - "description" : "Bad request.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -2912,8 +2912,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -2959,48 +2959,8 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "415" : { - "description" : "Unsupported media type", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "500" : { - "description" : "Internal server error.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "404" : { - "description" : "Not found.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "200" : { - "description" : "Returns the updated asset", + "200" : { + "description" : "Returns the updated asset", "content" : { "application/json" : { "schema" : { @@ -3186,8 +3146,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -3196,8 +3156,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "415" : { + "description" : "Unsupported media type", "content" : { "application/json" : { "schema" : { @@ -3206,8 +3166,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -3215,38 +3175,9 @@ } } } - } - }, - "security" : [ - { - "oAuth2" : [ - "profile email" - ] - } - ] - } - }, - "/assets/as-built/{assetId}" : { - "get" : { - "tags" : [ - "AssetsAsBuilt" - ], - "summary" : "Get asset by id", - "description" : "The endpoint returns an asset filtered by id .", - "operationId" : "assetById_1", - "parameters" : [ - { - "name" : "assetId", - "in" : "path", - "required" : true, - "schema" : { - "type" : "string" - } - } - ], - "responses" : { - "403" : { - "description" : "Forbidden.", + }, + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -3255,8 +3186,8 @@ } } }, - "415" : { - "description" : "Unsupported media type", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -3284,17 +3215,36 @@ } } } - }, - "400" : { - "description" : "Bad request.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } + } + }, + "security" : [ + { + "oAuth2" : [ + "profile email" + ] + } + ] + } + }, + "/assets/as-built/{assetId}" : { + "get" : { + "tags" : [ + "AssetsAsBuilt" + ], + "summary" : "Get asset by id", + "description" : "The endpoint returns an asset filtered by id .", + "operationId" : "assetById_1", + "parameters" : [ + { + "name" : "assetId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" } - }, + } + ], + "responses" : { "200" : { "description" : "Returns the assets found", "content" : { @@ -3492,6 +3442,36 @@ } } }, + "415" : { + "description" : "Unsupported media type", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "403" : { + "description" : "Forbidden.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "400" : { + "description" : "Bad request.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, "429" : { "description" : "Too many requests.", "content" : { @@ -3501,6 +3481,26 @@ } } } + }, + "500" : { + "description" : "Internal server error.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "404" : { + "description" : "Not found.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } } }, "security" : [ @@ -3539,36 +3539,6 @@ "required" : true }, "responses" : { - "403" : { - "description" : "Forbidden.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "415" : { - "description" : "Unsupported media type", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "500" : { - "description" : "Internal server error.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, "200" : { "description" : "Returns the updated asset", "content" : { @@ -3756,8 +3726,8 @@ } } }, - "404" : { - "description" : "Not found.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -3766,8 +3736,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "415" : { + "description" : "Unsupported media type", "content" : { "application/json" : { "schema" : { @@ -3776,8 +3746,18 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "403" : { + "description" : "Forbidden.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -3795,6 +3775,26 @@ } } } + }, + "500" : { + "description" : "Internal server error.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "404" : { + "description" : "Not found.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } } }, "security" : [ @@ -3815,8 +3815,8 @@ "description" : "The endpoint Triggers reload of shell descriptors.", "operationId" : "reload", "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -3835,8 +3835,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -3848,8 +3848,8 @@ "202" : { "description" : "Created registry reload job." }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -3858,8 +3858,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -3868,8 +3868,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -3878,8 +3878,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -3907,18 +3907,18 @@ "description" : "The endpoint returns all policies .", "operationId" : "policy", "responses" : { - "200" : { - "description" : "Returns the policies", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/PolicyResponse" + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "403" : { - "description" : "Forbidden.", + "415" : { + "description" : "Unsupported media type", "content" : { "application/json" : { "schema" : { @@ -3927,8 +3927,8 @@ } } }, - "415" : { - "description" : "Unsupported media type", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -3937,8 +3937,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -3947,8 +3947,8 @@ } } }, - "404" : { - "description" : "Not found.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -3957,18 +3957,18 @@ } } }, - "400" : { - "description" : "Bad request.", + "200" : { + "description" : "Returns the policies", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "$ref" : "#/components/schemas/PolicyResponse" } } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -3977,8 +3977,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -4017,18 +4017,23 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "200" : { + "description" : "OK.", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "maxItems" : 2147483647, + "type" : "array", + "description" : "Notifications", + "items" : { + "$ref" : "#/components/schemas/NotificationResponse" + } } } } }, - "415" : { - "description" : "Unsupported media type", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -4037,8 +4042,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "415" : { + "description" : "Unsupported media type", "content" : { "application/json" : { "schema" : { @@ -4047,23 +4052,18 @@ } } }, - "200" : { - "description" : "OK.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { - "maxItems" : 2147483647, - "type" : "array", - "description" : "Notifications", - "items" : { - "$ref" : "#/components/schemas/QualityNotificationResponse" - } + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -4072,8 +4072,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -4082,8 +4082,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -4092,8 +4092,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -4160,8 +4160,8 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -4180,16 +4180,6 @@ } } }, - "500" : { - "description" : "Internal server error.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, "200" : { "description" : "Returns a distinct filter values for given fieldName.", "content" : { @@ -4205,8 +4195,8 @@ } } }, - "404" : { - "description" : "Not found.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -4225,8 +4215,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -4235,8 +4225,18 @@ } } }, - "429" : { - "description" : "Too many requests.", + "500" : { + "description" : "Internal server error.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -4264,18 +4264,18 @@ "description" : "The endpoint can return limited data based on the user role", "operationId" : "dashboard", "responses" : { - "403" : { - "description" : "Forbidden.", + "200" : { + "description" : "Returns dashboard data", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "$ref" : "#/components/schemas/DashboardResponse" } } } }, - "415" : { - "description" : "Unsupported media type", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -4284,8 +4284,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "415" : { + "description" : "Unsupported media type", "content" : { "application/json" : { "schema" : { @@ -4294,8 +4294,8 @@ } } }, - "404" : { - "description" : "Not found.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -4314,18 +4314,18 @@ } } }, - "200" : { - "description" : "Returns dashboard data", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/DashboardResponse" + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -4334,8 +4334,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -4374,18 +4374,21 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "200" : { + "description" : "OK.", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "$ref" : "#/components/schemas/ImportReportResponse" } } } }, - "415" : { - "description" : "Unsupported media type", + "204" : { + "description" : "No Content." + }, + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -4394,8 +4397,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "415" : { + "description" : "Unsupported media type", "content" : { "application/json" : { "schema" : { @@ -4404,8 +4407,8 @@ } } }, - "404" : { - "description" : "Not found.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -4414,21 +4417,18 @@ } } }, - "204" : { - "description" : "No Content." - }, - "200" : { - "description" : "OK.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ImportReportResponse" + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -4437,8 +4437,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -4447,8 +4447,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -4494,36 +4494,6 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "415" : { - "description" : "Unsupported media type", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "500" : { - "description" : "Internal server error.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, "200" : { "description" : "Returns the paged result found for Asset", "content" : { @@ -4716,8 +4686,8 @@ } } }, - "404" : { - "description" : "Not found.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -4726,8 +4696,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "415" : { + "description" : "Unsupported media type", "content" : { "application/json" : { "schema" : { @@ -4736,8 +4706,18 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "403" : { + "description" : "Forbidden.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -4755,6 +4735,26 @@ } } } + }, + "500" : { + "description" : "Internal server error.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "404" : { + "description" : "Not found.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } } }, "security" : [ @@ -4817,8 +4817,8 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -4837,18 +4837,8 @@ } } }, - "500" : { - "description" : "Internal server error.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "200" : { - "description" : "Returns a distinct filter values for given fieldName.", + "200" : { + "description" : "Returns a distinct filter values for given fieldName.", "content" : { "application/json" : { "schema" : { @@ -4862,8 +4852,8 @@ } } }, - "404" : { - "description" : "Not found.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -4882,8 +4872,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -4892,8 +4882,18 @@ } } }, - "429" : { - "description" : "Too many requests.", + "500" : { + "description" : "Internal server error.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -4931,56 +4931,6 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "415" : { - "description" : "Unsupported media type", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "500" : { - "description" : "Internal server error.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "404" : { - "description" : "Not found.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "400" : { - "description" : "Bad request.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, "200" : { "description" : "Returns the asset by childId", "content" : { @@ -5178,6 +5128,36 @@ } } }, + "415" : { + "description" : "Unsupported media type", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "403" : { + "description" : "Forbidden.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "400" : { + "description" : "Bad request.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, "429" : { "description" : "Too many requests.", "content" : { @@ -5187,6 +5167,26 @@ } } } + }, + "500" : { + "description" : "Internal server error.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "404" : { + "description" : "Not found.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } } }, "security" : [ @@ -5225,6 +5225,66 @@ } ], "responses" : { + "401" : { + "description" : "Authorization failed.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "415" : { + "description" : "Unsupported media type", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "403" : { + "description" : "Forbidden.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "400" : { + "description" : "Bad request.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "429" : { + "description" : "Too many requests.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "500" : { + "description" : "Internal server error.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, "200" : { "description" : "Returns the paged result found for Asset", "content" : { @@ -5417,36 +5477,6 @@ } } }, - "403" : { - "description" : "Forbidden.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "415" : { - "description" : "Unsupported media type", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "500" : { - "description" : "Internal server error.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, "404" : { "description" : "Not found.", "content" : { @@ -5456,36 +5486,6 @@ } } } - }, - "400" : { - "description" : "Bad request.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "401" : { - "description" : "Authorization failed.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "429" : { - "description" : "Too many requests.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } } }, "security" : [ @@ -5548,8 +5548,8 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -5568,16 +5568,6 @@ } } }, - "500" : { - "description" : "Internal server error.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, "200" : { "description" : "Returns a distinct filter values for given fieldName.", "content" : { @@ -5593,8 +5583,8 @@ } } }, - "404" : { - "description" : "Not found.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -5613,8 +5603,8 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -5623,8 +5613,18 @@ } } }, - "429" : { - "description" : "Too many requests.", + "500" : { + "description" : "Internal server error.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -5652,8 +5652,8 @@ "description" : "The endpoint returns a map for assets consumed by the map.", "operationId" : "assetsCountryMap", "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -5672,8 +5672,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -5682,23 +5682,18 @@ } } }, - "200" : { - "description" : "Returns the assets found", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { - "maxItems" : 2147483647, - "minItems" : 0, - "type" : "array", - "items" : { - "type" : "string" - } + "$ref" : "#/components/schemas/ErrorResponse" } } } }, - "404" : { - "description" : "Not found.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -5707,18 +5702,23 @@ } } }, - "400" : { - "description" : "Bad request.", + "200" : { + "description" : "Returns the assets found", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" + "maxItems" : 2147483647, + "minItems" : 0, + "type" : "array", + "items" : { + "type" : "string" + } } } } }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -5727,8 +5727,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -5766,8 +5766,8 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -5786,6 +5786,36 @@ } } }, + "403" : { + "description" : "Forbidden.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "400" : { + "description" : "Bad request.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, + "429" : { + "description" : "Too many requests.", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ErrorResponse" + } + } + } + }, "500" : { "description" : "Internal server error.", "content" : { @@ -5992,36 +6022,6 @@ } } } - }, - "400" : { - "description" : "Bad request.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "401" : { - "description" : "Authorization failed.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } - }, - "429" : { - "description" : "Too many requests.", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ErrorResponse" - } - } - } } }, "security" : [ @@ -6042,8 +6042,11 @@ "description" : "Deletes all submodels from the system.", "operationId" : "deleteSubmodels", "responses" : { - "403" : { - "description" : "Forbidden.", + "200" : { + "description" : "Ok." + }, + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -6062,8 +6065,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -6072,11 +6075,8 @@ } } }, - "200" : { - "description" : "Ok." - }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -6085,8 +6085,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -6098,8 +6098,8 @@ "204" : { "description" : "No Content." }, - "401" : { - "description" : "Authorization failed.", + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -6108,8 +6108,8 @@ } } }, - "429" : { - "description" : "Too many requests.", + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -6147,8 +6147,8 @@ } ], "responses" : { - "403" : { - "description" : "Forbidden.", + "401" : { + "description" : "Authorization failed.", "content" : { "application/json" : { "schema" : { @@ -6167,8 +6167,8 @@ } } }, - "500" : { - "description" : "Internal server error.", + "403" : { + "description" : "Forbidden.", "content" : { "application/json" : { "schema" : { @@ -6177,14 +6177,8 @@ } } }, - "204" : { - "description" : "Deleted." - }, - "200" : { - "description" : "Okay" - }, - "404" : { - "description" : "Not found.", + "400" : { + "description" : "Bad request.", "content" : { "application/json" : { "schema" : { @@ -6193,8 +6187,8 @@ } } }, - "400" : { - "description" : "Bad request.", + "429" : { + "description" : "Too many requests.", "content" : { "application/json" : { "schema" : { @@ -6203,8 +6197,11 @@ } } }, - "401" : { - "description" : "Authorization failed.", + "204" : { + "description" : "Deleted." + }, + "500" : { + "description" : "Internal server error.", "content" : { "application/json" : { "schema" : { @@ -6213,8 +6210,11 @@ } } }, - "429" : { - "description" : "Too many requests.", + "200" : { + "description" : "Okay" + }, + "404" : { + "description" : "Not found.", "content" : { "application/json" : { "schema" : { @@ -6281,7 +6281,7 @@ } } }, - "StartQualityNotificationRequest" : { + "StartNotificationRequest" : { "required" : [ "severity", "type" @@ -6347,7 +6347,7 @@ } } }, - "QualityNotificationIdResponse" : { + "NotificationIdResponse" : { "type" : "object", "properties" : { "id" : { @@ -6357,7 +6357,7 @@ } } }, - "UpdateQualityNotificationRequest" : { + "UpdateNotificationRequest" : { "required" : [ "status" ], @@ -6378,7 +6378,7 @@ } } }, - "CloseQualityNotificationRequest" : { + "CloseNotificationRequest" : { "type" : "object", "properties" : { "reason" : { @@ -6436,7 +6436,7 @@ } } }, - "QualityNotificationMessageResponse" : { + "NotificationMessageResponse" : { "type" : "object", "properties" : { "id" : { @@ -6508,7 +6508,7 @@ } } }, - "QualityNotificationReasonResponse" : { + "NotificationReasonResponse" : { "type" : "object", "properties" : { "close" : { @@ -6531,7 +6531,7 @@ } } }, - "QualityNotificationResponse" : { + "NotificationResponse" : { "type" : "object", "properties" : { "id" : { @@ -6613,7 +6613,7 @@ ] }, "reason" : { - "$ref" : "#/components/schemas/QualityNotificationReasonResponse" + "$ref" : "#/components/schemas/NotificationReasonResponse" }, "sendTo" : { "maxLength" : 255, @@ -6658,7 +6658,7 @@ "messages" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/QualityNotificationMessageResponse" + "$ref" : "#/components/schemas/NotificationMessageResponse" } } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/application/asplanned/rest/AssetAsPlannedController.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/application/asplanned/rest/AssetAsPlannedController.java index 293c930076..be39f76fbd 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/application/asplanned/rest/AssetAsPlannedController.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/application/asplanned/rest/AssetAsPlannedController.java @@ -31,8 +31,6 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; -import jakarta.ws.rs.DefaultValue; -import jakarta.ws.rs.QueryParam; import org.eclipse.tractusx.traceability.assets.application.asbuilt.mapper.QualityTypeMapper; import org.eclipse.tractusx.traceability.assets.application.asplanned.mapper.AssetAsPlannedFieldMapper; import org.eclipse.tractusx.traceability.assets.application.asplanned.mapper.AssetAsPlannedResponseMapper; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/application/base/mapper/AssetBaseResponseMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/application/base/mapper/AssetBaseResponseMapper.java index 4dbf7f0eb9..11483ce650 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/application/base/mapper/AssetBaseResponseMapper.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/application/base/mapper/AssetBaseResponseMapper.java @@ -47,8 +47,8 @@ import org.eclipse.tractusx.traceability.assets.domain.base.model.aspect.DetailAspectData; import org.eclipse.tractusx.traceability.assets.domain.base.model.aspect.DetailAspectModel; import org.eclipse.tractusx.traceability.assets.domain.base.model.aspect.DetailAspectType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; import java.util.List; @@ -137,11 +137,11 @@ public static SemanticDataModelResponse from(final SemanticDataModel semanticDat return SemanticDataModelResponse.valueOf(semanticDataModel.name()); } - protected static List getNotificationIdsInActiveState(List notifications) { + protected static List getNotificationIdsInActiveState(List notifications) { return emptyIfNull(notifications).stream() - .filter(QualityNotification::isActiveState) - .map(QualityNotification::getNotificationId) - .map(QualityNotificationId::value) + .filter(Notification::isActiveState) + .map(Notification::getNotificationId) + .map(NotificationId::value) .toList(); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/domain/base/model/AssetBase.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/domain/base/model/AssetBase.java index 4807f7bb31..4d7097d136 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/domain/base/model/AssetBase.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/domain/base/model/AssetBase.java @@ -28,7 +28,7 @@ import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.irs.component.enums.BomLifecycle; import org.eclipse.tractusx.traceability.assets.domain.base.model.aspect.DetailAspectModel; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; import java.util.List; @@ -54,10 +54,10 @@ public class AssetBase { private SemanticDataModel semanticDataModel; private String classification; private List detailAspectModels; - private List sentQualityAlerts; - private List receivedQualityAlerts; - private List sentQualityInvestigations; - private List receivedQualityInvestigations; + private List sentQualityAlerts; + private List receivedQualityAlerts; + private List sentQualityInvestigations; + private List receivedQualityInvestigations; private ImportState importState; private String importNote; private String policyId; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/domain/dashboard/service/DashboardServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/domain/dashboard/service/DashboardServiceImpl.java index df1abdd316..487f300f99 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/domain/dashboard/service/DashboardServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/domain/dashboard/service/DashboardServiceImpl.java @@ -27,9 +27,9 @@ import org.eclipse.tractusx.traceability.assets.domain.asplanned.repository.AssetAsPlannedRepository; import org.eclipse.tractusx.traceability.assets.domain.base.model.Owner; import org.eclipse.tractusx.traceability.assets.domain.dashboard.model.Dashboard; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; import org.springframework.stereotype.Component; import java.util.List; @@ -53,20 +53,20 @@ public Dashboard getDashboard() { long asPlannedOwnParts = assetAsPlannedRepository.countAssetsByOwner(Owner.OWN); - long myPartsWithSentAlerts = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.OWN), QualityNotificationType.ALERT); - long myPartsWithReceivedInvestigations = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.OWN), QualityNotificationType.INVESTIGATION); + long myPartsWithSentAlerts = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.OWN), NotificationType.ALERT); + long myPartsWithReceivedInvestigations = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.OWN), NotificationType.INVESTIGATION); - long supplierPartsWithOpenReceivedAlerts = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.SUPPLIER), QualityNotificationType.ALERT); - long supplierPartsWithOpenSentInvestigations = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.SUPPLIER), QualityNotificationType.INVESTIGATION); + long supplierPartsWithOpenReceivedAlerts = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.SUPPLIER), NotificationType.ALERT); + long supplierPartsWithOpenSentInvestigations = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.SUPPLIER), NotificationType.INVESTIGATION); - long customerPartsWithOpenReceivedAlerts = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.CUSTOMER), QualityNotificationType.ALERT); - long customerPartsWithOpenSentInvestigations = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.CUSTOMER), QualityNotificationType.INVESTIGATION); + long customerPartsWithOpenReceivedAlerts = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.CUSTOMER), NotificationType.ALERT); + long customerPartsWithOpenSentInvestigations = notificationRepository.countOpenNotificationsByOwnershipAndNotificationType(List.of(Owner.CUSTOMER), NotificationType.INVESTIGATION); - long receivedActiveInvestigations = notificationRepository.countQualityNotificationEntitiesBySideAndNotificationType(QualityNotificationSide.RECEIVER, QualityNotificationType.INVESTIGATION); - long sentActiveInvestigations = notificationRepository.countQualityNotificationEntitiesBySideAndNotificationType(QualityNotificationSide.SENDER, QualityNotificationType.INVESTIGATION); + long receivedActiveInvestigations = notificationRepository.countNotificationsBySideAndType(NotificationSide.RECEIVER, NotificationType.INVESTIGATION); + long sentActiveInvestigations = notificationRepository.countNotificationsBySideAndType(NotificationSide.SENDER, NotificationType.INVESTIGATION); - long receivedActiveAlerts = notificationRepository.countQualityNotificationEntitiesBySideAndNotificationType(QualityNotificationSide.RECEIVER, QualityNotificationType.ALERT); - long sentActiveAlerts = notificationRepository.countQualityNotificationEntitiesBySideAndNotificationType(QualityNotificationSide.SENDER, QualityNotificationType.ALERT); + long receivedActiveAlerts = notificationRepository.countNotificationsBySideAndType(NotificationSide.RECEIVER, NotificationType.ALERT); + long sentActiveAlerts = notificationRepository.countNotificationsBySideAndType(NotificationSide.SENDER, NotificationType.ALERT); return Dashboard.builder() .asBuiltCustomerParts(asBuiltCustomerParts) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/model/AssetAsBuiltEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/model/AssetAsBuiltEntity.java index a6dc874181..7e413e8cdc 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/model/AssetAsBuiltEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/model/AssetAsBuiltEntity.java @@ -42,9 +42,9 @@ import org.eclipse.tractusx.traceability.assets.domain.base.model.aspect.DetailAspectModel; import org.eclipse.tractusx.traceability.assets.infrastructure.base.model.AssetBaseEntity; import org.eclipse.tractusx.traceability.assets.infrastructure.base.model.SemanticDataModelEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; import org.eclipse.tractusx.traceability.submodel.infrastructure.model.SubmodelPayloadEntity; import java.time.Instant; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/model/AssetAsBuiltViewEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/model/AssetAsBuiltViewEntity.java index 3f54d749be..1bd4d0aa57 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/model/AssetAsBuiltViewEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/asbuilt/model/AssetAsBuiltViewEntity.java @@ -39,9 +39,9 @@ import org.eclipse.tractusx.traceability.assets.domain.base.model.aspect.DetailAspectModel; import org.eclipse.tractusx.traceability.assets.infrastructure.base.model.AssetBaseEntity; import org.eclipse.tractusx.traceability.assets.infrastructure.base.model.SemanticDataModelEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; import org.springframework.data.annotation.Immutable; import java.time.Instant; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfig.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfig.java index 6b113d08d5..1829b23dd2 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfig.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfig.java @@ -22,10 +22,10 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.traceability.assets.domain.base.PolicyRepository; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractRequest; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.NotificationMethod; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.NotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.contract.EdcNotificationContractService; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractRequest; +import org.eclipse.tractusx.traceability.notification.application.contract.model.NotificationMethod; +import org.eclipse.tractusx.traceability.notification.application.contract.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.contract.EdcNotificationContractService; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.annotation.Profile; import org.springframework.context.event.EventListener; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ErrorHandlingConfig.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ErrorHandlingConfig.java index 58abc3640a..ed7ad91594 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ErrorHandlingConfig.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/config/ErrorHandlingConfig.java @@ -42,17 +42,17 @@ import org.eclipse.tractusx.traceability.common.security.TechnicalUserAuthorizationException; import org.eclipse.tractusx.traceability.contracts.domain.exception.ContractException; import org.eclipse.tractusx.traceability.discovery.infrastructure.exception.DiscoveryFinderException; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractException; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.validation.UpdateQualityNotificationValidationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationNotFoundException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationNotFoundException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationReceiverBpnMismatchException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationStatusTransitionNotAllowed; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationNotSupportedException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationStatusTransitionNotAllowed; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractException; +import org.eclipse.tractusx.traceability.notification.application.notification.validation.UpdateNotificationValidationException; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationNotFoundException; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationNotFoundException; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationReceiverBpnMismatchException; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationStatusTransitionNotAllowed; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationNotSupportedException; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationStatusTransitionNotAllowed; import org.eclipse.tractusx.traceability.submodel.domain.model.SubmodelNotFoundException; import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.http.HttpStatus; @@ -250,9 +250,9 @@ ResponseEntity handleNotificationStatusTransitionNotAllowed(Notif .body(new ErrorResponse(exception.getMessage())); } - @ExceptionHandler(UpdateQualityNotificationValidationException.class) - ResponseEntity handleUpdateQualityNotificationValidationException(UpdateQualityNotificationValidationException exception) { - log.warn("handleUpdateQualityNotificationValidationException", exception); + @ExceptionHandler(UpdateNotificationValidationException.class) + ResponseEntity handleUpdateNotificationValidationException(UpdateNotificationValidationException exception) { + log.warn("handleUpdateNotificationValidationException", exception); return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(new ErrorResponse(exception.getMessage())); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/QualityNotificationMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapper.java similarity index 60% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/QualityNotificationMapper.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapper.java index 393706d11f..381417b75c 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/QualityNotificationMapper.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapper.java @@ -22,12 +22,12 @@ import lombok.RequiredArgsConstructor; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; import org.springframework.stereotype.Component; import java.time.Instant; @@ -36,26 +36,26 @@ @RequiredArgsConstructor @Component -public class QualityNotificationMapper { +public class NotificationMapper { /** - * Creates an QualityNotification object representing the notification received by the receiver for a given notification. + * Creates an Notification object representing the notification received by the receiver for a given notification. * * @param bpn the BPN of the notification * @param description the description of the notification * @param notification the notification associated with the alert or investigation - * @return an QualityNotification object representing the notification received by the receiver + * @return an Notification object representing the notification received by the receiver */ - public QualityNotification toQualityNotification(BPN bpn, String description, QualityNotificationMessage notification, QualityNotificationType notificationType) { + public Notification toNotification(BPN bpn, String description, NotificationMessage notification, NotificationType notificationType) { List assetIds = new ArrayList<>(); notification.getAffectedParts().stream() - .map(QualityNotificationAffectedPart::assetId) + .map(NotificationAffectedPart::assetId) .forEach(assetIds::add); - return QualityNotification.builder() + return Notification.builder() .bpn(bpn) - .notificationStatus(QualityNotificationStatus.RECEIVED) - .notificationSide(QualityNotificationSide.RECEIVER) + .notificationStatus(NotificationStatus.RECEIVED) + .notificationSide(NotificationSide.RECEIVER) .notificationType(notificationType) .description(description) .createdAt(Instant.now()) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMessageMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMessageMapper.java index ef15863a52..abda31df0b 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMessageMapper.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMessageMapper.java @@ -22,10 +22,10 @@ import lombok.RequiredArgsConstructor; import org.eclipse.tractusx.traceability.bpn.domain.service.BpnRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; import org.springframework.stereotype.Component; import java.time.LocalDateTime; @@ -33,7 +33,7 @@ @Component @RequiredArgsConstructor -public class NotificationMessageMapper { // rename to QualityNotificationMessageMapper +public class NotificationMessageMapper { private final BpnRepository bpnRepository; @@ -43,9 +43,9 @@ public class NotificationMessageMapper { // rename to QualityNotificationMessage * @param edcNotification the EDCNotification received by the receiver * @return a Notification object representing the notification received by the receiver */ - public QualityNotificationMessage toNotification(EDCNotification edcNotification, QualityNotificationType type) { + public NotificationMessage toNotification(EDCNotification edcNotification, NotificationType type) { String notificationId = UUID.randomUUID().toString(); - return QualityNotificationMessage.builder() + return NotificationMessage.builder() .id(notificationId) .created(LocalDateTime.now()) .notificationReferenceId(edcNotification.getNotificationId()) @@ -58,7 +58,7 @@ public QualityNotificationMessage toNotification(EDCNotification edcNotification .notificationStatus(edcNotification.convertNotificationStatus()) .affectedParts(edcNotification.getListOfAffectedItems()) .targetDate(edcNotification.getTargetDate()) - .severity(QualityNotificationSeverity.fromString(edcNotification.getSeverity())) + .severity(NotificationSeverity.fromString(edcNotification.getSeverity())) .edcNotificationId(edcNotification.getNotificationId()) .messageId(edcNotification.getMessageId()) .build(); diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/model/SecurityUtils.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/model/SecurityUtils.java index 239d96777a..df8603ec3e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/model/SecurityUtils.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/model/SecurityUtils.java @@ -21,12 +21,12 @@ import lombok.experimental.UtilityClass; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationContent; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationHeader; -import qualitynotification.base.request.CloseQualityNotificationRequest; -import qualitynotification.base.request.StartQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationRequest; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationContent; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationHeader; +import notification.request.CloseNotificationRequest; +import notification.request.StartNotificationRequest; +import notification.request.UpdateNotificationRequest; import java.util.List; @@ -52,11 +52,11 @@ public static List sanitize(List unSanitizedList) { return null; } - public static StartQualityNotificationRequest sanitize(StartQualityNotificationRequest request) { + public static StartNotificationRequest sanitize(StartNotificationRequest request) { String cleanDescription = sanitize(request.getDescription()); String cleanReceiverBpn = sanitize(request.getReceiverBpn()); List cleanPartIds = sanitize(request.getPartIds()); - return StartQualityNotificationRequest.builder() + return StartNotificationRequest.builder() .description(cleanDescription) .targetDate(request.getTargetDate()) .severity(request.getSeverity()) @@ -68,14 +68,14 @@ public static StartQualityNotificationRequest sanitize(StartQualityNotificationR } - public static CloseQualityNotificationRequest sanitize(CloseQualityNotificationRequest closeInvestigationRequest) { + public static CloseNotificationRequest sanitize(CloseNotificationRequest closeInvestigationRequest) { String cleanReason = sanitize(closeInvestigationRequest.getReason()); - return CloseQualityNotificationRequest.builder().reason(cleanReason).build(); + return CloseNotificationRequest.builder().reason(cleanReason).build(); } - public static UpdateQualityNotificationRequest sanitize(UpdateQualityNotificationRequest updateInvestigationRequest) { + public static UpdateNotificationRequest sanitize(UpdateNotificationRequest updateInvestigationRequest) { String cleanReason = sanitize(updateInvestigationRequest.getReason()); - return UpdateQualityNotificationRequest.builder().status(updateInvestigationRequest.getStatus()).reason(cleanReason).build(); + return UpdateNotificationRequest.builder().status(updateInvestigationRequest.getStatus()).reason(cleanReason).build(); } public static EDCNotification sanitize(EDCNotification edcNotification) { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/repository/CriteriaUtility.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/repository/CriteriaUtility.java index 2f2917d1d7..29f2e5196d 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/repository/CriteriaUtility.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/common/repository/CriteriaUtility.java @@ -29,7 +29,7 @@ import jakarta.persistence.criteria.Root; import lombok.experimental.UtilityClass; import org.eclipse.tractusx.traceability.assets.domain.base.model.Owner; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; import java.util.ArrayList; import java.util.List; @@ -78,7 +78,7 @@ public List getDistinctNotificationFieldValues( String fieldName, String startWith, Integer resultLimit, - QualityNotificationSide side, + NotificationSide side, Class notificationEntityClass, EntityManager entityManager) { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/EdcNotificationContractController.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/EdcNotificationContractController.java similarity index 92% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/EdcNotificationContractController.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/EdcNotificationContractController.java index c055eea661..1a22453285 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/EdcNotificationContractController.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/EdcNotificationContractController.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.contract; +package org.eclipse.tractusx.traceability.notification.application.contract; import assets.importpoc.ErrorResponse; import io.swagger.v3.oas.annotations.Operation; @@ -30,9 +30,9 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractRequest; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractResponse; -import org.eclipse.tractusx.traceability.qualitynotification.domain.contract.EdcNotificationContractService; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractRequest; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractResponse; +import org.eclipse.tractusx.traceability.notification.domain.contract.EdcNotificationContractService; import org.springframework.http.HttpStatus; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractException.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractException.java index 37dae33eac..b43773512e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractException.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.contract.model; +package org.eclipse.tractusx.traceability.notification.application.contract.model; public class CreateNotificationContractException extends RuntimeException { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractRequest.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractRequest.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractRequest.java index ff17a901dc..aade5de9d7 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractRequest.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractRequest.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.contract.model; +package org.eclipse.tractusx.traceability.notification.application.contract.model; import jakarta.validation.constraints.NotNull; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractResponse.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractResponse.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractResponse.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractResponse.java index 30e3908b7f..f80ce2f296 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/CreateNotificationContractResponse.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/CreateNotificationContractResponse.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.contract.model; +package org.eclipse.tractusx.traceability.notification.application.contract.model; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/NotificationMethod.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/NotificationMethod.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/NotificationMethod.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/NotificationMethod.java index 55ea01ecef..601a7b2bdb 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/NotificationMethod.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/NotificationMethod.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.contract.model; +package org.eclipse.tractusx.traceability.notification.application.contract.model; public enum NotificationMethod { RECEIVE("receive"), diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/NotificationType.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/NotificationType.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/NotificationType.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/NotificationType.java index 61f4850ce2..19bf393ce9 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/contract/model/NotificationType.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/contract/model/NotificationType.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.contract.model; +package org.eclipse.tractusx.traceability.notification.application.contract.model; public enum NotificationType { QUALITY_INVESTIGATION("qualityinvestigation"), diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/QualityNotificationFieldMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationFieldMapper.java similarity index 92% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/QualityNotificationFieldMapper.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationFieldMapper.java index 6bcba53c18..e1ac3d4680 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/QualityNotificationFieldMapper.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationFieldMapper.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.notification.mapper; +package org.eclipse.tractusx.traceability.notification.application.notification.mapper; import org.eclipse.tractusx.traceability.common.model.BaseRequestFieldMapper; import org.springframework.stereotype.Component; @@ -25,7 +25,7 @@ import java.util.Map; @Component -public class QualityNotificationFieldMapper extends BaseRequestFieldMapper { +public class NotificationFieldMapper extends BaseRequestFieldMapper { private static final Map SUPPORTED_NOTIFICATION_FILTER_FIELDS = Map.ofEntries( Map.entry("id", "id"), diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationMessageMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationMessageMapper.java new file mode 100644 index 0000000000..f1fb5e0918 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationMessageMapper.java @@ -0,0 +1,84 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.traceability.notification.application.notification.mapper; + +import lombok.experimental.UtilityClass; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import notification.response.NotificationMessageResponse; +import notification.response.NotificationSeverityResponse; +import notification.response.NotificationSideResponse; +import notification.response.NotificationStatusResponse; +import notification.response.NotificationTypeResponse; + +import java.util.List; + +@UtilityClass +public class NotificationMessageMapper { + + public static NotificationSeverityResponse from(NotificationSeverity notificationSeverity) { + return NotificationSeverityResponse.fromString(notificationSeverity.getRealName()); + } + + public static NotificationSideResponse from(NotificationSide side) { + return NotificationSideResponse.valueOf(side.name()); + } + + public static NotificationStatusResponse from(NotificationStatus notificationStatus) { + return NotificationStatusResponse.fromStringValue(notificationStatus.name()); + } + + public static NotificationTypeResponse from(NotificationType notificationType) { + return NotificationTypeResponse.valueOf(notificationType.name()); + } + + public static List fromNotifications(List notificationMessages) { + return notificationMessages.stream().map(NotificationMessageMapper::fromNotification).toList(); + } + + public static NotificationMessageResponse fromNotification(NotificationMessage notificationMessage) { + return NotificationMessageResponse + .builder() + .id(notificationMessage.getId()) + .severity(notificationMessage.getSeverity() != null ? NotificationSeverityResponse.fromString(notificationMessage.getSeverity().getRealName()) : null) + .notificationReferenceId(notificationMessage.getNotificationReferenceId()) + .edcNotificationId(notificationMessage.getEdcNotificationId()) + .contractAgreementId(notificationMessage.getContractAgreementId()) + .notificationReferenceId(notificationMessage.getNotificationReferenceId()) + .messageId(notificationMessage.getMessageId()) + .updated(notificationMessage.getUpdated()) + .sendToName(notificationMessage.getSendToName()) + .status(fromStatus(notificationMessage.getNotificationStatus())) + .targetDate(notificationMessage.getTargetDate()) + .created(notificationMessage.getCreated()) + .createdBy(notificationMessage.getCreatedBy()) + .createdByName(notificationMessage.getCreatedByName()) + .sendTo(notificationMessage.getSendTo()) + .errorMessage(notificationMessage.getErrorMessage()) + .build(); + } + + public static NotificationStatusResponse fromStatus(NotificationStatus notificationStatus) { + return NotificationStatusResponse.fromStringValue(notificationStatus.name()); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationResponseMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationResponseMapper.java new file mode 100644 index 0000000000..78fb1bfb73 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/mapper/NotificationResponseMapper.java @@ -0,0 +1,106 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.traceability.notification.application.notification.mapper; + +import lombok.experimental.UtilityClass; +import org.eclipse.tractusx.traceability.common.model.PageResult; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import notification.response.NotificationReasonResponse; +import notification.response.NotificationResponse; + +import java.time.Instant; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import static org.eclipse.tractusx.traceability.notification.application.notification.mapper.NotificationMessageMapper.fromNotifications; + +@UtilityClass +public class NotificationResponseMapper { + + public static NotificationResponse from(Notification notification) { + return NotificationResponse + .builder() + .id(notification.getNotificationId().value()) + .status(NotificationMessageMapper.from(notification.getNotificationStatus())) + .description(notification.getDescription()) + .createdBy(getSenderBPN(notification.getNotifications())) + .createdByName(getSenderName(notification.getNotifications())) + .createdDate(notification.getCreatedAt().toString()) + .assetIds(Collections.unmodifiableList(notification.getAssetIds())) + .channel(NotificationMessageMapper.from(notification.getNotificationSide())) + .type(NotificationMessageMapper.from(notification.getNotificationType())) + .reason(new NotificationReasonResponse( + notification.getCloseReason(), + notification.getAcceptReason(), + notification.getDeclineReason() + )) + .sendTo(getReceiverBPN(notification.getNotifications())) + .sendToName(getReceiverName(notification.getNotifications())) + .severity(NotificationMessageMapper.from(notification.getNotifications().stream().findFirst().map(NotificationMessage::getSeverity).orElse(NotificationSeverity.MINOR))) + .targetDate(notification.getNotifications().stream().findFirst().map(NotificationMessage::getTargetDate).map(Instant::toString).orElse(null)) + .messages(fromNotifications(notification.getNotifications())) + .build(); + } + + public static PageResult fromAsPageResult(PageResult notificationPageResult) { + List investigationResponses = notificationPageResult.content().stream().map(NotificationResponseMapper::from).toList(); + int pageNumber = notificationPageResult.page(); + int pageSize = notificationPageResult.pageSize(); + Pageable pageable = PageRequest.of(pageNumber, pageSize); + + Page investigationDataPage = new PageImpl<>(investigationResponses, pageable, notificationPageResult.totalItems()); + return new PageResult<>(investigationDataPage); + } + + private static String getSenderBPN(Collection notifications) { + return notifications.stream() + .findFirst() + .map(NotificationMessage::getCreatedBy) + .orElse(null); + } + + private static String getReceiverBPN(Collection notifications) { + return notifications.stream() + .findFirst() + .map(NotificationMessage::getSendTo) + .orElse(null); + } + + private static String getSenderName(Collection notifications) { + return notifications.stream() + .findFirst() + .map(NotificationMessage::getCreatedByName) + .orElse(null); + } + + private static String getReceiverName(Collection notifications) { + return notifications.stream() + .findFirst() + .map(NotificationMessage::getSendToName) + .orElse(null); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/rest/NotificationController.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/rest/NotificationController.java similarity index 89% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/rest/NotificationController.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/rest/NotificationController.java index e1ae35e7cb..1bcc129bc2 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/rest/NotificationController.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/rest/NotificationController.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.notification.rest; +package org.eclipse.tractusx.traceability.notification.application.notification.rest; import assets.importpoc.ErrorResponse; import io.swagger.annotations.ApiParam; @@ -36,11 +36,11 @@ import org.eclipse.tractusx.traceability.common.model.PageResult; import org.eclipse.tractusx.traceability.common.request.OwnPageable; import org.eclipse.tractusx.traceability.common.request.PageableFilterRequest; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.mapper.NotificationResponseMapper; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.mapper.QualityNotificationFieldMapper; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.service.QualityNotificationService; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.application.notification.mapper.NotificationResponseMapper; +import org.eclipse.tractusx.traceability.notification.application.notification.mapper.NotificationFieldMapper; +import org.eclipse.tractusx.traceability.notification.application.notification.service.NotificationService; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.security.access.prepost.PreAuthorize; @@ -52,18 +52,18 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import qualitynotification.base.request.CloseQualityNotificationRequest; -import qualitynotification.base.request.QualityNotificationStatusRequest; -import qualitynotification.base.request.StartQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationRequest; -import qualitynotification.base.response.QualityNotificationIdResponse; -import qualitynotification.base.response.QualityNotificationResponse; +import notification.request.CloseNotificationRequest; +import notification.request.NotificationStatusRequest; +import notification.request.StartNotificationRequest; +import notification.request.UpdateNotificationRequest; +import notification.response.NotificationIdResponse; +import notification.response.NotificationResponse; import java.util.List; import static org.eclipse.tractusx.traceability.common.model.SecurityUtils.sanitize; -import static org.eclipse.tractusx.traceability.qualitynotification.application.notification.validation.UpdateQualityNotificationValidator.validate; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.notification.model.StartQualityNotification.from; +import static org.eclipse.tractusx.traceability.notification.application.notification.validation.UpdateNotificationValidator.validate; +import static org.eclipse.tractusx.traceability.notification.domain.notification.model.StartNotification.from; @RestController @RequestMapping(value = "/notifications", consumes = "application/json", produces = "application/json") @@ -74,13 +74,13 @@ public class NotificationController { private static final String RECEIVED_API_CALL_LOG = "Received API call on /notifications"; - private final QualityNotificationService notificationService; + private final NotificationService notificationService; private final BaseRequestFieldMapper fieldMapper; public NotificationController( - @Qualifier("notificationServiceImpl") QualityNotificationService notificationService, - QualityNotificationFieldMapper fieldMapper) { + @Qualifier("notificationServiceImpl") NotificationService notificationService, + NotificationFieldMapper fieldMapper) { this.notificationService = notificationService; this.fieldMapper = fieldMapper; } @@ -136,10 +136,10 @@ public NotificationController( @PostMapping @PreAuthorize("hasAnyRole('ROLE_SUPERVISOR', 'ROLE_USER')") @ResponseStatus(HttpStatus.CREATED) - public QualityNotificationIdResponse alertAssets(@RequestBody @Valid StartQualityNotificationRequest request) { - StartQualityNotificationRequest cleanStartQualityNotificationRequest = sanitize(request); - log.info(RECEIVED_API_CALL_LOG + " with params: {}", cleanStartQualityNotificationRequest); - return new QualityNotificationIdResponse(notificationService.start(from(cleanStartQualityNotificationRequest)).value()); + public NotificationIdResponse alertAssets(@RequestBody @Valid StartNotificationRequest request) { + StartNotificationRequest cleanStartNotificationRequest = sanitize(request); + log.info(RECEIVED_API_CALL_LOG + " with params: {}", cleanStartNotificationRequest); + return new NotificationIdResponse(notificationService.start(from(cleanStartNotificationRequest)).value()); } @Operation(operationId = "filterNotifications", @@ -149,8 +149,8 @@ public QualityNotificationIdResponse alertAssets(@RequestBody @Valid StartQualit security = @SecurityRequirement(name = "oAuth2", scopes = "profile email")) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Returns the paged result found for Notifications", content = @Content( mediaType = "application/json", - array = @ArraySchema(arraySchema = @Schema(description = "AlertData", implementation = QualityNotificationResponse.class, additionalProperties = Schema.AdditionalPropertiesValue.FALSE), maxItems = Integer.MAX_VALUE), - schema = @Schema(implementation = QualityNotificationResponse.class) + array = @ArraySchema(arraySchema = @Schema(description = "AlertData", implementation = NotificationResponse.class, additionalProperties = Schema.AdditionalPropertiesValue.FALSE), maxItems = Integer.MAX_VALUE), + schema = @Schema(implementation = NotificationResponse.class) )), @ApiResponse( responseCode = "400", @@ -197,7 +197,7 @@ public QualityNotificationIdResponse alertAssets(@RequestBody @Valid StartQualit mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class)))}) @PostMapping("/filter") - public PageResult getAlerts(@Valid @RequestBody PageableFilterRequest pageableFilterRequest) { + public PageResult getAlerts(@Valid @RequestBody PageableFilterRequest pageableFilterRequest) { log.info(RECEIVED_API_CALL_LOG + "/filter"); return NotificationResponseMapper.fromAsPageResult( @@ -257,7 +257,7 @@ public PageResult getAlerts(@Valid @RequestBody Pag mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class)))}) @GetMapping("/{notificationId}") - public QualityNotificationResponse getAlert(@PathVariable("notificationId") Long notificationId) { + public NotificationResponse getAlert(@PathVariable("notificationId") Long notificationId) { log.info(RECEIVED_API_CALL_LOG + "/{}", notificationId); return NotificationResponseMapper.from(notificationService.find(notificationId)); } @@ -451,10 +451,10 @@ public void cancelAlert(@PathVariable("notificationId") Long notificationId) { @ResponseStatus(HttpStatus.NO_CONTENT) public void closeAlert( @PathVariable("notificationId") @ApiParam Long notificationId, - @Valid @RequestBody CloseQualityNotificationRequest closeAlertRequest) { - CloseQualityNotificationRequest cleanCloseAlertRequest = sanitize(closeAlertRequest); + @Valid @RequestBody CloseNotificationRequest closeAlertRequest) { + CloseNotificationRequest cleanCloseAlertRequest = sanitize(closeAlertRequest); log.info(RECEIVED_API_CALL_LOG + "/{}/close with params {}", notificationId, cleanCloseAlertRequest); - notificationService.update(notificationId, QualityNotificationStatus.from(QualityNotificationStatusRequest.CLOSED), cleanCloseAlertRequest.getReason()); + notificationService.update(notificationId, NotificationStatus.from(NotificationStatusRequest.CLOSED), cleanCloseAlertRequest.getReason()); } @Operation(operationId = "updateNotification", @@ -515,11 +515,11 @@ public void closeAlert( @ResponseStatus(HttpStatus.NO_CONTENT) public void updateAlert( @PathVariable("notificationId") Long notificationId, - @Valid @RequestBody UpdateQualityNotificationRequest updateAlertRequest) { - UpdateQualityNotificationRequest cleanUpdateAlertRequest = sanitize(updateAlertRequest); + @Valid @RequestBody UpdateNotificationRequest updateAlertRequest) { + UpdateNotificationRequest cleanUpdateAlertRequest = sanitize(updateAlertRequest); validate(cleanUpdateAlertRequest); log.info(RECEIVED_API_CALL_LOG + "/{}/update with params {}", notificationId, cleanUpdateAlertRequest); - notificationService.update(notificationId, QualityNotificationStatus.from(cleanUpdateAlertRequest.getStatus()), cleanUpdateAlertRequest.getReason()); + notificationService.update(notificationId, NotificationStatus.from(cleanUpdateAlertRequest.getStatus()), cleanUpdateAlertRequest.getReason()); } @Operation(operationId = "distinctFilterValues", @@ -582,7 +582,7 @@ public void updateAlert( mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class)))}) @GetMapping("distinctFilterValues") - public List distinctFilterValues(@QueryParam("fieldName") String fieldName, @QueryParam("size") Integer size, @QueryParam("startWith") String startWith, @QueryParam("channel") QualityNotificationSide channel) { + public List distinctFilterValues(@QueryParam("fieldName") String fieldName, @QueryParam("size") Integer size, @QueryParam("startWith") String startWith, @QueryParam("channel") NotificationSide channel) { return notificationService.getDistinctFilterValues(fieldMapper.mapRequestFieldName(fieldName), startWith, size, channel); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/service/QualityNotificationService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/service/NotificationService.java similarity index 50% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/service/QualityNotificationService.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/service/NotificationService.java index 7c20ef440b..0bb73038b9 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/service/QualityNotificationService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/service/NotificationService.java @@ -16,36 +16,36 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.notification.service; +package org.eclipse.tractusx.traceability.notification.application.notification.service; import org.eclipse.tractusx.traceability.common.model.PageResult; import org.eclipse.tractusx.traceability.common.model.SearchCriteria; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.model.StartQualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.notification.model.StartNotification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import org.springframework.data.domain.Pageable; import java.util.List; -public interface QualityNotificationService { +public interface NotificationService { - QualityNotificationId start(StartQualityNotification startQualityNotification); + NotificationId start(StartNotification startNotification); - QualityNotification find(Long notificationId); + Notification find(Long notificationId); - QualityNotification loadOrNotFoundException(QualityNotificationId notificationId); + Notification loadOrNotFoundException(NotificationId notificationId); - QualityNotification loadByEdcNotificationIdOrNotFoundException(String edcNotificationId); + Notification loadByEdcNotificationIdOrNotFoundException(String edcNotificationId); void approve(Long notificationId); void cancel(Long notificationId); - void update(Long notificationId, QualityNotificationStatus notificationStatus, String reason); + void update(Long notificationId, NotificationStatus notificationStatus, String reason); - PageResult getNotifications(Pageable pageable, SearchCriteria searchCriteria); + PageResult getNotifications(Pageable pageable, SearchCriteria searchCriteria); - List getDistinctFilterValues(String fieldName, String startWith, Integer size, QualityNotificationSide side); + List getDistinctFilterValues(String fieldName, String startWith, Integer size, NotificationSide side); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/validation/UpdateQualityNotificationValidationException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/validation/UpdateNotificationValidationException.java similarity index 80% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/validation/UpdateQualityNotificationValidationException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/validation/UpdateNotificationValidationException.java index b55fbde563..ec4d3d03d6 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/validation/UpdateQualityNotificationValidationException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/validation/UpdateNotificationValidationException.java @@ -19,11 +19,11 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.notification.validation; +package org.eclipse.tractusx.traceability.notification.application.notification.validation; -public class UpdateQualityNotificationValidationException extends RuntimeException { +public class UpdateNotificationValidationException extends RuntimeException { - public UpdateQualityNotificationValidationException(String message) { + public UpdateNotificationValidationException(String message) { super(message); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/validation/UpdateNotificationValidator.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/validation/UpdateNotificationValidator.java new file mode 100644 index 0000000000..c2e2849084 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/application/notification/validation/UpdateNotificationValidator.java @@ -0,0 +1,66 @@ +/******************************************************************************** + * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2022, 2023 ZF Friedrichshafen AG + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.traceability.notification.application.notification.validation; + +import lombok.experimental.UtilityClass; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import notification.request.UpdateNotificationRequest; + +import java.util.Set; + +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.ACCEPTED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.ACKNOWLEDGED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.DECLINED; + +@UtilityClass +public class UpdateNotificationValidator { + + private static final Set ALLOWED_STATUSES = Set.of(ACKNOWLEDGED, ACCEPTED, DECLINED); + + private static final int MINIMUM_REASON_CHARACTERS_SIZE = 15; + private static final int MAXIMUM_REASON_CHARACTERS_SIZE = 1000; + + public static void validate(UpdateNotificationRequest updateInvestigationRequest) { + NotificationStatus status = NotificationStatus.fromStringValue(updateInvestigationRequest.getStatus().name()); + + if (!ALLOWED_STATUSES.contains(status)) { + throw new UpdateNotificationValidationException("%s not allowed for update investigation with".formatted(status)); + } + + String reason = updateInvestigationRequest.getReason(); + + if (status == ACKNOWLEDGED && (reason != null && !reason.isBlank())) { + throw new UpdateNotificationValidationException("Update investigation reason can't be present for %s status".formatted(ACKNOWLEDGED)); + + } + + if (status != ACKNOWLEDGED) { + if (reason == null || reason.isBlank()) { + throw new UpdateNotificationValidationException("Update investigation reason must be present"); + } + + if (reason.length() < MINIMUM_REASON_CHARACTERS_SIZE || reason.length() > MAXIMUM_REASON_CHARACTERS_SIZE) { + throw new UpdateNotificationValidationException("Reason should have at least %d characters and at most %d characters".formatted(MINIMUM_REASON_CHARACTERS_SIZE, MAXIMUM_REASON_CHARACTERS_SIZE)); + } + } + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/BadRequestException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/BadRequestException.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/BadRequestException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/BadRequestException.java index 467a3959ea..d88f4ea21b 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/BadRequestException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/BadRequestException.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception; +package org.eclipse.tractusx.traceability.notification.domain.base.exception; public class BadRequestException extends RuntimeException { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/ContractNegotiationException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/ContractNegotiationException.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/ContractNegotiationException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/ContractNegotiationException.java index 5259663d00..d1eac30166 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/ContractNegotiationException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/ContractNegotiationException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception; +package org.eclipse.tractusx.traceability.notification.domain.base.exception; public class ContractNegotiationException extends RuntimeException { public ContractNegotiationException(final String message, final Throwable exception) { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/NoCatalogItemException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/NoCatalogItemException.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/NoCatalogItemException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/NoCatalogItemException.java index 9a80a84ab3..45cd3b50c2 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/NoCatalogItemException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/NoCatalogItemException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception; +package org.eclipse.tractusx.traceability.notification.domain.base.exception; public class NoCatalogItemException extends RuntimeException { public static final String MESSAGE = "No Catalog Item in catalog found."; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/NoEndpointDataReferenceException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/NoEndpointDataReferenceException.java similarity index 92% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/NoEndpointDataReferenceException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/NoEndpointDataReferenceException.java index 1bf205e080..0d8019b52e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/NoEndpointDataReferenceException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/NoEndpointDataReferenceException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception; +package org.eclipse.tractusx.traceability.notification.domain.base.exception; public class NoEndpointDataReferenceException extends RuntimeException { public NoEndpointDataReferenceException(String message) { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/SendNotificationException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/SendNotificationException.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/SendNotificationException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/SendNotificationException.java index e2fc4c2112..1f2a1d3277 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/exception/SendNotificationException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/exception/SendNotificationException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception; +package org.eclipse.tractusx.traceability.notification.domain.base.exception; public class SendNotificationException extends RuntimeException { public SendNotificationException(final String message, final Throwable exception) { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/Notification.java similarity index 66% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotification.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/Notification.java index b5c4d267f6..8c84c78fb3 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotification.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/Notification.java @@ -16,15 +16,15 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; +package org.eclipse.tractusx.traceability.notification.domain.base.model; import lombok.Builder; import lombok.Data; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationStatusTransitionNotAllowed; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationStatusTransitionNotAllowed; import java.time.Instant; import java.util.ArrayList; @@ -36,15 +36,15 @@ @Data @Builder(toBuilder = true) @Slf4j -public class QualityNotification { +public class Notification { private String title; private BPN bpn; - private QualityNotificationId notificationId; - private QualityNotificationStatus notificationStatus; + private NotificationId notificationId; + private NotificationStatus notificationStatus; private String description; private Instant createdAt; - private QualityNotificationSide notificationSide; - private QualityNotificationType notificationType; + private NotificationSide notificationSide; + private NotificationType notificationType; @Builder.Default private List assetIds = new ArrayList<>(); private String closeReason; @@ -52,15 +52,15 @@ public class QualityNotification { private String declineReason; @Getter @Builder.Default - private List notifications = List.of(); + private List notifications = List.of(); - public static QualityNotification startNotification(String title, Instant createDate, BPN bpn, String description, QualityNotificationType notificationType) { - return QualityNotification.builder() + public static Notification startNotification(String title, Instant createDate, BPN bpn, String description, NotificationType notificationType) { + return Notification.builder() .title(title) .bpn(bpn) - .notificationStatus(QualityNotificationStatus.CREATED) - .notificationSide(QualityNotificationSide.SENDER) + .notificationStatus(NotificationStatus.CREATED) + .notificationSide(NotificationSide.SENDER) .notificationType(notificationType) .description(description) .createdAt(createDate) @@ -78,39 +78,39 @@ public String getBpn() { public void cancel(BPN applicationBpn) { validateBPN(applicationBpn); - changeStatusTo(QualityNotificationStatus.CANCELED); + changeStatusTo(NotificationStatus.CANCELED); this.closeReason = "canceled"; } public void close(BPN applicationBpn, String reason) { validateBPN(applicationBpn); - changeStatusTo(QualityNotificationStatus.CLOSED); + changeStatusTo(NotificationStatus.CLOSED); this.closeReason = reason; this.notifications.forEach(notification -> notification.setDescription(reason)); } public void acknowledge() { - changeStatusTo(QualityNotificationStatus.ACKNOWLEDGED); + changeStatusTo(NotificationStatus.ACKNOWLEDGED); } public void accept(String reason) { - changeStatusTo(QualityNotificationStatus.ACCEPTED); + changeStatusTo(NotificationStatus.ACCEPTED); this.acceptReason = reason; } public void decline(String reason) { - changeStatusTo(QualityNotificationStatus.DECLINED); + changeStatusTo(NotificationStatus.DECLINED); this.declineReason = reason; } public void close(String reason) { - changeStatusTo(QualityNotificationStatus.CLOSED); + changeStatusTo(NotificationStatus.CLOSED); this.closeReason = reason; } public void send(BPN applicationBpn) { validateBPN(applicationBpn); - changeStatusTo(QualityNotificationStatus.SENT); + changeStatusTo(NotificationStatus.SENT); } private void validateBPN(BPN applicationBpn) { @@ -119,7 +119,7 @@ private void validateBPN(BPN applicationBpn) { } } - private void changeStatusTo(QualityNotificationStatus to) { + private void changeStatusTo(NotificationStatus to) { boolean transitionAllowed = notificationStatus.transitionAllowed(to); if (!transitionAllowed) { @@ -128,41 +128,41 @@ private void changeStatusTo(QualityNotificationStatus to) { this.notificationStatus = to; } - public void addNotification(QualityNotificationMessage notification) { + public void addNotificationMessage(NotificationMessage notification) { - List updatedNotifications = new ArrayList<>(notifications); + List updatedNotifications = new ArrayList<>(notifications); updatedNotifications.add(notification); notifications = Collections.unmodifiableList(updatedNotifications); List newAssetIds = new ArrayList<>(assetIds); // create a mutable copy of assetIds notification.getAffectedParts().stream() - .map(QualityNotificationAffectedPart::assetId) + .map(NotificationAffectedPart::assetId) .forEach(newAssetIds::add); assetIds = Collections.unmodifiableList(newAssetIds); // } - public void addNotifications(List notificationMessages) { - notificationMessages.forEach(this::addNotification); + public void addNotificationMessages(List notificationMessages) { + notificationMessages.forEach(this::addNotificationMessage); } public boolean isActiveState() { return this.notificationStatus.isActiveState(); } - public List secondLatestNotifications() { + public List secondLatestNotifications() { - Optional highestState = notifications.stream() - .max(Comparator.comparing(QualityNotificationMessage::getCreated)); + Optional highestState = notifications.stream() + .max(Comparator.comparing(NotificationMessage::getCreated)); if (highestState.isPresent()) { - QualityNotificationMessage highestMessage = highestState.get(); - QualityNotificationStatus highestStatus = highestMessage.getNotificationStatus(); + NotificationMessage highestMessage = highestState.get(); + NotificationStatus highestStatus = highestMessage.getNotificationStatus(); log.info("Highest status found: {}", highestStatus); - Optional secondHighestState = notifications.stream() + Optional secondHighestState = notifications.stream() .filter(message -> !message.getNotificationStatus().equals(highestStatus)) - .max(Comparator.comparing(QualityNotificationMessage::getCreated)); + .max(Comparator.comparing(NotificationMessage::getCreated)); if (secondHighestState.isPresent()) { log.info("Second highest status found: {}", secondHighestState.get().getNotificationStatus()); diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationAffectedPart.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationAffectedPart.java similarity index 87% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationAffectedPart.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationAffectedPart.java index 82a54f5c48..a2ede63511 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationAffectedPart.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationAffectedPart.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; +package org.eclipse.tractusx.traceability.notification.domain.base.model; -public record QualityNotificationAffectedPart(String assetId) { +public record NotificationAffectedPart(String assetId) { } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationId.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationId.java similarity index 87% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationId.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationId.java index 0511a52bd3..9c54a5dfa2 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationId.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationId.java @@ -19,13 +19,13 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; +package org.eclipse.tractusx.traceability.notification.domain.base.model; import java.util.Objects; -public record QualityNotificationId(Long value) { +public record NotificationId(Long value) { - public QualityNotificationId { + public NotificationId { if (Objects.isNull(value)) { throw new IllegalArgumentException("Investigation id must be present"); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationMessage.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationMessage.java similarity index 78% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationMessage.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationMessage.java index 2de3522bac..ac1faf0a0c 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationMessage.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationMessage.java @@ -16,7 +16,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; +package org.eclipse.tractusx.traceability.notification.domain.base.model; import lombok.Builder; import lombok.Data; @@ -25,7 +25,7 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.tractusx.traceability.assets.domain.base.model.AssetBase; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationStatusTransitionNotAllowed; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationStatusTransitionNotAllowed; import java.time.Instant; import java.time.LocalDateTime; @@ -38,28 +38,28 @@ @Getter @Setter @Data -public class QualityNotificationMessage { +public class NotificationMessage { private String id; private final String createdByName; private final String sendToName; @Builder.Default - private final List affectedParts = new ArrayList<>(); + private final List affectedParts = new ArrayList<>(); private String notificationReferenceId; private String createdBy; private String sendTo; private String contractAgreementId; private String description; - private QualityNotificationStatus notificationStatus; + private NotificationStatus notificationStatus; private String edcNotificationId; private LocalDateTime created; private LocalDateTime updated; private Instant targetDate; - private QualityNotificationSeverity severity; + private NotificationSeverity severity; private String messageId; - private QualityNotificationType type; + private NotificationType type; private String errorMessage; - public void changeStatusTo(QualityNotificationStatus to) { + public void changeStatusTo(NotificationStatus to) { boolean transitionAllowed = notificationStatus.transitionAllowed(to); if (!transitionAllowed) { @@ -68,10 +68,10 @@ public void changeStatusTo(QualityNotificationStatus to) { this.notificationStatus = to; } - public static QualityNotificationMessage create(BPN applicationBpn, String receiverBpn, String description, Instant targetDate, QualityNotificationSeverity severity, QualityNotificationType notificationType, Map.Entry> asset, String creator, String sendToName) { + public static NotificationMessage create(BPN applicationBpn, String receiverBpn, String description, Instant targetDate, NotificationSeverity severity, NotificationType notificationType, Map.Entry> asset, String creator, String sendToName) { final String notificationId = UUID.randomUUID().toString(); final String messageId = UUID.randomUUID().toString(); - return QualityNotificationMessage.builder() + return NotificationMessage.builder() .id(notificationId) .created(LocalDateTime.now()) .createdBy(applicationBpn.value()) @@ -79,8 +79,8 @@ public static QualityNotificationMessage create(BPN applicationBpn, String recei .sendTo(StringUtils.isBlank(receiverBpn) ? asset.getKey() : receiverBpn) .sendToName(sendToName) .description(description) - .notificationStatus(QualityNotificationStatus.CREATED) - .affectedParts(asset.getValue().stream().map(AssetBase::getId).map(QualityNotificationAffectedPart::new).toList()) + .notificationStatus(NotificationStatus.CREATED) + .affectedParts(asset.getValue().stream().map(AssetBase::getId).map(NotificationAffectedPart::new).toList()) .targetDate(targetDate) .severity(severity) .edcNotificationId(notificationId) @@ -90,7 +90,7 @@ public static QualityNotificationMessage create(BPN applicationBpn, String recei } // Important - receiver and sender will be saved in switched order - public QualityNotificationMessage copyAndSwitchSenderAndReceiver(BPN applicationBpn) { + public NotificationMessage copyAndSwitchSenderAndReceiver(BPN applicationBpn) { final String notificationId = UUID.randomUUID().toString(); final String messageUUID = UUID.randomUUID().toString(); String receiverBPN = sendTo; @@ -108,7 +108,7 @@ public QualityNotificationMessage copyAndSwitchSenderAndReceiver(BPN application receiverName = sendToName; senderName = createdByName; } - return QualityNotificationMessage.builder() + return NotificationMessage.builder() .created(LocalDateTime.now()) .id(notificationId) .createdBy(senderBPN) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationSeverity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationSeverity.java similarity index 66% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationSeverity.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationSeverity.java index d05fc8a9f3..0ac24ad6c1 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationSeverity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationSeverity.java @@ -17,15 +17,15 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; +package org.eclipse.tractusx.traceability.notification.domain.base.model; import io.swagger.annotations.ApiModel; import lombok.Getter; -import qualitynotification.base.request.QualityNotificationSeverityRequest; +import notification.request.NotificationSeverityRequest; @Getter @ApiModel(description = "Describes the criticality of a notification") -public enum QualityNotificationSeverity { +public enum NotificationSeverity { MINOR("MINOR"), MAJOR("MAJOR"), CRITICAL("CRITICAL"), @@ -33,20 +33,20 @@ public enum QualityNotificationSeverity { private final String realName; - QualityNotificationSeverity(String realName) { + NotificationSeverity(String realName) { this.realName = realName; } - public static QualityNotificationSeverity fromString(String str) { - for (QualityNotificationSeverity s : QualityNotificationSeverity.values()) { + public static NotificationSeverity fromString(String str) { + for (NotificationSeverity s : NotificationSeverity.values()) { if (s.realName.equalsIgnoreCase(str)) { return s; } } - throw new IllegalArgumentException("No enum constant " + QualityNotificationSeverity.class.getCanonicalName() + "." + str); + throw new IllegalArgumentException("No enum constant " + NotificationSeverity.class.getCanonicalName() + "." + str); } - public static QualityNotificationSeverity from(QualityNotificationSeverityRequest qualityNotificationSeverityRequest) { - return QualityNotificationSeverity.fromString(qualityNotificationSeverityRequest.getRealName()); + public static NotificationSeverity from(NotificationSeverityRequest notificationSeverityRequest) { + return NotificationSeverity.fromString(notificationSeverityRequest.getRealName()); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationSide.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationSide.java similarity index 88% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationSide.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationSide.java index 409aca5297..327b941f60 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationSide.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationSide.java @@ -17,9 +17,9 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; +package org.eclipse.tractusx.traceability.notification.domain.base.model; -public enum QualityNotificationSide { +public enum NotificationSide { SENDER, RECEIVER } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationStatus.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationStatus.java new file mode 100644 index 0000000000..c05a9ceb44 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationStatus.java @@ -0,0 +1,117 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.traceability.notification.domain.base.model; + +import notification.request.NotificationStatusRequest; +import notification.request.UpdateNotificationStatusRequest; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import static java.util.Collections.emptySet; +import static java.util.Set.of; + +public enum NotificationStatus { + CREATED(NotificationSide.SENDER, emptySet()), + SENT(NotificationSide.SENDER, Set.of(NotificationSide.SENDER)), + RECEIVED(NotificationSide.RECEIVER, emptySet()), + ACKNOWLEDGED(NotificationSide.RECEIVER, Set.of(NotificationSide.RECEIVER, NotificationSide.SENDER)), + ACCEPTED(NotificationSide.RECEIVER, Set.of(NotificationSide.RECEIVER)), + DECLINED(NotificationSide.RECEIVER, Set.of(NotificationSide.RECEIVER)), + CANCELED(NotificationSide.SENDER, Set.of(NotificationSide.SENDER)), + CLOSED(NotificationSide.SENDER, of(NotificationSide.SENDER, NotificationSide.RECEIVER)); + + private static final Map> STATE_MACHINE; + private static final Set NO_TRANSITION_ALLOWED = emptySet(); + private static final Map MAPPINGS; + + public static final List ACTIVE_STATES = List.of(CREATED, SENT, RECEIVED, ACKNOWLEDGED, ACCEPTED, DECLINED); + + static { + STATE_MACHINE = Map.of( + CREATED, of(SENT, CANCELED), + SENT, of(RECEIVED, CLOSED, ACKNOWLEDGED), + RECEIVED, of(ACKNOWLEDGED, CLOSED), + ACKNOWLEDGED, of(DECLINED, ACCEPTED, CLOSED), + ACCEPTED, of(CLOSED), + DECLINED, of(CLOSED), + CLOSED, NO_TRANSITION_ALLOWED, + CANCELED, NO_TRANSITION_ALLOWED + ); + + MAPPINGS = Arrays.stream(NotificationStatus.values()) + .collect(Collectors.toMap(Enum::name, notificationStatus -> notificationStatus)); + } + + private final NotificationSide notificationSide; + private final Set allowedTransitionFromSide; + + NotificationStatus(NotificationSide notificationSide, Set allowedTransitionFromSide) { + this.notificationSide = notificationSide; + this.allowedTransitionFromSide = allowedTransitionFromSide; + } + + public static Optional fromValue(String value) { + return Optional.ofNullable(MAPPINGS.get(value)); + } + + public static NotificationStatus fromStringValue(String value) { + return MAPPINGS.get(value); + } + + public static NotificationStatus getPreviousStatus(NotificationStatus status) { + return switch (status) { + case CREATED, SENT, CANCELED -> NotificationStatus.CREATED; + case ACKNOWLEDGED, RECEIVED, CLOSED -> NotificationStatus.SENT; + case ACCEPTED, DECLINED -> NotificationStatus.ACKNOWLEDGED; + }; + } + public boolean transitionAllowed(NotificationStatus to) { + + Set allowedStatusesToTransition = STATE_MACHINE.get(this); + + if (!allowedStatusesToTransition.contains(to)) { + return false; + } + + return isSideEligibleForTransition(this, to); + } + + private boolean isSideEligibleForTransition(NotificationStatus from, NotificationStatus to) { + return to.allowedTransitionFromSide.contains(from.notificationSide); + } + + public boolean isActiveState() { + return ACTIVE_STATES.contains(this); + } + + + public static NotificationStatus from(NotificationStatusRequest notificationStatusRequest) { + return NotificationStatus.fromStringValue(notificationStatusRequest.name()); + } + + public static NotificationStatus from(UpdateNotificationStatusRequest updateNotificationStatusRequest) { + return NotificationStatus.fromStringValue(updateNotificationStatusRequest.name()); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationType.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationType.java similarity index 65% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationType.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationType.java index a5292d17b0..0abcd2ac9c 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationType.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationType.java @@ -17,30 +17,30 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; +package org.eclipse.tractusx.traceability.notification.domain.base.model; -import qualitynotification.base.request.QualityNotificationTypeRequest; +import notification.request.NotificationTypeRequest; -public enum QualityNotificationType { +public enum NotificationType { ALERT("ALERT"), INVESTIGATION("INVESTIGATION"); private final String realName; - QualityNotificationType(String realName) { + NotificationType(String realName) { this.realName = realName; } - public static QualityNotificationType fromString(String str) { - for (QualityNotificationType s : QualityNotificationType.values()) { + public static NotificationType fromString(String str) { + for (NotificationType s : NotificationType.values()) { if (s.realName.equalsIgnoreCase(str)) { return s; } } - throw new IllegalArgumentException("No enum constant " + QualityNotificationType.class.getCanonicalName() + "." + str); + throw new IllegalArgumentException("No enum constant " + NotificationType.class.getCanonicalName() + "." + str); } - public static QualityNotificationType from(QualityNotificationTypeRequest qualityNotificationTypeRequest) { - return QualityNotificationType.fromString(qualityNotificationTypeRequest.getRealName()); + public static NotificationType from(NotificationTypeRequest notificationTypeRequest) { + return NotificationType.fromString(notificationTypeRequest.getRealName()); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/exception/QualityNotificationIllegalUpdate.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/exception/NotificationIllegalUpdate.java similarity index 80% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/exception/QualityNotificationIllegalUpdate.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/exception/NotificationIllegalUpdate.java index aac9a0013c..1288385760 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/exception/QualityNotificationIllegalUpdate.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/model/exception/NotificationIllegalUpdate.java @@ -17,11 +17,11 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.exception; +package org.eclipse.tractusx.traceability.notification.domain.base.model.exception; -public class QualityNotificationIllegalUpdate extends IllegalArgumentException { +public class NotificationIllegalUpdate extends IllegalArgumentException { - public QualityNotificationIllegalUpdate(String message) { + public NotificationIllegalUpdate(String message) { super(message); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationReceiverService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationReceiverService.java new file mode 100644 index 0000000000..72dd7affe6 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationReceiverService.java @@ -0,0 +1,72 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.traceability.notification.domain.base.service; + +import lombok.extern.slf4j.Slf4j; +import org.eclipse.tractusx.traceability.common.mapper.NotificationMessageMapper; +import org.eclipse.tractusx.traceability.common.mapper.NotificationMapper; +import org.eclipse.tractusx.traceability.common.model.BPN; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; + +@Slf4j +public abstract class AbstractNotificationReceiverService implements NotificationReceiverService { + + protected abstract NotificationRepository getRepository(); + + protected abstract NotificationMessageMapper getNotificationMessageMapper(); + + protected abstract NotificationMapper getNotificationMapper(); + + protected abstract RuntimeException getNotFoundException(String message); + + protected abstract RuntimeException getIllegalUpdateException(String message); + + @Override + public void handleReceive(EDCNotification edcNotification, NotificationType notificationType) { + BPN investigationCreatorBPN = BPN.of(edcNotification.getSenderBPN()); + NotificationMessage notification = getNotificationMessageMapper().toNotification(edcNotification, notificationType); + Notification investigation = getNotificationMapper().toNotification(investigationCreatorBPN, edcNotification.getInformation(), notification, notificationType); + NotificationId investigationId = getRepository().saveNotification(investigation); + log.info("Stored received edcNotification in investigation with id {}", investigationId); + } + + @Override + public void handleUpdate(EDCNotification edcNotification, NotificationType notificationType) { + NotificationMessage notificationMessage = getNotificationMessageMapper().toNotification(edcNotification, notificationType); + Notification notification = getRepository().findByEdcNotificationId(edcNotification.getNotificationId()) + .orElseThrow(() -> getNotFoundException(edcNotification.getNotificationId())); + + switch (edcNotification.convertNotificationStatus()) { + case ACKNOWLEDGED -> notification.acknowledge(); + case ACCEPTED -> notification.accept(edcNotification.getInformation()); + case DECLINED -> notification.decline(edcNotification.getInformation()); + case CLOSED -> + notification.close(BPN.of(notification.getBpn()), edcNotification.getInformation()); + default -> + throw getIllegalUpdateException("Failed to handle notification due to unhandled %s status".formatted(edcNotification.convertNotificationStatus())); + } + notification.addNotificationMessage(notificationMessage); + getRepository().updateNotification(notification); + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationService.java new file mode 100644 index 0000000000..e81db3cab7 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/AbstractNotificationService.java @@ -0,0 +1,183 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.traceability.notification.domain.base.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.eclipse.tractusx.traceability.common.model.PageResult; +import org.eclipse.tractusx.traceability.common.model.SearchCriteria; +import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; +import org.eclipse.tractusx.traceability.notification.application.notification.service.NotificationService; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.model.StartNotification; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; +import org.springframework.data.domain.Pageable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +@RequiredArgsConstructor +@Slf4j +public abstract class AbstractNotificationService implements NotificationService { + + private final TraceabilityProperties traceabilityProperties; + private final NotificationPublisherService notificationPublisherService; + private static final List SUPPORTED_ENUM_FIELDS = List.of("status", "side", "messages_severity", "type"); + + protected abstract NotificationRepository getNotificationRepository(); + + protected abstract RuntimeException getNotFoundException(String message); + + @Override + public PageResult getNotifications(Pageable pageable, SearchCriteria searchCriteria) { + return getNotificationRepository().getNotifications(pageable, searchCriteria); + } + + @Override + public NotificationId start(StartNotification startNotification) { + Notification notification = notificationPublisherService.startNotification(startNotification); + NotificationId createdAlertId = getNotificationRepository().saveNotification(notification); + log.info("Start Quality Notification {}", notification); + return createdAlertId; + } + + @Override + public void update(Long notificationId, NotificationStatus notificationStatus, String reason) { + Notification notification = loadOrNotFoundException(new NotificationId(notificationId)); + + NotificationStatus previousStatus = NotificationStatus.getPreviousStatus(notificationStatus); + + /* Create a copy of the latest notifications. + As per asset there will be a notification created on start + it is possible that several elements with the same previous state are returned.*/ + notification.getNotifications().stream() + .filter(notificationMessage -> notificationMessage.getNotificationStatus().equals(previousStatus)) + .forEach(notificationMessage -> { + NotificationMessage notificationMessageSwitchedSenderAndReceiver = notificationMessage.copyAndSwitchSenderAndReceiver(traceabilityProperties.getBpn()); + notificationMessageSwitchedSenderAndReceiver.setId(UUID.randomUUID().toString()); + notificationMessageSwitchedSenderAndReceiver.changeStatusTo(notificationStatus); + notificationMessageSwitchedSenderAndReceiver.setDescription(reason); + notification.addNotificationMessage(notificationMessageSwitchedSenderAndReceiver); + }); + + Notification updatedNotification; + try { + updatedNotification = notificationPublisherService.updateNotificationPublisher(notification, notificationStatus, reason); + } catch (SendNotificationException exception) { + log.info("Notification status rollback", exception); + throw new SendNotificationException(exception.getMessage()); + } + + getNotificationRepository().updateNotification(updatedNotification); + } + + @Override + public Notification find(Long id) { + NotificationId investigationId = new NotificationId(id); + return loadOrNotFoundException(investigationId); + } + + @Override + public void approve(Long notificationId) { + Notification notification = loadOrNotFoundException(new NotificationId(notificationId)); + List createdNotifications = notification + .getNotifications() + .stream() + .filter(notificationMessage -> notificationMessage.getNotificationStatus().equals(NotificationStatus.CREATED)) + .map(notificationMessage -> notificationMessage.toBuilder().build()) + .toList(); + + log.info("Found {} notification messages in status CREATED", createdNotifications.size()); + List approvedNotifications = new ArrayList<>(createdNotifications); + approvedNotifications.forEach(notificationMessage -> { + notificationMessage.setId(UUID.randomUUID().toString()); + notificationMessage.changeStatusTo(NotificationStatus.SENT); + }); + log.info("Found {} notification messages in status SENT", approvedNotifications.size()); + + notification.addNotificationMessages(approvedNotifications); + log.info("Found {} notification messages at all", notification.getNotifications().size()); + notification.getNotifications().stream().map(notificationMessage -> notificationMessage.getNotificationStatus().name()).forEach(s -> log.info("Notification Status {} ", s)); + + final Notification approvedInvestigation; + try { + approvedInvestigation = notificationPublisherService.approveNotification(notification); + } catch (SendNotificationException exception) { + log.info("Notification status rollback", exception); + throw new SendNotificationException(exception.getMessage()); + } + getNotificationRepository().updateNotification(approvedInvestigation); + } + + @Override + public void cancel(Long notificationId) { + Notification notification = loadOrNotFoundException(new NotificationId(notificationId)); + Notification canceledNotification = notificationPublisherService.cancelNotification(notification); + + getNotificationRepository().updateNotification(canceledNotification); + } + + @Override + public List getDistinctFilterValues(String fieldName, String startWith, Integer size, NotificationSide side) { + final Integer resultSize = Objects.isNull(size) ? Integer.MAX_VALUE : size; + + if (isSupportedEnumType(fieldName)) { + return getAssetEnumFieldValues(fieldName); + } + return getNotificationRepository().getDistinctFieldValues(fieldName, startWith, resultSize, side); + } + + @Override + public Notification loadOrNotFoundException(NotificationId investigationId) { + return getNotificationRepository().findOptionalNotificationById(investigationId) + .orElseThrow(() -> getNotFoundException(investigationId.value().toString())); + } + + @Override + public Notification loadByEdcNotificationIdOrNotFoundException(String edcNotificationId) { + return getNotificationRepository().findByEdcNotificationId(edcNotificationId) + .orElseThrow(() -> getNotFoundException(edcNotificationId)); + } + + private boolean isSupportedEnumType(String fieldName) { + return SUPPORTED_ENUM_FIELDS.contains(fieldName); + } + + private List getAssetEnumFieldValues(String fieldName) { + return switch (fieldName) { + case "status" -> Arrays.stream(NotificationStatus.values()).map(Enum::name).toList(); + case "side" -> Arrays.stream(NotificationSide.values()).map(Enum::name).toList(); + case "messages_severity" -> + Arrays.stream(NotificationSeverity.values()).map(Enum::name).toList(); + case "type" -> + Arrays.stream(NotificationType.values()).map(Enum::name).toList(); + default -> null; + }; + } +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationMockServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationMockServiceImpl.java similarity index 82% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationMockServiceImpl.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationMockServiceImpl.java index 167953bde5..70929eeb64 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationMockServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationMockServiceImpl.java @@ -17,11 +17,11 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; +package org.eclipse.tractusx.traceability.notification.domain.base.service; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; @@ -34,7 +34,7 @@ @Profile(INTEGRATION_SPRING_BOOT) public class EdcNotificationMockServiceImpl implements EdcNotificationService { @Override - public CompletableFuture asyncNotificationMessageExecutor(QualityNotificationMessage message) { + public CompletableFuture asyncNotificationMessageExecutor(NotificationMessage message) { log.info("EdcNotificationMockServiceImpl: {}", message); return CompletableFuture.completedFuture(message); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationRequest.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationRequest.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationRequest.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationRequest.java index 29a579eb68..0368942604 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationRequest.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationRequest.java @@ -16,7 +16,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; +package org.eclipse.tractusx.traceability.notification.domain.base.service; import lombok.Builder; import lombok.Data; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationService.java similarity index 75% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationService.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationService.java index df9b4ed097..47e78b873c 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationService.java @@ -17,12 +17,12 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; +package org.eclipse.tractusx.traceability.notification.domain.base.service; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; import java.util.concurrent.CompletableFuture; public interface EdcNotificationService { - CompletableFuture asyncNotificationMessageExecutor(QualityNotificationMessage notification); + CompletableFuture asyncNotificationMessageExecutor(NotificationMessage notification); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationServiceImpl.java similarity index 63% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationServiceImpl.java index ff6005582a..3dc8a9e8ee 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/EdcNotificationServiceImpl.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; +package org.eclipse.tractusx.traceability.notification.domain.base.service; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; @@ -28,14 +28,14 @@ import org.eclipse.tractusx.traceability.discovery.domain.model.Discovery; import org.eclipse.tractusx.traceability.discovery.domain.service.DiscoveryService; import org.eclipse.tractusx.traceability.discovery.infrastructure.exception.DiscoveryFinderException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.ContractNegotiationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoCatalogItemException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoEndpointDataReferenceException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.ContractNegotiationException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.NoCatalogItemException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.NoEndpointDataReferenceException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -60,7 +60,7 @@ public class EdcNotificationServiceImpl implements EdcNotificationService { @Override @Async(value = AssetsAsyncConfig.UPDATE_NOTIFICATION_EXECUTOR) - public CompletableFuture asyncNotificationMessageExecutor(QualityNotificationMessage message) { + public CompletableFuture asyncNotificationMessageExecutor(NotificationMessage message) { log.info("::asyncNotificationExecutor::message {}", message); try { Discovery discovery = discoveryService.getDiscoveryByBPN(message.getSendTo()); @@ -69,13 +69,13 @@ public CompletableFuture asyncNotificationMessageExe List receiverUrls = emptyIfNull(discovery.getReceiverUrls()); List sendResults = List.of(); - if (message.getType().equals(QualityNotificationType.ALERT)) { + if (message.getType().equals(NotificationType.ALERT)) { log.info("::asyncNotificationExecutor::isQualityAlert"); sendResults = receiverUrls .stream().map(receiverUrl -> handleSendingNotification(message, senderEdcUrl, receiverUrl)).toList(); } - if (message.getType().equals(QualityNotificationType.INVESTIGATION)) { + if (message.getType().equals(NotificationType.INVESTIGATION)) { log.info("::asyncNotificationExecutor::isQualityInvestigation"); sendResults = receiverUrls .stream().map(receiverUrl -> handleSendingNotification(message, senderEdcUrl, receiverUrl)).toList(); @@ -90,48 +90,48 @@ public CompletableFuture asyncNotificationMessageExe return CompletableFuture.completedFuture(null); } catch (DiscoveryFinderException discoveryFinderException) { - enrichQualityNotificationByError(discoveryFinderException, message); + enrichNotificationByError(discoveryFinderException, message); return CompletableFuture.completedFuture(null); } } - private boolean handleSendingNotification(QualityNotificationMessage message, String senderEdcUrl, String receiverUrl) { + private boolean handleSendingNotification(NotificationMessage message, String senderEdcUrl, String receiverUrl) { try { edcFacade.startEdcTransfer(message, receiverUrl, senderEdcUrl); return true; } catch (NoCatalogItemException e) { log.warn("Could not send message to {} no catalog item found. ", receiverUrl, e); - enrichQualityNotificationByError(e, message); + enrichNotificationByError(e, message); } catch (SendNotificationException e) { log.warn("Could not send message to {} ", receiverUrl, e); - enrichQualityNotificationByError(e, message); + enrichNotificationByError(e, message); } catch (NoEndpointDataReferenceException e) { log.warn("Could not send message to {} no endpoint data reference found", receiverUrl, e); - enrichQualityNotificationByError(e, message); + enrichNotificationByError(e, message); } catch (ContractNegotiationException e) { log.warn("Could not send message to {} could not negotiate contract agreement", receiverUrl, e); - enrichQualityNotificationByError(e, message); + enrichNotificationByError(e, message); } return false; } - private void enrichQualityNotificationByError(Exception e, QualityNotificationMessage message) { - log.info("Retrieving quality notification by message id {}", message.getEdcNotificationId()); + private void enrichNotificationByError(Exception e, NotificationMessage notificationMessage) { + log.info("Retrieving notification by message id {}", notificationMessage.getEdcNotificationId()); - Optional optionalQualityNotificationById = notificationRepository.findByEdcNotificationId(message.getEdcNotificationId()); + Optional optionalNotificationByEdcId = notificationRepository.findByEdcNotificationId(notificationMessage.getEdcNotificationId()); log.info("Successfully executed retrieving quality notification by message id"); - if (optionalQualityNotificationById.isPresent()) { - log.info("Quality Notification for error message enrichment {}", optionalQualityNotificationById.get()); - optionalQualityNotificationById.get().getNotifications().forEach(message1 -> log.info("Message found {}", message1)); - optionalQualityNotificationById.get().secondLatestNotifications().forEach(qmMessage -> { + if (optionalNotificationByEdcId.isPresent()) { + log.info("Notification for error message enrichment {}", optionalNotificationByEdcId.get()); + optionalNotificationByEdcId.get().getNotifications().forEach(message1 -> log.info("Message found {}", message1)); + optionalNotificationByEdcId.get().secondLatestNotifications().forEach(qmMessage -> { log.info("Message from second latest notification {}", qmMessage); qmMessage.setErrorMessage(e.getMessage()); }); - notificationRepository.updateErrorMessage(optionalQualityNotificationById.get()); + notificationRepository.updateErrorMessage(optionalNotificationByEdcId.get()); } else { - log.warn("Quality Notification NOT FOUND for error message enrichment notification id {}", message.getId()); + log.warn("Notification NOT FOUND for error message enrichment notification id {}", notificationMessage.getId()); } } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/NotificationPublisherService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationPublisherService.java similarity index 59% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/NotificationPublisherService.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationPublisherService.java index 0b8d863ea5..9bded8c91b 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/NotificationPublisherService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationPublisherService.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; +package org.eclipse.tractusx.traceability.notification.domain.base.service; import lombok.RequiredArgsConstructor; @@ -27,14 +27,14 @@ import org.eclipse.tractusx.traceability.bpn.domain.service.BpnRepository; import org.eclipse.tractusx.traceability.common.model.BPN; import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.exception.QualityNotificationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationNotSupportedException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.model.StartQualityNotification; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.exception.NotificationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationNotSupportedException; +import org.eclipse.tractusx.traceability.notification.domain.notification.model.StartNotification; import org.springframework.stereotype.Service; import java.time.Clock; @@ -57,29 +57,29 @@ public class NotificationPublisherService { private final Clock clock; - public QualityNotification startQualityNotification(StartQualityNotification startQualityNotification) { + public Notification startNotification(StartNotification startNotification) { BPN applicationBPN = traceabilityProperties.getBpn(); - QualityNotification notification = QualityNotification.startNotification(startQualityNotification.getTitle(), clock.instant(), applicationBPN, startQualityNotification.getDescription(), startQualityNotification.getType()); - if (startQualityNotification.isAsBuilt()) { - Map> assetsAsBuiltBPNMap = assetAsBuiltRepository.getAssetsById(startQualityNotification.getPartIds()).stream().collect(groupingBy(AssetBase::getManufacturerId)); + Notification notification = Notification.startNotification(startNotification.getTitle(), clock.instant(), applicationBPN, startNotification.getDescription(), startNotification.getType()); + if (startNotification.isAsBuilt()) { + Map> assetsAsBuiltBPNMap = assetAsBuiltRepository.getAssetsById(startNotification.getPartIds()).stream().collect(groupingBy(AssetBase::getManufacturerId)); assetsAsBuiltBPNMap .entrySet() .stream() .map(it -> { String creator = getManufacturerNameByBpn(traceabilityProperties.getBpn().value()); - String sendToName = getManufacturerNameByBpn(startQualityNotification.getReceiverBpn()); - return QualityNotificationMessage.create( + String sendToName = getManufacturerNameByBpn(startNotification.getReceiverBpn()); + return NotificationMessage.create( applicationBPN, - startQualityNotification.getReceiverBpn(), - startQualityNotification.getDescription(), - startQualityNotification.getTargetDate(), - startQualityNotification.getSeverity(), - startQualityNotification.getType(), + startNotification.getReceiverBpn(), + startNotification.getDescription(), + startNotification.getTargetDate(), + startNotification.getSeverity(), + startNotification.getType(), it, creator, sendToName); }) - .forEach(notification::addNotification); + .forEach(notification::addNotificationMessage); return notification; } else { throw new NotificationNotSupportedException(); @@ -95,7 +95,7 @@ private String getManufacturerNameByBpn(String bpn) { * * @param notification the Notification to cancel */ - public QualityNotification cancelNotification(QualityNotification notification) { + public Notification cancelNotification(Notification notification) { BPN applicationBPN = traceabilityProperties.getBpn(); notification.cancel(applicationBPN); // Shouldn't cancel notification trigger update on other side ? return notification; @@ -106,7 +106,7 @@ public QualityNotification cancelNotification(QualityNotification notification) * * @param notification the Notification to send */ - public QualityNotification approveNotification(QualityNotification notification) { + public Notification approveNotification(Notification notification) { BPN applicationBPN = traceabilityProperties.getBpn(); notification.send(applicationBPN); @@ -116,17 +116,17 @@ public QualityNotification approveNotification(QualityNotification notification) notificationStatus.forEach(s -> log.info("Notification Status {}", s)); // For each asset within investigation a notification was created before - List> futures = + List> futures = notification .getNotifications() .stream() .filter(notificationMessage -> notificationMessage.getNotificationStatus().name() - .equals(QualityNotificationStatus.SENT.name())) + .equals(NotificationStatus.SENT.name())) .map(edcNotificationService::asyncNotificationMessageExecutor) .filter(Objects::nonNull) .toList(); - List sentMessages = futures.stream() + List sentMessages = futures.stream() .map(CompletableFuture::join) .filter(Objects::nonNull) .toList(); @@ -143,11 +143,11 @@ public QualityNotification approveNotification(QualityNotification notification) * @param status the NotificationStatus of the notification to update * @param reason the reason for update of the notification */ - public QualityNotification updateNotificationPublisher(QualityNotification notification, QualityNotificationStatus status, String reason) { + public Notification updateNotificationPublisher(Notification notification, NotificationStatus status, String reason) { BPN applicationBPN = traceabilityProperties.getBpn(); validate(applicationBPN, status, notification); - List relevantNotifications = + List relevantNotifications = notification .getNotifications() .stream() @@ -161,16 +161,16 @@ public QualityNotification updateNotificationPublisher(QualityNotification notif case DECLINED -> notification.decline(reason); case CLOSED -> notification.close(reason); default -> - throw new QualityNotificationIllegalUpdate("Transition from status '%s' to status '%s' is not allowed for notification with id '%s'".formatted(notification.getNotificationStatus().name(), status, notification.getNotificationId())); + throw new NotificationIllegalUpdate("Transition from status '%s' to status '%s' is not allowed for notification with id '%s'".formatted(notification.getNotificationStatus().name(), status, notification.getNotificationId())); } log.info("::updateNotificationPublisher::notificationToSend {}", qNotification); }); - List> futures = relevantNotifications.stream() + List> futures = relevantNotifications.stream() .map(edcNotificationService::asyncNotificationMessageExecutor) .filter(Objects::nonNull) .toList(); - List sentMessages = futures.stream() + List sentMessages = futures.stream() .map(CompletableFuture::join) .filter(Objects::nonNull) .toList(); @@ -182,23 +182,23 @@ public QualityNotification updateNotificationPublisher(QualityNotification notif return notification; } - private void validate(BPN applicationBpn, QualityNotificationStatus status, QualityNotification notification) { + private void validate(BPN applicationBpn, NotificationStatus status, Notification notification) { - final boolean isInvalidAcknowledgeOrAcceptOrDecline = !QualityNotificationSide.RECEIVER.equals(notification.getNotificationSide()) && applicationBpn.value().equals(notification.getBpn()); - final boolean isInvalidClose = QualityNotificationStatus.CLOSED.equals(status) && !applicationBpn.value().equals(notification.getBpn()); + final boolean isInvalidAcknowledgeOrAcceptOrDecline = !NotificationSide.RECEIVER.equals(notification.getNotificationSide()) && applicationBpn.value().equals(notification.getBpn()); + final boolean isInvalidClose = NotificationStatus.CLOSED.equals(status) && !applicationBpn.value().equals(notification.getBpn()); switch (status) { case ACKNOWLEDGED, ACCEPTED, DECLINED -> { if (isInvalidAcknowledgeOrAcceptOrDecline) { - throw new QualityNotificationIllegalUpdate("Transition from status '%s' to status '%s' is not allowed for notification with BPN '%s' and application with BPN '%s'".formatted(notification.getNotificationStatus().name(), status, notification.getBpn(), applicationBpn.value())); + throw new NotificationIllegalUpdate("Transition from status '%s' to status '%s' is not allowed for notification with BPN '%s' and application with BPN '%s'".formatted(notification.getNotificationStatus().name(), status, notification.getBpn(), applicationBpn.value())); } } case CLOSED -> { if (isInvalidClose) { - throw new QualityNotificationIllegalUpdate("Transition from status '%s' to status '%s' is not allowed for notification with BPN '%s' and application with BPN '%s'".formatted(notification.getNotificationStatus().name(), status, notification.getBpn(), applicationBpn.value())); + throw new NotificationIllegalUpdate("Transition from status '%s' to status '%s' is not allowed for notification with BPN '%s' and application with BPN '%s'".formatted(notification.getNotificationStatus().name(), status, notification.getBpn(), applicationBpn.value())); } } default -> - throw new QualityNotificationIllegalUpdate("Unknown Transition from status '%s' to status '%s' is not allowed for notification with id '%s'".formatted(notification.getNotificationStatus().name(), status, notification.getNotificationId())); + throw new NotificationIllegalUpdate("Unknown Transition from status '%s' to status '%s' is not allowed for notification with id '%s'".formatted(notification.getNotificationStatus().name(), status, notification.getNotificationId())); } } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationReceiverService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationReceiverService.java new file mode 100644 index 0000000000..e681fe07a8 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationReceiverService.java @@ -0,0 +1,29 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ +package org.eclipse.tractusx.traceability.notification.domain.base.service; + +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; + +public interface NotificationReceiverService { + + void handleReceive(EDCNotification edcNotification, NotificationType notificationType); + + void handleUpdate(EDCNotification edcNotification, NotificationType notificationType); +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/NotificationsEDCFacade.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationsEDCFacade.java similarity index 78% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/NotificationsEDCFacade.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationsEDCFacade.java index 4d4016764f..ea194a1486 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/NotificationsEDCFacade.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/base/service/NotificationsEDCFacade.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; +package org.eclipse.tractusx.traceability.notification.domain.base.service; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; @@ -36,18 +36,18 @@ import org.eclipse.tractusx.irs.edc.client.model.CatalogItem; import org.eclipse.tractusx.irs.edc.client.policy.PolicyCheckerService; import org.eclipse.tractusx.traceability.common.properties.EdcProperties; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.BadRequestException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.ContractNegotiationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoCatalogItemException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoEndpointDataReferenceException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationFactory; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.BadRequestException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.ContractNegotiationException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.NoCatalogItemException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.NoEndpointDataReferenceException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationFactory; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; @@ -91,7 +91,7 @@ public class NotificationsEDCFacade { private static final String ASSET_VALUE_NOTIFICATION_METHOD_RECEIVE = "receive"; public void startEdcTransfer( - final QualityNotificationMessage notification, + final NotificationMessage notification, final String receiverEdcUrl, final String senderEdcUrl) { @@ -124,10 +124,10 @@ private String negotiateContractAgreement(final String receiverEdcUrl, final Cat } } - private CatalogItem getCatalogItem(final QualityNotificationMessage notification, final String receiverEdcUrl) { + private CatalogItem getCatalogItem(final NotificationMessage notification, final String receiverEdcUrl) { try { - final String propertyNotificationTypeValue = QualityNotificationType.ALERT.equals(notification.getType()) ? ASSET_VALUE_QUALITY_ALERT : ASSET_VALUE_QUALITY_INVESTIGATION; - final String propertyMethodValue = Boolean.TRUE.equals(notification.getNotificationStatus().equals(QualityNotificationStatus.SENT)) ? ASSET_VALUE_NOTIFICATION_METHOD_RECEIVE : ASSET_VALUE_NOTIFICATION_METHOD_UPDATE; + final String propertyNotificationTypeValue = NotificationType.ALERT.equals(notification.getType()) ? ASSET_VALUE_QUALITY_ALERT : ASSET_VALUE_QUALITY_INVESTIGATION; + final String propertyMethodValue = Boolean.TRUE.equals(notification.getNotificationStatus().equals(NotificationStatus.SENT)) ? ASSET_VALUE_NOTIFICATION_METHOD_RECEIVE : ASSET_VALUE_NOTIFICATION_METHOD_UPDATE; return edcCatalogFacade.fetchCatalogItems( CatalogRequest.Builder.newInstance() .protocol(DEFAULT_PROTOCOL) @@ -157,7 +157,7 @@ private CatalogItem getCatalogItem(final QualityNotificationMessage notification // TODO this method should be completly handled by EDCNotificationFactory.createEdcNotification which is part of this method currently private EdcNotificationRequest toEdcNotificationRequest( - final QualityNotificationMessage notification, + final NotificationMessage notification, final String senderEdcUrl, final EndpointDataReference dataReference ) throws JsonProcessingException { @@ -176,7 +176,7 @@ private EdcNotificationRequest toEdcNotificationRequest( } - private void sendRequest(final EdcNotificationRequest request, QualityNotificationMessage message) { + private void sendRequest(final EdcNotificationRequest request, NotificationMessage message) { HttpEntity entity = new HttpEntity<>(request.getBody(), request.getHeaders()); try { var response = edcNotificationTemplate.exchange(request.getUrl(), HttpMethod.POST, entity, new ParameterizedTypeReference<>() { @@ -187,10 +187,10 @@ private void sendRequest(final EdcNotificationRequest request, QualityNotificati } else { String edcNotificationId = message.getEdcNotificationId(); - Optional optionalQualityNotificationById = notificationRepository.findByEdcNotificationId(edcNotificationId); - if (optionalQualityNotificationById.isPresent()) { - optionalQualityNotificationById.ifPresent(notificationRepository::updateQualityNotificationEntity); - log.info("Updated qualitynotification message as {} with id {}.", message.getType(), optionalQualityNotificationById.get().getNotificationId().value()); + Optional optionalNotificationById = notificationRepository.findByEdcNotificationId(edcNotificationId); + if (optionalNotificationById.isPresent()) { + optionalNotificationById.ifPresent(notificationRepository::updateNotification); + log.info("Updated notification message as {} with id {}.", message.getType(), optionalNotificationById.get().getNotificationId().value()); } } } catch (Exception e) { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/contract/EdcNotificationContractService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/contract/EdcNotificationContractService.java similarity index 88% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/contract/EdcNotificationContractService.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/contract/EdcNotificationContractService.java index 24602c362d..8044c5180e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/contract/EdcNotificationContractService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/contract/EdcNotificationContractService.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.contract; +package org.eclipse.tractusx.traceability.notification.domain.contract; import assets.importpoc.PolicyResponse; import lombok.AllArgsConstructor; @@ -37,10 +37,10 @@ import org.eclipse.tractusx.traceability.assets.application.importpoc.PolicyService; import org.eclipse.tractusx.traceability.assets.application.importpoc.mapper.PolicyMapper; import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractException; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractRequest; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractResponse; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.NotificationMethod; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractException; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractRequest; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractResponse; +import org.eclipse.tractusx.traceability.notification.application.contract.model.NotificationMethod; import org.springframework.stereotype.Component; import java.util.Optional; @@ -142,8 +142,8 @@ private void revertNotificationAsset(String notificationAssetId) { } } - private String createBaseUrl(org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.NotificationType notificationType, NotificationMethod notificationMethod) { - final String template = notificationType.equals(org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.NotificationType.QUALITY_ALERT) ? TRACE_FOSS_QUALITY_NOTIFICATION_ALERT_URL_TEMPLATE : TRACE_FOSS_QUALITY_NOTIFICATION_INVESTIGATION_URL_TEMPLATE; + private String createBaseUrl(org.eclipse.tractusx.traceability.notification.application.contract.model.NotificationType notificationType, NotificationMethod notificationMethod) { + final String template = notificationType.equals(org.eclipse.tractusx.traceability.notification.application.contract.model.NotificationType.QUALITY_ALERT) ? TRACE_FOSS_QUALITY_NOTIFICATION_ALERT_URL_TEMPLATE : TRACE_FOSS_QUALITY_NOTIFICATION_INVESTIGATION_URL_TEMPLATE; return traceabilityProperties.getUrl() + template.formatted(notificationMethod.getValue()); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationIllegalUpdate.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationIllegalUpdate.java similarity index 92% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationIllegalUpdate.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationIllegalUpdate.java index fbe15f5cbe..be4b6ceaa7 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationIllegalUpdate.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationIllegalUpdate.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception; +package org.eclipse.tractusx.traceability.notification.domain.notification.exception; public class InvestigationIllegalUpdate extends IllegalArgumentException { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationNotFoundException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationNotFoundException.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationNotFoundException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationNotFoundException.java index 8298438314..e7ce115e72 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationNotFoundException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationNotFoundException.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception; +package org.eclipse.tractusx.traceability.notification.domain.notification.exception; public class InvestigationNotFoundException extends RuntimeException { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationReceiverBpnMismatchException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationReceiverBpnMismatchException.java similarity index 94% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationReceiverBpnMismatchException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationReceiverBpnMismatchException.java index 36a498b9b4..749786bb98 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationReceiverBpnMismatchException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationReceiverBpnMismatchException.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception; +package org.eclipse.tractusx.traceability.notification.domain.notification.exception; import org.eclipse.tractusx.traceability.common.model.BPN; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationStatusTransitionNotAllowed.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationStatusTransitionNotAllowed.java similarity index 74% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationStatusTransitionNotAllowed.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationStatusTransitionNotAllowed.java index 6f62d49472..b2e9d10a9c 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/InvestigationStatusTransitionNotAllowed.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/InvestigationStatusTransitionNotAllowed.java @@ -19,14 +19,14 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception; +package org.eclipse.tractusx.traceability.notification.domain.notification.exception; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; public class InvestigationStatusTransitionNotAllowed extends RuntimeException { - public InvestigationStatusTransitionNotAllowed(QualityNotificationId investigationId, QualityNotificationStatus from, QualityNotificationStatus to) { + public InvestigationStatusTransitionNotAllowed(NotificationId investigationId, NotificationStatus from, NotificationStatus to) { super("Transition from status '%s' to status '%s' is not allowed for investigation with id '%s'".formatted(from.name(), to.name(), investigationId.value())); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationIllegalUpdate.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationIllegalUpdate.java similarity index 91% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationIllegalUpdate.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationIllegalUpdate.java index f87357243d..185e7206ed 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationIllegalUpdate.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationIllegalUpdate.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception; +package org.eclipse.tractusx.traceability.notification.domain.notification.exception; public class NotificationIllegalUpdate extends IllegalArgumentException { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationNotFoundException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationNotFoundException.java similarity index 92% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationNotFoundException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationNotFoundException.java index 12b380e3ca..52035bb8ee 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationNotFoundException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationNotFoundException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception; +package org.eclipse.tractusx.traceability.notification.domain.notification.exception; public class NotificationNotFoundException extends RuntimeException{ public NotificationNotFoundException(String notificationId) { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationNotSupportedException.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationNotSupportedException.java similarity index 92% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationNotSupportedException.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationNotSupportedException.java index e7876f18dc..96130c8454 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationNotSupportedException.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationNotSupportedException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception; +package org.eclipse.tractusx.traceability.notification.domain.notification.exception; public class NotificationNotSupportedException extends RuntimeException { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationStatusTransitionNotAllowed.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationStatusTransitionNotAllowed.java similarity index 83% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationStatusTransitionNotAllowed.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationStatusTransitionNotAllowed.java index ff144db632..cc3dc9f7d4 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/exception/NotificationStatusTransitionNotAllowed.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/exception/NotificationStatusTransitionNotAllowed.java @@ -19,13 +19,13 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception; +package org.eclipse.tractusx.traceability.notification.domain.notification.exception; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; public class NotificationStatusTransitionNotAllowed extends RuntimeException { - public NotificationStatusTransitionNotAllowed(String notificationId, QualityNotificationStatus from, QualityNotificationStatus to) { + public NotificationStatusTransitionNotAllowed(String notificationId, NotificationStatus from, NotificationStatus to) { super("Transition from status '%s' to status '%s' is not allowed for notification with id '%s'".formatted(from.name(), to.name(), notificationId)); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/model/StartNotification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/model/StartNotification.java new file mode 100644 index 0000000000..41cce47e9d --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/model/StartNotification.java @@ -0,0 +1,68 @@ +/******************************************************************************** + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.traceability.notification.domain.notification.model; + +import lombok.Builder; +import lombok.Data; +import lombok.Getter; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import notification.request.StartNotificationRequest; + +import java.time.Instant; +import java.util.List; + +@Builder +@Getter +@Data +public class StartNotification { + + private String title; + + private List partIds; + + private String description; + + private Instant targetDate; + + private NotificationSeverity severity; + + private NotificationType type; + + private boolean isAsBuilt; + + private String receiverBpn; + + + public static StartNotification from(StartNotificationRequest startNotificationRequest) { + return StartNotification.builder() + .title(startNotificationRequest.getTitle()) + .partIds(startNotificationRequest.getPartIds()) + .description(startNotificationRequest.getDescription()) + .targetDate(startNotificationRequest.getTargetDate()) + .severity(NotificationSeverity.from(startNotificationRequest.getSeverity())) + .type(NotificationType.from(startNotificationRequest.getType())) + .receiverBpn(startNotificationRequest.getReceiverBpn()) + .isAsBuilt(startNotificationRequest.isAsBuilt()) + .build(); + } + + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/repository/NotificationRepository.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/repository/NotificationRepository.java new file mode 100644 index 0000000000..6a944e5d62 --- /dev/null +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/repository/NotificationRepository.java @@ -0,0 +1,56 @@ +/******************************************************************************** + * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (c) 2022, 2023 ZF Friedrichshafen AG + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://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. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.traceability.notification.domain.notification.repository; + +import org.eclipse.tractusx.traceability.assets.domain.base.model.Owner; +import org.eclipse.tractusx.traceability.common.model.PageResult; +import org.eclipse.tractusx.traceability.common.model.SearchCriteria; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.springframework.data.domain.Pageable; + +import java.util.List; +import java.util.Optional; + +public interface NotificationRepository { + + Optional findOptionalNotificationById(NotificationId investigationId); + + Optional findByEdcNotificationId(String edcNotificationId); + + long countNotificationsBySideAndType(NotificationSide investigationSide, NotificationType notificationType); + + NotificationId saveNotification(Notification investigation); + + void updateNotification(Notification investigation); + + PageResult getNotifications(Pageable pageable, SearchCriteria searchCriteria); + + long countOpenNotificationsByOwnershipAndNotificationType(List owners, NotificationType notificationType); + + List getDistinctFieldValues(String fieldName, String startWith, Integer resultLimit, NotificationSide owner); + + void updateErrorMessage(Notification investigation); + +} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/service/NotificationReceiverService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/service/NotificationReceiverService.java similarity index 59% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/service/NotificationReceiverService.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/service/NotificationReceiverService.java index 365646954a..b4c328bbd4 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/service/NotificationReceiverService.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/service/NotificationReceiverService.java @@ -17,42 +17,41 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.service; +package org.eclipse.tractusx.traceability.notification.domain.notification.service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.eclipse.tractusx.traceability.common.mapper.NotificationMapper; import org.eclipse.tractusx.traceability.common.mapper.NotificationMessageMapper; -import org.eclipse.tractusx.traceability.common.mapper.QualityNotificationMapper; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.service.AbstractQualityNotificationReceiverService; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationNotFoundException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.QualityNotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.service.AbstractNotificationReceiverService; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationNotFoundException; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; import org.springframework.stereotype.Component; @Slf4j @RequiredArgsConstructor @Component -public class NotificationReceiverService extends AbstractQualityNotificationReceiverService { +public class NotificationReceiverService extends AbstractNotificationReceiverService { private final NotificationRepository notificationRepository; - private final NotificationMessageMapper notificationMapper; - private final QualityNotificationMapper qualityNotificationMapper; + private final NotificationMessageMapper notificationMessageMapper; + private final NotificationMapper notificationMapper; @Override - protected QualityNotificationRepository getRepository() { + protected NotificationRepository getRepository() { return notificationRepository; } @Override protected NotificationMessageMapper getNotificationMessageMapper() { - return notificationMapper; + return notificationMessageMapper; } @Override - protected QualityNotificationMapper getQualityNotificationMapper() { - return qualityNotificationMapper; + protected NotificationMapper getNotificationMapper() { + return notificationMapper; } @Override diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/service/NotificationServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/service/NotificationServiceImpl.java similarity index 66% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/service/NotificationServiceImpl.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/service/NotificationServiceImpl.java index df2db0429e..58380fdb80 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/service/NotificationServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/domain/notification/service/NotificationServiceImpl.java @@ -17,18 +17,17 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.service; +package org.eclipse.tractusx.traceability.notification.domain.notification.service; import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationNotFoundException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.service.AbstractQualityNotificationService; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.service.NotificationPublisherService; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.QualityNotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationNotFoundException; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.service.AbstractNotificationService; +import org.eclipse.tractusx.traceability.notification.domain.base.service.NotificationPublisherService; import org.springframework.stereotype.Service; @Service("notificationServiceImpl") -public class NotificationServiceImpl extends AbstractQualityNotificationService { +public class NotificationServiceImpl extends AbstractNotificationService { private final NotificationRepository notificationRepository; @@ -39,7 +38,7 @@ public NotificationServiceImpl(TraceabilityProperties traceabilityProperties, No } @Override - protected QualityNotificationRepository getQualityNotificationRepository() { + protected NotificationRepository getNotificationRepository() { return notificationRepository; } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/EDCNotificationValidator.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/EDCNotificationValidator.java similarity index 91% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/EDCNotificationValidator.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/EDCNotificationValidator.java index da2efa92c6..287ab24c8f 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/EDCNotificationValidator.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/EDCNotificationValidator.java @@ -17,14 +17,14 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc; +package org.eclipse.tractusx.traceability.notification.infrastructure.edc; import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; import org.eclipse.tractusx.traceability.common.model.BPN; import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationReceiverBpnMismatchException; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationReceiverBpnMismatchException; import org.springframework.stereotype.Component; /** diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/EdcController.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/EdcController.java similarity index 82% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/EdcController.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/EdcController.java index 8276c57edc..876452d8f9 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/EdcController.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/EdcController.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc; +package org.eclipse.tractusx.traceability.notification.infrastructure.edc; import assets.importpoc.ErrorResponse; import io.swagger.v3.oas.annotations.Hidden; @@ -31,11 +31,10 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.service.NotificationReceiverService; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.notification.service.NotificationReceiverService; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -55,10 +54,10 @@ public class EdcController { /** * Receiver API call for EDC Transfer */ - @Operation(operationId = "qualityNotificationInvestigationReceive", - summary = "Receive and process quality notifications", + @Operation(operationId = "investigationNotificationReceive", + summary = "Receive and process investigation type notifications", tags = {"Edc"}, - description = "This endpoint receives and processes quality notifications.", + description = "This endpoint receives and processes investigation type notifications.", security = @SecurityRequirement(name = "oAuth2", scopes = "profile email")) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse( @@ -105,20 +104,20 @@ public class EdcController { mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class)))}) @PostMapping("/qualitynotifications/receive") - public void qualityNotificationInvestigationReceive(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) { + public void investigationNotificationReceive(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) { EDCNotification cleanEdcNotification = sanitize(edcNotification); - log.info("EdcController [qualityNotificationReceive] notificationId:{}", cleanEdcNotification); - validateIsQualityInvestigation(cleanEdcNotification); - notificationReceiverService.handleReceive(cleanEdcNotification, QualityNotificationType.INVESTIGATION); + log.info("EdcController [investigationNotificationReceive] notificationId:{}", cleanEdcNotification); + validateIsInvestigation(cleanEdcNotification); + notificationReceiverService.handleReceive(cleanEdcNotification, NotificationType.INVESTIGATION); } /** * Update API call for EDC Transfer */ - @Operation(operationId = "qualityNotificationInvestigationUpdate", - summary = "Updates a quality notification", + @Operation(operationId = "investigationNotificationUpdate", + summary = "Updates a investigation type notification", tags = {"Edc"}, - description = "This endpoint handles the update of a quality notification.", + description = "This endpoint handles the update of a investigation type notification.", security = @SecurityRequirement(name = "oAuth2", scopes = "profile email")) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"), @@ -166,20 +165,20 @@ public void qualityNotificationInvestigationReceive(final @ValidEDCNotification mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class)))}) @PostMapping("/qualitynotifications/update") - public void qualityNotificationInvestigationUpdate(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) { + public void investigationNotificationUpdate(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) { EDCNotification cleanEdcNotification = sanitize(edcNotification); - log.info("EdcController [qualityNotificationUpdate] notificationId:{}", cleanEdcNotification); - validateIsQualityInvestigation(cleanEdcNotification); - notificationReceiverService.handleUpdate(cleanEdcNotification, QualityNotificationType.INVESTIGATION); + log.info("EdcController [investigationNotificationUpdate] notificationId:{}", cleanEdcNotification); + validateIsInvestigation(cleanEdcNotification); + notificationReceiverService.handleUpdate(cleanEdcNotification, NotificationType.INVESTIGATION); } /** * Receiver API call for EDC Transfer */ - @Operation(operationId = "qualityNotificationAlertReceive", - summary = "Receive and process quality alerts", + @Operation(operationId = "alertNotificationReceive", + summary = "Receive and process alert type notifications", tags = {"Edc"}, - description = "This endpoint receives and processes quality alerts.", + description = "This endpoint receives and processes alert type notifications.", security = @SecurityRequirement(name = "oAuth2", scopes = "profile email")) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse( @@ -226,20 +225,20 @@ public void qualityNotificationInvestigationUpdate(final @ValidEDCNotification @ mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class)))}) @PostMapping("/qualityalerts/receive") - public void qualityNotificationAlertReceive(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) { + public void alertNotificationReceive(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) { EDCNotification cleanEdcNotification = sanitize(edcNotification); - log.info("EdcController [qualityalertReceive] notificationId:{}", cleanEdcNotification); + log.info("EdcController [alertNotificationReceive] notificationId:{}", cleanEdcNotification); validateIsAlert(cleanEdcNotification); - notificationReceiverService.handleReceive(cleanEdcNotification, QualityNotificationType.ALERT); + notificationReceiverService.handleReceive(cleanEdcNotification, NotificationType.ALERT); } /** * Update API call for EDC Transfer */ - @Operation(operationId = "qualityNotificationAlertUpdate", - summary = "Updates a quality alert", + @Operation(operationId = "alertNotificationUpdate", + summary = "Updates a alert type notification", tags = {"Edc"}, - description = "This endpoint handles the update of a quality alert.", + description = "This endpoint handles the update of a alert type notifications.", security = @SecurityRequirement(name = "oAuth2", scopes = "profile email")) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse( @@ -286,24 +285,24 @@ public void qualityNotificationAlertReceive(final @ValidEDCNotification @Valid @ mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class)))}) @PostMapping("/qualityalerts/update") - public void qualityNotificationAlertUpdate(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) { + public void alertNotificationUpdate(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) { EDCNotification cleanEdcNotification = sanitize(edcNotification); - log.info("EdcController [qualityalertUpdate] notificationId:{}", cleanEdcNotification); + log.info("EdcController [alertNotificationUpdate] notificationId:{}", cleanEdcNotification); validateIsAlert(cleanEdcNotification); - notificationReceiverService.handleUpdate(cleanEdcNotification, QualityNotificationType.ALERT); + notificationReceiverService.handleUpdate(cleanEdcNotification, NotificationType.ALERT); } - private void validateIsQualityInvestigation(EDCNotification edcNotification) { - NotificationType notificationType = edcNotification.convertNotificationType(); - if (!notificationType.equals(NotificationType.QMINVESTIGATION)) { + private void validateIsInvestigation(EDCNotification edcNotification) { + org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.NotificationType notificationType = edcNotification.convertNotificationType(); + if (!notificationType.equals(org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.NotificationType.QMINVESTIGATION)) { throw new InvestigationIllegalUpdate("Received %s classified edc notification which is not an investigation".formatted(notificationType)); } } private void validateIsAlert(EDCNotification edcNotification) { - NotificationType notificationType = edcNotification.convertNotificationType(); - if (!notificationType.equals(NotificationType.QMALERT)) { + org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.NotificationType notificationType = edcNotification.convertNotificationType(); + if (!notificationType.equals(org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.NotificationType.QMALERT)) { throw new InvestigationIllegalUpdate("Received %s classified edc notification which is not an alert".formatted(notificationType)); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/ValidEDCNotification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/ValidEDCNotification.java similarity index 94% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/ValidEDCNotification.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/ValidEDCNotification.java index e3f886f5bd..2ae8f9b31f 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/ValidEDCNotification.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/ValidEDCNotification.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc; +package org.eclipse.tractusx.traceability.notification.infrastructure.edc; import jakarta.validation.Constraint; import jakarta.validation.Payload; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotification.java similarity index 85% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotification.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotification.java index fe3209f45d..8fcd824c8d 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotification.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotification.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.edc.model; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; @@ -26,8 +26,8 @@ import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import org.apache.commons.lang3.StringUtils; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import java.time.Instant; import java.util.List; @@ -80,9 +80,9 @@ public String getRelatedNotificationId() { } @JsonIgnore - public List getListOfAffectedItems() { + public List getListOfAffectedItems() { return content.listOfAffectedItems().stream() - .map(QualityNotificationAffectedPart::new).toList(); + .map(NotificationAffectedPart::new).toList(); } public NotificationType convertNotificationType() { @@ -92,10 +92,10 @@ public NotificationType convertNotificationType() { .orElseThrow(() -> new IllegalArgumentException("%s not supported notification type".formatted(classification))); } - public QualityNotificationStatus convertNotificationStatus() { + public NotificationStatus convertNotificationStatus() { String notificationStatus = header().status(); - return QualityNotificationStatus.fromValue(notificationStatus) + return NotificationStatus.fromValue(notificationStatus) .orElseThrow(() -> new IllegalArgumentException("%s not supported investigation status".formatted(notificationStatus))); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationContent.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationContent.java similarity index 93% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationContent.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationContent.java index 812e410944..16fa0b6fbb 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationContent.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationContent.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.edc.model; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationFactory.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationFactory.java similarity index 75% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationFactory.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationFactory.java index 2faf2fa2c4..e159dbd99e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationFactory.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationFactory.java @@ -18,11 +18,11 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.edc.model; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; import java.util.List; @@ -31,7 +31,7 @@ public class EDCNotificationFactory { private EDCNotificationFactory() { } - public static EDCNotification createEdcNotification(String senderEDC, QualityNotificationMessage notification) { + public static EDCNotification createEdcNotification(String senderEDC, NotificationMessage notification) { String targetDate = null; if (notification.getTargetDate() != null) { targetDate = notification.getTargetDate().toString(); @@ -43,7 +43,7 @@ public static EDCNotification createEdcNotification(String senderEDC, QualityNot senderEDC, notification.getSendTo(), NotificationType.from(notification.getType()).getValue(), - notification.getSeverity() != null ? notification.getSeverity().getRealName() : QualityNotificationSeverity.MINOR.getRealName(), + notification.getSeverity() != null ? notification.getSeverity().getRealName() : NotificationSeverity.MINOR.getRealName(), notification.getNotificationReferenceId(), notification.getNotificationStatus().name(), targetDate, @@ -59,9 +59,9 @@ public static EDCNotification createEdcNotification(String senderEDC, QualityNot } - private static List extractAssetIds(QualityNotificationMessage notification) { + private static List extractAssetIds(NotificationMessage notification) { return notification.getAffectedParts().stream() - .map(QualityNotificationAffectedPart::assetId).toList(); + .map(NotificationAffectedPart::assetId).toList(); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationHeader.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationHeader.java similarity index 94% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationHeader.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationHeader.java index 33dc72a7e0..0943bdd7ae 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/EDCNotificationHeader.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/EDCNotificationHeader.java @@ -18,7 +18,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.edc.model; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/NotificationType.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/NotificationType.java similarity index 65% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/NotificationType.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/NotificationType.java index 62d2dffab5..b26960bf00 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/edc/model/NotificationType.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/edc/model/NotificationType.java @@ -19,10 +19,9 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.edc.model; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.BadRequestException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.BadRequestException; import java.util.Arrays; import java.util.Map; @@ -36,8 +35,8 @@ public enum NotificationType { private static final Map MAPPINGS; static { - MAPPINGS = Arrays.stream(NotificationType.values()) - .collect(Collectors.toMap(NotificationType::getValue, notificationType -> notificationType)); + MAPPINGS = Arrays.stream(org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.NotificationType.values()) + .collect(Collectors.toMap(org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.NotificationType::getValue, notificationType -> notificationType)); } private final String value; @@ -50,14 +49,14 @@ public static Optional fromValue(String value) { return Optional.ofNullable(MAPPINGS.get(value)); } - public static NotificationType from(QualityNotificationType qualityNotificationType) { - if (qualityNotificationType.equals(QualityNotificationType.ALERT)) { + public static NotificationType from(org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType notificationType) { + if (notificationType.equals(org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType.ALERT)) { return QMALERT; } - if (qualityNotificationType.equals(QualityNotificationType.INVESTIGATION)) { + if (notificationType.equals(org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType.INVESTIGATION)) { return QMINVESTIGATION; } - throw new BadRequestException("Wrong quality notification type wwas provided " + qualityNotificationType); + throw new BadRequestException("Wrong quality notification type wwas provided " + notificationType); } public String getValue() { diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationBaseEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationBaseEntity.java similarity index 95% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationBaseEntity.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationBaseEntity.java index 6ed9bcd686..daa225466f 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationBaseEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationBaseEntity.java @@ -16,7 +16,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.model; import jakarta.persistence.Column; import jakarta.persistence.EnumType; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationEntity.java similarity index 70% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationEntity.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationEntity.java index 39e39742df..608ad96498 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationEntity.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.model; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; @@ -34,12 +34,12 @@ import lombok.experimental.SuperBuilder; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; import java.util.List; @@ -68,32 +68,32 @@ public class NotificationEntity extends NotificationBaseEntity { @OneToMany(mappedBy = "notification") private List messages; - public static QualityNotification toDomain(NotificationEntity notificationEntity) { - List messages = emptyIfNull(notificationEntity.getMessages()).stream() + public static Notification toDomain(NotificationEntity notificationEntity) { + List messages = emptyIfNull(notificationEntity.getMessages()).stream() .map(NotificationMessageEntity::toDomain) .toList(); List assetIds = notificationEntity.getAssets().stream() .map(AssetAsBuiltEntity::getId) .toList(); - return QualityNotification.builder() + return Notification.builder() .title(notificationEntity.getTitle()) - .notificationId(new QualityNotificationId(notificationEntity.getId())) + .notificationId(new NotificationId(notificationEntity.getId())) .bpn(BPN.of(notificationEntity.getBpn())) - .notificationStatus(QualityNotificationStatus.fromStringValue(notificationEntity.getStatus().name())) - .notificationSide(QualityNotificationSide.valueOf(notificationEntity.getSide().name())) + .notificationStatus(NotificationStatus.fromStringValue(notificationEntity.getStatus().name())) + .notificationSide(NotificationSide.valueOf(notificationEntity.getSide().name())) .closeReason(notificationEntity.getCloseReason()) .acceptReason(notificationEntity.getAcceptReason()) .declineReason(notificationEntity.getDeclineReason()) .createdAt(notificationEntity.getCreatedDate()) .description(notificationEntity.getDescription()) - .notificationType(QualityNotificationType.valueOf(notificationEntity.getType().name())) + .notificationType(NotificationType.valueOf(notificationEntity.getType().name())) .assetIds(assetIds) .notifications(messages) .build(); } - public static NotificationEntity from(QualityNotification notification, List assetEntities) { + public static NotificationEntity from(Notification notification, List assetEntities) { return NotificationEntity.builder() .title(notification.getTitle()) .assets(assetEntities) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationMessageBaseEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationMessageBaseEntity.java similarity index 88% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationMessageBaseEntity.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationMessageBaseEntity.java index 5beb6e75f7..837842a4ad 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationMessageBaseEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationMessageBaseEntity.java @@ -16,7 +16,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.model; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; @@ -26,7 +26,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; import java.time.Instant; import java.time.LocalDateTime; @@ -46,7 +46,7 @@ public class NotificationMessageBaseEntity { private String notificationReferenceId; private Instant targetDate; @Enumerated(EnumType.STRING) - private QualityNotificationSeverity severity; + private NotificationSeverity severity; private String edcNotificationId; private LocalDateTime created; private LocalDateTime updated; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationMessageEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationMessageEntity.java similarity index 66% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationMessageEntity.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationMessageEntity.java index e0e1b368b6..ce6ec56dec 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationMessageEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationMessageEntity.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.model; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; @@ -33,9 +33,9 @@ import lombok.Setter; import lombok.experimental.SuperBuilder; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import java.util.List; @@ -60,8 +60,8 @@ public class NotificationMessageEntity extends NotificationMessageBaseEntity { ) private List assets; - public static QualityNotificationMessage toDomain(NotificationMessageEntity notificationMessageEntity) { - return QualityNotificationMessage.builder() + public static NotificationMessage toDomain(NotificationMessageEntity notificationMessageEntity) { + return NotificationMessage.builder() .id(notificationMessageEntity.getId()) .notificationReferenceId(notificationMessageEntity.getNotificationReferenceId()) .createdBy(notificationMessageEntity.getCreatedBy()) @@ -70,9 +70,9 @@ public static QualityNotificationMessage toDomain(NotificationMessageEntity noti .sendToName(notificationMessageEntity.getSendToName()) .description(notificationMessageEntity.getNotification().getDescription()) .contractAgreementId(notificationMessageEntity.getContractAgreementId()) - .notificationStatus(QualityNotificationStatus.fromStringValue(notificationMessageEntity.getStatus().name())) + .notificationStatus(NotificationStatus.fromStringValue(notificationMessageEntity.getStatus().name())) .affectedParts(notificationMessageEntity.getAssets().stream() - .map(asset -> new QualityNotificationAffectedPart(asset.getId())) + .map(asset -> new NotificationAffectedPart(asset.getId())) .toList()) .targetDate(notificationMessageEntity.getTargetDate()) .severity(notificationMessageEntity.getSeverity()) @@ -86,26 +86,26 @@ public static QualityNotificationMessage toDomain(NotificationMessageEntity noti } public static NotificationMessageEntity from(NotificationEntity notificationEntity, - QualityNotificationMessage qualityNotificationMessage, + NotificationMessage notificationMessage, List notificationAssets) { return NotificationMessageEntity .builder() - .id(qualityNotificationMessage.getId()) + .id(notificationMessage.getId()) .notification(notificationEntity) - .errorMessage(qualityNotificationMessage.getErrorMessage()) - .contractAgreementId(qualityNotificationMessage.getContractAgreementId()) - .created(qualityNotificationMessage.getCreated()) - .createdBy(qualityNotificationMessage.getCreatedBy()) - .createdByName(qualityNotificationMessage.getCreatedByName()) - .sendTo(qualityNotificationMessage.getSendTo()) - .sendToName(qualityNotificationMessage.getSendToName()) + .errorMessage(notificationMessage.getErrorMessage()) + .contractAgreementId(notificationMessage.getContractAgreementId()) + .created(notificationMessage.getCreated()) + .createdBy(notificationMessage.getCreatedBy()) + .createdByName(notificationMessage.getCreatedByName()) + .sendTo(notificationMessage.getSendTo()) + .sendToName(notificationMessage.getSendToName()) .assets(notificationAssets) - .notificationReferenceId(qualityNotificationMessage.getNotificationReferenceId()) - .targetDate(qualityNotificationMessage.getTargetDate()) - .severity(qualityNotificationMessage.getSeverity()) - .edcNotificationId(qualityNotificationMessage.getEdcNotificationId()) - .status(NotificationStatusBaseEntity.fromStringValue(qualityNotificationMessage.getNotificationStatus().name())) - .messageId(qualityNotificationMessage.getMessageId()) + .notificationReferenceId(notificationMessage.getNotificationReferenceId()) + .targetDate(notificationMessage.getTargetDate()) + .severity(notificationMessage.getSeverity()) + .edcNotificationId(notificationMessage.getEdcNotificationId()) + .status(NotificationStatusBaseEntity.fromStringValue(notificationMessage.getNotificationStatus().name())) + .messageId(notificationMessage.getMessageId()) .build(); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationSideBaseEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationSideBaseEntity.java similarity index 90% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationSideBaseEntity.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationSideBaseEntity.java index b760d88b1c..5f102328f2 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationSideBaseEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationSideBaseEntity.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.model; public enum NotificationSideBaseEntity { SENDER, diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationStatusBaseEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationStatusBaseEntity.java similarity index 86% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationStatusBaseEntity.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationStatusBaseEntity.java index 592c53bf6d..064752101e 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationStatusBaseEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationStatusBaseEntity.java @@ -16,10 +16,10 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.model; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import java.util.Arrays; import java.util.List; @@ -58,7 +58,7 @@ DECLINED, of(CLOSED), ); MAPPINGS = Arrays.stream(NotificationStatusBaseEntity.values()) - .collect(Collectors.toMap(Enum::name, qualityNotificationStatusBaseEntity -> qualityNotificationStatusBaseEntity)); + .collect(Collectors.toMap(Enum::name, notificationStatusBaseEntity -> notificationStatusBaseEntity)); } private final NotificationSideBaseEntity notificationSideBaseEntity; @@ -73,11 +73,11 @@ public static NotificationStatusBaseEntity fromStringValue(String value) { return MAPPINGS.get(value); } - public static NotificationStatusBaseEntity from(QualityNotificationStatus status) { + public static NotificationStatusBaseEntity from(NotificationStatus status) { return NotificationStatusBaseEntity.valueOf(status.name()); } - public static List from(List statuses) { + public static List from(List statuses) { return statuses.stream().map(NotificationStatusBaseEntity::from).toList(); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationTypeEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationTypeEntity.java similarity index 72% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationTypeEntity.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationTypeEntity.java index c2ea6cd95b..e6628a0f75 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/model/NotificationTypeEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/model/NotificationTypeEntity.java @@ -17,19 +17,19 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.model; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; public enum NotificationTypeEntity { ALERT, INVESTIGATION; - public QualityNotificationType toDomain() { - return QualityNotificationType.valueOf(this.name()); + public NotificationType toDomain() { + return NotificationType.valueOf(this.name()); } - public static NotificationTypeEntity from(QualityNotificationType type) { + public static NotificationTypeEntity from(NotificationType type) { return NotificationTypeEntity.valueOf(type.name()); } } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/JpaNotificationMessageRepository.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/JpaNotificationMessageRepository.java similarity index 83% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/JpaNotificationMessageRepository.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/JpaNotificationMessageRepository.java index 452febb0f0..e7d01e536f 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/JpaNotificationMessageRepository.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/JpaNotificationMessageRepository.java @@ -17,9 +17,9 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/JpaNotificationRepository.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/JpaNotificationRepository.java similarity index 80% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/JpaNotificationRepository.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/JpaNotificationRepository.java index 9b15862aba..411836a04c 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/JpaNotificationRepository.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/JpaNotificationRepository.java @@ -17,12 +17,12 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/NotificationRepositoryImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/NotificationRepositoryImpl.java similarity index 68% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/NotificationRepositoryImpl.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/NotificationRepositoryImpl.java index 41f2c4bfa2..48de2feb16 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/NotificationRepositoryImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/NotificationRepositoryImpl.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; @@ -31,19 +31,19 @@ import org.eclipse.tractusx.traceability.common.model.SearchCriteria; import org.eclipse.tractusx.traceability.common.repository.BaseSpecification; import org.eclipse.tractusx.traceability.common.repository.CriteriaUtility; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component; @@ -74,27 +74,17 @@ public class NotificationRepositoryImpl implements NotificationRepository { private EntityManager entityManager; @Override - public Optional findOptionalQualityNotificationById(QualityNotificationId notificationId) { + public Optional findOptionalNotificationById(NotificationId notificationId) { return jpaNotificationRepository.findById(notificationId.value()).map(NotificationEntity::toDomain); } @Override - public Optional findByEdcNotificationId(String edcNotificationId) { + public Optional findByEdcNotificationId(String edcNotificationId) { return jpaNotificationRepository.findByNotificationMessageEdcNotificationId(edcNotificationId).map(NotificationEntity::toDomain); } @Override - public Optional findByNotificationMessageId(String id) { - return jpaNotificationRepository.findByNotificationMessageId(id).map(NotificationEntity::toDomain); - } - - @Override - public long countQualityNotificationEntitiesBySide(QualityNotificationSide notificationSide) { - return jpaNotificationRepository.countAllBySideEquals(NotificationSideBaseEntity.valueOf(notificationSide.name())); - } - - @Override - public long countQualityNotificationEntitiesBySideAndNotificationType(QualityNotificationSide notificationSide, QualityNotificationType notificationType) { + public long countNotificationsBySideAndType(NotificationSide notificationSide, NotificationType notificationType) { return jpaNotificationRepository.countAllBySideEqualsAndTypeEquals( NotificationSideBaseEntity.valueOf(notificationSide.name()), NotificationTypeEntity.valueOf(notificationType.name()) @@ -102,7 +92,7 @@ public long countQualityNotificationEntitiesBySideAndNotificationType(QualityNot } @Override - public QualityNotificationId saveQualityNotificationEntity(QualityNotification notification) { + public NotificationId saveNotification(Notification notification) { List assetEntities = getAssetEntitiesByNotification(notification); if (assetEntities.isEmpty()) { @@ -114,11 +104,11 @@ public QualityNotificationId saveQualityNotificationEntity(QualityNotification n notification.getNotifications().forEach(notificationMessage -> handleNotificationCreate(notificationEntity, notificationMessage, assetEntities)); - return new QualityNotificationId(notificationEntity.getId()); + return new NotificationId(notificationEntity.getId()); } @Override - public void updateQualityNotificationEntity(QualityNotification notification) { + public void updateNotification(Notification notification) { NotificationEntity notificationEntity = jpaNotificationRepository.findById(notification.getNotificationId().value()) .orElseThrow(() -> new IllegalArgumentException(String.format("Investigation with id %s not found!", notification.getNotificationId().value()))); @@ -132,7 +122,7 @@ public void updateQualityNotificationEntity(QualityNotification notification) { } @Override - public PageResult getNotifications(Pageable pageable, SearchCriteria searchCriteria) { + public PageResult getNotifications(Pageable pageable, SearchCriteria searchCriteria) { List notificationSpecifications = emptyIfNull(searchCriteria.getSearchCriteriaFilterList()) .stream() .map(NotificationSpecification::new) @@ -141,23 +131,10 @@ public PageResult getNotifications(Pageable pageable, Searc return new PageResult<>(jpaNotificationRepository.findAll(specification, pageable), NotificationEntity::toDomain); } - @Transactional - @Override - public long countOpenNotificationsByOwnership(List owners) { - return jpaNotificationRepository.findAllByStatusIn(NotificationStatusBaseEntity.from(QualityNotificationStatus.ACTIVE_STATES)) - .stream() - .map(NotificationEntity::getAssets) - .flatMap(Collection::stream) - .filter(assetAsBuiltEntity -> owners.contains(assetAsBuiltEntity.getOwner())) - .distinct() - .toList() - .size(); - } - @Override - public long countOpenNotificationsByOwnershipAndNotificationType(List owners, QualityNotificationType notificationType) { + public long countOpenNotificationsByOwnershipAndNotificationType(List owners, NotificationType notificationType) { return jpaNotificationRepository.findAllByStatusInAndType( - NotificationStatusBaseEntity.from(QualityNotificationStatus.ACTIVE_STATES), + NotificationStatusBaseEntity.from(NotificationStatus.ACTIVE_STATES), NotificationTypeEntity.from(notificationType)) .stream() .map(NotificationEntity::getAssets) @@ -169,17 +146,17 @@ public long countOpenNotificationsByOwnershipAndNotificationType(List own } @Override - public List getDistinctFieldValues(String fieldName, String startWith, Integer resultLimit, QualityNotificationSide side) { + public List getDistinctFieldValues(String fieldName, String startWith, Integer resultLimit, NotificationSide side) { return CriteriaUtility.getDistinctNotificationFieldValues(fieldName, startWith, resultLimit, side, NotificationEntity.class, entityManager); } @Override - public void updateErrorMessage(QualityNotification notification) { + public void updateErrorMessage(Notification notification) { log.info("Starting update of error message with notification {}", notification); NotificationEntity notificationEntity = jpaNotificationRepository.findById(notification.getNotificationId().value()) .orElseThrow(() -> new IllegalArgumentException(String.format("Notification with id %s not found!", notification.getNotificationId().value()))); - for (QualityNotificationMessage notificationMessage : notification.getNotifications()) { + for (NotificationMessage notificationMessage : notification.getNotifications()) { List assetEntitiesByNotification = getAssetEntitiesByNotification(notification); NotificationMessageEntity notificationMessageEntity = toNotificationMessageEntity(notificationEntity, notificationMessage, assetEntitiesByNotification); Optional optionalNotificationMessage = jpaNotificationMessageRepository.findById(notificationMessageEntity.getId()); @@ -193,11 +170,11 @@ public void updateErrorMessage(QualityNotification notification) { jpaNotificationRepository.save(notificationEntity); } - private List getAssetEntitiesByNotification(QualityNotification notification) { + private List getAssetEntitiesByNotification(Notification notification) { return assetsAsBuiltRepository.findByIdIn(notification.getAssetIds()); } - private void handleNotificationCreate(NotificationEntity notificationEntity, QualityNotificationMessage notificationDomain, List assetEntities) { + private void handleNotificationCreate(NotificationEntity notificationEntity, NotificationMessage notificationDomain, List assetEntities) { NotificationMessageEntity notificationMessageEntity = toNotificationMessageEntity(notificationEntity, notificationDomain, assetEntities); Optional optionalNotificationMessage = jpaNotificationMessageRepository.findById(notificationMessageEntity.getId()); @@ -214,7 +191,7 @@ private void handleNotificationCreate(NotificationEntity notificationEntity, Qua }); } - private NotificationMessageEntity toNotificationMessageEntity(NotificationEntity notificationEntity, QualityNotificationMessage notification, List investigationAssets) { + private NotificationMessageEntity toNotificationMessageEntity(NotificationEntity notificationEntity, NotificationMessage notification, List investigationAssets) { List notificationAssets = filterNotificationAssets(notification, investigationAssets); if (notificationAssets.isEmpty()) { @@ -223,14 +200,14 @@ private NotificationMessageEntity toNotificationMessageEntity(NotificationEntity return NotificationMessageEntity.from(notificationEntity, notification, notificationAssets); } - private List filterNotificationAssets(QualityNotificationMessage notificationMessage, List assets) { - Set notificationAffectedAssetIds = notificationMessage.getAffectedParts().stream().map(QualityNotificationAffectedPart::assetId).collect(Collectors.toSet()); + private List filterNotificationAssets(NotificationMessage notificationMessage, List assets) { + Set notificationAffectedAssetIds = notificationMessage.getAffectedParts().stream().map(NotificationAffectedPart::assetId).collect(Collectors.toSet()); return assets.stream().filter(it -> notificationAffectedAssetIds.contains(it.getId())).toList(); } - private void handleNotificationUpdate(NotificationEntity notificationEntity, QualityNotification notification) { - for (QualityNotificationMessage notificationMessage : notification.getNotifications()) { + private void handleNotificationUpdate(NotificationEntity notificationEntity, Notification notification) { + for (NotificationMessage notificationMessage : notification.getNotifications()) { List assetEntitiesByNotification = getAssetEntitiesByNotification(notification); handleNotificationCreate(notificationEntity, notificationMessage, assetEntitiesByNotification); } diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/NotificationSpecification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/NotificationSpecification.java similarity index 89% rename from tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/NotificationSpecification.java rename to tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/NotificationSpecification.java index 8e68d0b5f7..c0009a0f77 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/notification/repository/NotificationSpecification.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/notification/infrastructure/notification/repository/NotificationSpecification.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository; +package org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaQuery; @@ -25,7 +25,7 @@ import jakarta.persistence.criteria.Root; import org.eclipse.tractusx.traceability.common.model.SearchCriteriaFilter; import org.eclipse.tractusx.traceability.common.repository.BaseSpecification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; import org.jetbrains.annotations.NotNull; import org.springframework.data.jpa.domain.Specification; diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/NotificationResponseMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/NotificationResponseMapper.java deleted file mode 100644 index c7d2c1560f..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/NotificationResponseMapper.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2024 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.traceability.qualitynotification.application.notification.mapper; - -import lombok.experimental.UtilityClass; -import org.eclipse.tractusx.traceability.common.model.PageResult; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import qualitynotification.base.response.QualityNotificationReasonResponse; -import qualitynotification.base.response.QualityNotificationResponse; - -import java.time.Instant; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static org.eclipse.tractusx.traceability.qualitynotification.application.notification.mapper.QualityNotificationMapper.fromNotifications; - -@UtilityClass -public class NotificationResponseMapper { - - public static QualityNotificationResponse from(QualityNotification qualityNotification) { - return QualityNotificationResponse - .builder() - .id(qualityNotification.getNotificationId().value()) - .status(QualityNotificationMapper.from(qualityNotification.getNotificationStatus())) - .description(qualityNotification.getDescription()) - .createdBy(getSenderBPN(qualityNotification.getNotifications())) - .createdByName(getSenderName(qualityNotification.getNotifications())) - .createdDate(qualityNotification.getCreatedAt().toString()) - .assetIds(Collections.unmodifiableList(qualityNotification.getAssetIds())) - .channel(QualityNotificationMapper.from(qualityNotification.getNotificationSide())) - .type(QualityNotificationMapper.from(qualityNotification.getNotificationType())) - .reason(new QualityNotificationReasonResponse( - qualityNotification.getCloseReason(), - qualityNotification.getAcceptReason(), - qualityNotification.getDeclineReason() - )) - .sendTo(getReceiverBPN(qualityNotification.getNotifications())) - .sendToName(getReceiverName(qualityNotification.getNotifications())) - .severity(QualityNotificationMapper.from(qualityNotification.getNotifications().stream().findFirst().map(QualityNotificationMessage::getSeverity).orElse(QualityNotificationSeverity.MINOR))) - .targetDate(qualityNotification.getNotifications().stream().findFirst().map(QualityNotificationMessage::getTargetDate).map(Instant::toString).orElse(null)) - .messages(fromNotifications(qualityNotification.getNotifications())) - .build(); - } - - public static PageResult fromAsPageResult(PageResult qualityNotificationPageResult) { - List investigationResponses = qualityNotificationPageResult.content().stream().map(NotificationResponseMapper::from).toList(); - int pageNumber = qualityNotificationPageResult.page(); - int pageSize = qualityNotificationPageResult.pageSize(); - Pageable pageable = PageRequest.of(pageNumber, pageSize); - - Page investigationDataPage = new PageImpl<>(investigationResponses, pageable, qualityNotificationPageResult.totalItems()); - return new PageResult<>(investigationDataPage); - } - - private static String getSenderBPN(Collection notifications) { - return notifications.stream() - .findFirst() - .map(QualityNotificationMessage::getCreatedBy) - .orElse(null); - } - - private static String getReceiverBPN(Collection notifications) { - return notifications.stream() - .findFirst() - .map(QualityNotificationMessage::getSendTo) - .orElse(null); - } - - private static String getSenderName(Collection notifications) { - return notifications.stream() - .findFirst() - .map(QualityNotificationMessage::getCreatedByName) - .orElse(null); - } - - private static String getReceiverName(Collection notifications) { - return notifications.stream() - .findFirst() - .map(QualityNotificationMessage::getSendToName) - .orElse(null); - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/QualityNotificationMapper.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/QualityNotificationMapper.java deleted file mode 100644 index 0677b665a8..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/mapper/QualityNotificationMapper.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.traceability.qualitynotification.application.notification.mapper; - -import lombok.experimental.UtilityClass; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import qualitynotification.base.response.QualityNotificationMessageResponse; -import qualitynotification.base.response.QualityNotificationResponse; -import qualitynotification.base.response.QualityNotificationSeverityResponse; -import qualitynotification.base.response.QualityNotificationSideResponse; -import qualitynotification.base.response.QualityNotificationStatusResponse; -import qualitynotification.base.response.QualityNotificationTypeResponse; - -import java.util.List; - -@UtilityClass -public class QualityNotificationMapper { - - public static QualityNotificationSeverityResponse from(QualityNotificationSeverity qualityNotificationSeverity) { - return QualityNotificationSeverityResponse.fromString(qualityNotificationSeverity.getRealName()); - } - - public static QualityNotificationSideResponse from(QualityNotificationSide side) { - return QualityNotificationSideResponse.valueOf(side.name()); - } - - public static QualityNotificationStatusResponse from(QualityNotificationStatus qualityNotificationStatus) { - return QualityNotificationStatusResponse.fromStringValue(qualityNotificationStatus.name()); - } - - public static QualityNotificationTypeResponse from(QualityNotificationType qualityNotificationType) { - return QualityNotificationTypeResponse.valueOf(qualityNotificationType.name()); - } - - public static List fromNotifications(List notificationMessages) { - return notificationMessages.stream().map(QualityNotificationMapper::fromNotification).toList(); - } - - public static QualityNotificationMessageResponse fromNotification(QualityNotificationMessage notificationMessage) { - return QualityNotificationMessageResponse - .builder() - .id(notificationMessage.getId()) - .severity(notificationMessage.getSeverity() != null ? QualityNotificationSeverityResponse.fromString(notificationMessage.getSeverity().getRealName()) : null) - .notificationReferenceId(notificationMessage.getNotificationReferenceId()) - .edcNotificationId(notificationMessage.getEdcNotificationId()) - .contractAgreementId(notificationMessage.getContractAgreementId()) - .notificationReferenceId(notificationMessage.getNotificationReferenceId()) - .messageId(notificationMessage.getMessageId()) - .updated(notificationMessage.getUpdated()) - .sendToName(notificationMessage.getSendToName()) - .status(fromStatus(notificationMessage.getNotificationStatus())) - .targetDate(notificationMessage.getTargetDate()) - .created(notificationMessage.getCreated()) - .createdBy(notificationMessage.getCreatedBy()) - .createdByName(notificationMessage.getCreatedByName()) - .sendTo(notificationMessage.getSendTo()) - .errorMessage(notificationMessage.getErrorMessage()) - .build(); - } - - public static QualityNotificationStatusResponse fromStatus(QualityNotificationStatus qualityNotificationStatus) { - return QualityNotificationStatusResponse.fromStringValue(qualityNotificationStatus.name()); - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/validation/UpdateQualityNotificationValidator.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/validation/UpdateQualityNotificationValidator.java deleted file mode 100644 index 00fc19d5b9..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/application/notification/validation/UpdateQualityNotificationValidator.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.traceability.qualitynotification.application.notification.validation; - -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import qualitynotification.base.request.UpdateQualityNotificationRequest; - -import java.util.Set; - -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.ACCEPTED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.ACKNOWLEDGED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.DECLINED; - -public class UpdateQualityNotificationValidator { - - private static final Set ALLOWED_STATUSES = Set.of(ACKNOWLEDGED, ACCEPTED, DECLINED); - - private static final int MINIMUM_REASON_CHARACTERS_SIZE = 15; - private static final int MAXIMUM_REASON_CHARACTERS_SIZE = 1000; - - private UpdateQualityNotificationValidator() { - } - - public static void validate(UpdateQualityNotificationRequest updateInvestigationRequest) { - QualityNotificationStatus status = QualityNotificationStatus.fromStringValue(updateInvestigationRequest.getStatus().name()); - - if (!ALLOWED_STATUSES.contains(status)) { - throw new UpdateQualityNotificationValidationException("%s not allowed for update investigation with".formatted(status)); - } - - String reason = updateInvestigationRequest.getReason(); - - if (status == ACKNOWLEDGED && (reason != null && !reason.isBlank())) { - throw new UpdateQualityNotificationValidationException("Update investigation reason can't be present for %s status".formatted(ACKNOWLEDGED)); - - } - - if (status != ACKNOWLEDGED) { - if (reason == null || reason.isBlank()) { - throw new UpdateQualityNotificationValidationException("Update investigation reason must be present"); - } - - if (reason.length() < MINIMUM_REASON_CHARACTERS_SIZE || reason.length() > MAXIMUM_REASON_CHARACTERS_SIZE) { - throw new UpdateQualityNotificationValidationException("Reason should have at least %d characters and at most %d characters".formatted(MINIMUM_REASON_CHARACTERS_SIZE, MAXIMUM_REASON_CHARACTERS_SIZE)); - } - } - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationStatus.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationStatus.java deleted file mode 100644 index 62b0b0034b..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationStatus.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; - -import qualitynotification.base.request.QualityNotificationStatusRequest; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -import static java.util.Collections.emptySet; -import static java.util.Set.of; - -public enum QualityNotificationStatus { - CREATED(QualityNotificationSide.SENDER, emptySet()), - SENT(QualityNotificationSide.SENDER, Set.of(QualityNotificationSide.SENDER)), - RECEIVED(QualityNotificationSide.RECEIVER, emptySet()), - ACKNOWLEDGED(QualityNotificationSide.RECEIVER, Set.of(QualityNotificationSide.RECEIVER, QualityNotificationSide.SENDER)), - ACCEPTED(QualityNotificationSide.RECEIVER, Set.of(QualityNotificationSide.RECEIVER)), - DECLINED(QualityNotificationSide.RECEIVER, Set.of(QualityNotificationSide.RECEIVER)), - CANCELED(QualityNotificationSide.SENDER, Set.of(QualityNotificationSide.SENDER)), - CLOSED(QualityNotificationSide.SENDER, of(QualityNotificationSide.SENDER, QualityNotificationSide.RECEIVER)); - - private static final Map> STATE_MACHINE; - private static final Set NO_TRANSITION_ALLOWED = emptySet(); - private static final Map MAPPINGS; - - public static final List ACTIVE_STATES = List.of(CREATED, SENT, RECEIVED, ACKNOWLEDGED, ACCEPTED, DECLINED); - - static { - STATE_MACHINE = Map.of( - CREATED, of(SENT, CANCELED), - SENT, of(RECEIVED, CLOSED, ACKNOWLEDGED), - RECEIVED, of(ACKNOWLEDGED, CLOSED), - ACKNOWLEDGED, of(DECLINED, ACCEPTED, CLOSED), - ACCEPTED, of(CLOSED), - DECLINED, of(CLOSED), - CLOSED, NO_TRANSITION_ALLOWED, - CANCELED, NO_TRANSITION_ALLOWED - ); - - MAPPINGS = Arrays.stream(QualityNotificationStatus.values()) - .collect(Collectors.toMap(Enum::name, qualityNotificationStatus -> qualityNotificationStatus)); - } - - private final QualityNotificationSide qualityNotificationSide; - private final Set allowedTransitionFromSide; - - QualityNotificationStatus(QualityNotificationSide qualityNotificationSide, Set allowedTransitionFromSide) { - this.qualityNotificationSide = qualityNotificationSide; - this.allowedTransitionFromSide = allowedTransitionFromSide; - } - - public static Optional fromValue(String value) { - return Optional.ofNullable(MAPPINGS.get(value)); - } - - public static QualityNotificationStatus fromStringValue(String value) { - return MAPPINGS.get(value); - } - - public static QualityNotificationStatus getPreviousStatus(QualityNotificationStatus status) { - return switch (status) { - case CREATED, SENT, CANCELED -> QualityNotificationStatus.CREATED; - case ACKNOWLEDGED, RECEIVED, CLOSED -> QualityNotificationStatus.SENT; - case ACCEPTED, DECLINED -> QualityNotificationStatus.ACKNOWLEDGED; - }; - } - public boolean transitionAllowed(QualityNotificationStatus to) { - - Set allowedStatusesToTransition = STATE_MACHINE.get(this); - - if (!allowedStatusesToTransition.contains(to)) { - return false; - } - - return isSideEligibleForTransition(this, to); - } - - private boolean isSideEligibleForTransition(QualityNotificationStatus from, QualityNotificationStatus to) { - return to.allowedTransitionFromSide.contains(from.qualityNotificationSide); - } - - public boolean isActiveState() { - return ACTIVE_STATES.contains(this); - } - - - public static QualityNotificationStatus from(QualityNotificationStatusRequest qualityNotificationStatusRequest) { - return QualityNotificationStatus.fromStringValue(qualityNotificationStatusRequest.name()); - } - - public static QualityNotificationStatus from(UpdateQualityNotificationStatusRequest qualityNotificationStatusRequest) { - return QualityNotificationStatus.fromStringValue(qualityNotificationStatusRequest.name()); - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/AbstractQualityNotificationReceiverService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/AbstractQualityNotificationReceiverService.java deleted file mode 100644 index 338bbd138f..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/AbstractQualityNotificationReceiverService.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2024 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; - -import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.traceability.common.mapper.NotificationMessageMapper; -import org.eclipse.tractusx.traceability.common.mapper.QualityNotificationMapper; -import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.QualityNotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; - -@Slf4j -public abstract class AbstractQualityNotificationReceiverService implements QualityNotificationReceiverService { - - protected abstract QualityNotificationRepository getRepository(); - - protected abstract NotificationMessageMapper getNotificationMessageMapper(); - - protected abstract QualityNotificationMapper getQualityNotificationMapper(); - - protected abstract RuntimeException getNotFoundException(String message); - - protected abstract RuntimeException getIllegalUpdateException(String message); - - @Override - public void handleReceive(EDCNotification edcNotification, QualityNotificationType notificationType) { - BPN investigationCreatorBPN = BPN.of(edcNotification.getSenderBPN()); - QualityNotificationMessage notification = getNotificationMessageMapper().toNotification(edcNotification, notificationType); - QualityNotification investigation = getQualityNotificationMapper().toQualityNotification(investigationCreatorBPN, edcNotification.getInformation(), notification, notificationType); - QualityNotificationId investigationId = getRepository().saveQualityNotificationEntity(investigation); - log.info("Stored received edcNotification in investigation with id {}", investigationId); - } - - @Override - public void handleUpdate(EDCNotification edcNotification, QualityNotificationType notificationType) { - QualityNotificationMessage notification = getNotificationMessageMapper().toNotification(edcNotification, notificationType); - QualityNotification qualityNotification = getRepository().findByEdcNotificationId(edcNotification.getNotificationId()) - .orElseThrow(() -> getNotFoundException(edcNotification.getNotificationId())); - - switch (edcNotification.convertNotificationStatus()) { - case ACKNOWLEDGED -> qualityNotification.acknowledge(); - case ACCEPTED -> qualityNotification.accept(edcNotification.getInformation()); - case DECLINED -> qualityNotification.decline(edcNotification.getInformation()); - case CLOSED -> - qualityNotification.close(BPN.of(qualityNotification.getBpn()), edcNotification.getInformation()); - default -> - throw getIllegalUpdateException("Failed to handle notification due to unhandled %s status".formatted(edcNotification.convertNotificationStatus())); - } - qualityNotification.addNotification(notification); - getRepository().updateQualityNotificationEntity(qualityNotification); - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/AbstractQualityNotificationService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/AbstractQualityNotificationService.java deleted file mode 100644 index 3b81cfa675..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/AbstractQualityNotificationService.java +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.traceability.common.model.PageResult; -import org.eclipse.tractusx.traceability.common.model.SearchCriteria; -import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.service.QualityNotificationService; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.model.StartQualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.QualityNotificationRepository; -import org.springframework.data.domain.Pageable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.UUID; - -@RequiredArgsConstructor -@Slf4j -public abstract class AbstractQualityNotificationService implements QualityNotificationService { - - private final TraceabilityProperties traceabilityProperties; - private final NotificationPublisherService notificationPublisherService; - private static final List SUPPORTED_ENUM_FIELDS = List.of("status", "side", "messages_severity", "type"); - - protected abstract QualityNotificationRepository getQualityNotificationRepository(); - - protected abstract RuntimeException getNotFoundException(String message); - - @Override - public PageResult getNotifications(Pageable pageable, SearchCriteria searchCriteria) { - return getQualityNotificationRepository().getNotifications(pageable, searchCriteria); - } - - @Override - public QualityNotificationId start(StartQualityNotification startQualityNotification) { - QualityNotification notification = notificationPublisherService.startQualityNotification(startQualityNotification); - QualityNotificationId createdAlertId = getQualityNotificationRepository().saveQualityNotificationEntity(notification); - log.info("Start Quality Notification {}", notification); - return createdAlertId; - } - - @Override - public void update(Long notificationId, QualityNotificationStatus notificationStatus, String reason) { - QualityNotification qualityNotification = loadOrNotFoundException(new QualityNotificationId(notificationId)); - - QualityNotificationStatus previousStatus = QualityNotificationStatus.getPreviousStatus(notificationStatus); - - /* Create a copy of the latest notifications. - As per asset there will be a notification created on start - it is possible that several elements with the same previous state are returned.*/ - qualityNotification.getNotifications().stream() - .filter(notificationMessage -> notificationMessage.getNotificationStatus().equals(previousStatus)) - .forEach(notificationMessage -> { - QualityNotificationMessage qualityNotificationMessage = notificationMessage.copyAndSwitchSenderAndReceiver(traceabilityProperties.getBpn()); - qualityNotificationMessage.setId(UUID.randomUUID().toString()); - qualityNotificationMessage.changeStatusTo(notificationStatus); - qualityNotificationMessage.setDescription(reason); - qualityNotification.addNotification(qualityNotificationMessage); - }); - - QualityNotification updatedQualityNotification; - try { - updatedQualityNotification = notificationPublisherService.updateNotificationPublisher(qualityNotification, notificationStatus, reason); - } catch (SendNotificationException exception) { - log.info("Notification status rollback", exception); - throw new SendNotificationException(exception.getMessage()); - } - - getQualityNotificationRepository().updateQualityNotificationEntity(updatedQualityNotification); - } - - @Override - public QualityNotification find(Long id) { - QualityNotificationId investigationId = new QualityNotificationId(id); - return loadOrNotFoundException(investigationId); - } - - @Override - public void approve(Long notificationId) { - QualityNotification notification = loadOrNotFoundException(new QualityNotificationId(notificationId)); - List createdNotifications = notification - .getNotifications() - .stream() - .filter(notificationMessage -> notificationMessage.getNotificationStatus().equals(QualityNotificationStatus.CREATED)) - .map(notificationMessage -> notificationMessage.toBuilder().build()) - .toList(); - - log.info("Found {} notification messages in status CREATED", createdNotifications.size()); - List approvedNotifications = new ArrayList<>(createdNotifications); - approvedNotifications.forEach(notificationMessage -> { - notificationMessage.setId(UUID.randomUUID().toString()); - notificationMessage.changeStatusTo(QualityNotificationStatus.SENT); - }); - log.info("Found {} notification messages in status SENT", approvedNotifications.size()); - - notification.addNotifications(approvedNotifications); - log.info("Found {} notification messages at all", notification.getNotifications().size()); - notification.getNotifications().stream().map(notificationMessage -> notificationMessage.getNotificationStatus().name()).forEach(s -> log.info("Notification Status {} ", s)); - - final QualityNotification approvedInvestigation; - try { - approvedInvestigation = notificationPublisherService.approveNotification(notification); - } catch (SendNotificationException exception) { - log.info("Notification status rollback", exception); - throw new SendNotificationException(exception.getMessage()); - } - getQualityNotificationRepository().updateQualityNotificationEntity(approvedInvestigation); - } - - @Override - public void cancel(Long notificationId) { - QualityNotification qualityNotification = loadOrNotFoundException(new QualityNotificationId(notificationId)); - QualityNotification canceledQualityNotification = notificationPublisherService.cancelNotification(qualityNotification); - - getQualityNotificationRepository().updateQualityNotificationEntity(canceledQualityNotification); - } - - @Override - public List getDistinctFilterValues(String fieldName, String startWith, Integer size, QualityNotificationSide side) { - final Integer resultSize = Objects.isNull(size) ? Integer.MAX_VALUE : size; - - if (isSupportedEnumType(fieldName)) { - return getAssetEnumFieldValues(fieldName); - } - return getQualityNotificationRepository().getDistinctFieldValues(fieldName, startWith, resultSize, side); - } - - @Override - public QualityNotification loadOrNotFoundException(QualityNotificationId investigationId) { - return getQualityNotificationRepository().findOptionalQualityNotificationById(investigationId) - .orElseThrow(() -> getNotFoundException(investigationId.value().toString())); - } - - @Override - public QualityNotification loadByEdcNotificationIdOrNotFoundException(String edcNotificationId) { - return getQualityNotificationRepository().findByEdcNotificationId(edcNotificationId) - .orElseThrow(() -> getNotFoundException(edcNotificationId)); - } - - private boolean isSupportedEnumType(String fieldName) { - return SUPPORTED_ENUM_FIELDS.contains(fieldName); - } - - private List getAssetEnumFieldValues(String fieldName) { - return switch (fieldName) { - case "status" -> Arrays.stream(QualityNotificationStatus.values()).map(Enum::name).toList(); - case "side" -> Arrays.stream(QualityNotificationSide.values()).map(Enum::name).toList(); - case "messages_severity" -> - Arrays.stream(QualityNotificationSeverity.values()).map(Enum::name).toList(); - case "type" -> - Arrays.stream(QualityNotificationType.values()).map(Enum::name).toList(); - default -> null; - }; - } -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/QualityNotificationReceiverService.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/QualityNotificationReceiverService.java deleted file mode 100644 index cb7fa3ee8f..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/QualityNotificationReceiverService.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.service; - -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; - -public interface QualityNotificationReceiverService { - - void handleReceive(EDCNotification edcNotification, QualityNotificationType notificationType); - - void handleUpdate(EDCNotification edcNotification, QualityNotificationType notificationType); -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/model/StartQualityNotification.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/model/StartQualityNotification.java deleted file mode 100644 index e1fb515538..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/model/StartQualityNotification.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.model; - -import lombok.Builder; -import lombok.Data; -import lombok.Getter; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import qualitynotification.base.request.StartQualityNotificationRequest; - -import java.time.Instant; -import java.util.List; - -@Builder -@Getter -@Data -public class StartQualityNotification { - - private String title; - - private List partIds; - - private String description; - - private Instant targetDate; - - private QualityNotificationSeverity severity; - - private QualityNotificationType type; - - private boolean isAsBuilt; - - private String receiverBpn; - - - public static StartQualityNotification from(StartQualityNotificationRequest startQualityNotificationRequest) { - return StartQualityNotification.builder() - .title(startQualityNotificationRequest.getTitle()) - .partIds(startQualityNotificationRequest.getPartIds()) - .description(startQualityNotificationRequest.getDescription()) - .targetDate(startQualityNotificationRequest.getTargetDate()) - .severity(QualityNotificationSeverity.from(startQualityNotificationRequest.getSeverity())) - .type(QualityNotificationType.from(startQualityNotificationRequest.getType())) - .receiverBpn(startQualityNotificationRequest.getReceiverBpn()) - .isAsBuilt(startQualityNotificationRequest.isAsBuilt()) - .build(); - } - - -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/repository/NotificationRepository.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/repository/NotificationRepository.java deleted file mode 100644 index c7728ebb53..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/repository/NotificationRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2024 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository; - -public interface NotificationRepository extends QualityNotificationRepository { -} diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/repository/QualityNotificationRepository.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/repository/QualityNotificationRepository.java deleted file mode 100644 index 534c97a007..0000000000 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/notification/repository/QualityNotificationRepository.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * Copyright (c) 2022, 2023 ZF Friedrichshafen AG - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository; - -import org.eclipse.tractusx.traceability.assets.domain.base.model.Owner; -import org.eclipse.tractusx.traceability.common.model.PageResult; -import org.eclipse.tractusx.traceability.common.model.SearchCriteria; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.springframework.data.domain.Pageable; - -import java.util.List; -import java.util.Optional; - -public interface QualityNotificationRepository { - - Optional findOptionalQualityNotificationById(QualityNotificationId investigationId); - - Optional findByEdcNotificationId(String edcNotificationId); - - Optional findByNotificationMessageId(String id); - - long countQualityNotificationEntitiesBySide(QualityNotificationSide investigationSide); - - long countQualityNotificationEntitiesBySideAndNotificationType(QualityNotificationSide investigationSide, QualityNotificationType notificationType); - - QualityNotificationId saveQualityNotificationEntity(QualityNotification investigation); - - void updateQualityNotificationEntity(QualityNotification investigation); - - PageResult getNotifications(Pageable pageable, SearchCriteria searchCriteria); - - long countOpenNotificationsByOwnership(List owners); - - long countOpenNotificationsByOwnershipAndNotificationType(List owners, QualityNotificationType notificationType); - - List getDistinctFieldValues(String fieldName, String startWith, Integer resultLimit, QualityNotificationSide owner); - - void updateErrorMessage(QualityNotification investigation); - -} diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfigTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfigTest.java index 7a10dfaec3..0dbb28d7e3 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfigTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ApplicationStartupConfigTest.java @@ -21,7 +21,7 @@ import org.eclipse.tractusx.traceability.assets.domain.base.JobRepository; import org.eclipse.tractusx.traceability.assets.domain.base.PolicyRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.contract.EdcNotificationContractService; +import org.eclipse.tractusx.traceability.notification.domain.contract.EdcNotificationContractService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ErrorHandlingConfigTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ErrorHandlingConfigTest.java index 33c0716e91..f986de273f 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ErrorHandlingConfigTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/config/ErrorHandlingConfigTest.java @@ -30,15 +30,15 @@ import org.eclipse.tractusx.traceability.assets.domain.asbuilt.exception.AssetNotFoundException; import org.eclipse.tractusx.traceability.bpn.domain.model.BpnNotFoundException; import org.eclipse.tractusx.traceability.common.security.TechnicalUserAuthorizationException; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractException; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.validation.UpdateQualityNotificationValidationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationNotFoundException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationReceiverBpnMismatchException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationStatusTransitionNotAllowed; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationStatusTransitionNotAllowed; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractException; +import org.eclipse.tractusx.traceability.notification.application.notification.validation.UpdateNotificationValidationException; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationNotFoundException; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationReceiverBpnMismatchException; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationStatusTransitionNotAllowed; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationStatusTransitionNotAllowed; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; @@ -169,8 +169,8 @@ void givenNotificationStatusTransitionNotAllowed_handler_respondsBadRequest() th } @Test - void givenUpdateQualityNotificationValidationException_handler_respondsBadRequest() throws Exception { - mockMvc.perform(get("/updateQualityNotificationValidationException")) + void givenUpdateNotificationValidationException_handler_respondsBadRequest() throws Exception { + mockMvc.perform(get("/updateNotificationValidationException")) .andExpect(status().isBadRequest()); } @@ -261,9 +261,9 @@ public void investigationNotFoundException() { @GetMapping("/investigationStatusTransitionNotAllowed") public void investigationStatusTransitionNotAllowed() { throw new InvestigationStatusTransitionNotAllowed( - new QualityNotificationId(1L), - QualityNotificationStatus.CLOSED, - QualityNotificationStatus.ACCEPTED + new NotificationId(1L), + NotificationStatus.CLOSED, + NotificationStatus.ACCEPTED ); } @@ -311,13 +311,13 @@ public void authenticationCredentialsNotFoundException() { public void notificationStatusTransitionNotAllowed() { throw new NotificationStatusTransitionNotAllowed( "", - QualityNotificationStatus.CLOSED, - QualityNotificationStatus.ACCEPTED); + NotificationStatus.CLOSED, + NotificationStatus.ACCEPTED); } - @GetMapping("/updateQualityNotificationValidationException") - public void updateQualityNotificationValidationException() { - throw new UpdateQualityNotificationValidationException(""); + @GetMapping("/updateNotificationValidationException") + public void updateNotificationValidationException() { + throw new UpdateNotificationValidationException(""); } @GetMapping("/createNotificationContractException") diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapperTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapperTest.java index 0f532c0555..04b6a00464 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapperTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMapperTest.java @@ -21,11 +21,11 @@ package org.eclipse.tractusx.traceability.common.mapper; import org.eclipse.tractusx.traceability.bpn.domain.service.BpnRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationContent; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationHeader; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationContent; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationHeader; import org.eclipse.tractusx.traceability.testdata.NotificationTestDataFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -34,7 +34,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.util.List; -import java.util.Optional; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -59,13 +58,13 @@ void testToReceiverNotification() { EDCNotificationContent content = new EDCNotificationContent("information", List.of("partId")); EDCNotification edcNotification = new EDCNotification(header, content); - QualityNotificationMessage expectedNotification = NotificationTestDataFactory.createNotificationTestData(); + NotificationMessage expectedNotification = NotificationTestDataFactory.createNotificationTestData(); when(bpnRepository.findManufacturerName(eq(expectedNotification.getCreatedBy()))).thenReturn(expectedNotification.getCreatedByName()); when(bpnRepository.findManufacturerName(eq(expectedNotification.getSendTo()))).thenReturn(expectedNotification.getSendToName()); - QualityNotificationMessage actualNotification = notificationMapper.toNotification(edcNotification, QualityNotificationType.INVESTIGATION); + NotificationMessage actualNotification = notificationMapper.toNotification(edcNotification, NotificationType.INVESTIGATION); assertNotNull(actualNotification.getId()); assertEquals(expectedNotification.getNotificationReferenceId(), actualNotification.getNotificationReferenceId()); assertEquals(expectedNotification.getCreatedBy(), actualNotification.getCreatedBy()); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/QualityNotificationMapperTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMessageMapperTest.java similarity index 58% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/QualityNotificationMapperTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMessageMapperTest.java index 6f884dc409..f8f305852b 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/QualityNotificationMapperTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/common/mapper/NotificationMessageMapperTest.java @@ -21,13 +21,13 @@ package org.eclipse.tractusx.traceability.common.mapper; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -38,10 +38,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; @ExtendWith(MockitoExtension.class) -class QualityNotificationMapperTest { +class NotificationMessageMapperTest { @InjectMocks - private QualityNotificationMapper mapper; + private NotificationMapper mapper; @Test void testToReceiverInvestigation() { @@ -49,31 +49,31 @@ void testToReceiverInvestigation() { String sender = "BPNL000000000001"; String receiver = "BPNL000000000002"; String description = "Test investigation"; - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .id("1") .notificationReferenceId("Test notification") - .notificationStatus(QualityNotificationStatus.RECEIVED) - .affectedParts(List.of(new QualityNotificationAffectedPart("123"))) + .notificationStatus(NotificationStatus.RECEIVED) + .affectedParts(List.of(new NotificationAffectedPart("123"))) .createdByName("senderManufacturerName") .createdBy(sender) .sendTo(receiver) .sendToName("receiverManufacturerName") - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .messageId("1") .build(); - QualityNotificationType type = QualityNotificationType.INVESTIGATION; + NotificationType type = NotificationType.INVESTIGATION; // When - QualityNotification result = mapper.toQualityNotification(new BPN(receiver), description, notification, type); + Notification result = mapper.toNotification(new BPN(receiver), description, notification, type); // Then - assertEquals(QualityNotificationStatus.RECEIVED, result.getNotificationStatus()); - assertEquals(QualityNotificationSide.RECEIVER, result.getNotificationSide()); + assertEquals(NotificationStatus.RECEIVED, result.getNotificationStatus()); + assertEquals(NotificationSide.RECEIVER, result.getNotificationSide()); assertEquals(description, result.getDescription()); assertEquals(List.of("123"), result.getAssetIds()); assertEquals(List.of(notification), result.getNotifications()); - assertEquals(QualityNotificationType.INVESTIGATION, result.getNotificationType()); + assertEquals(NotificationType.INVESTIGATION, result.getNotificationType()); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/BadRequestExceptionTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/BadRequestExceptionTest.java index 0547dd61e0..c03df95475 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/BadRequestExceptionTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/BadRequestExceptionTest.java @@ -22,7 +22,7 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.BadRequestException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.BadRequestException; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/ContractNegotiationExceptionTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/ContractNegotiationExceptionTest.java index c76b46462d..9001b1880e 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/ContractNegotiationExceptionTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/ContractNegotiationExceptionTest.java @@ -19,7 +19,7 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.ContractNegotiationException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.ContractNegotiationException; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/NoCatalogItemExceptionTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/NoCatalogItemExceptionTest.java index c430d5a852..c1fedf969d 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/NoCatalogItemExceptionTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/NoCatalogItemExceptionTest.java @@ -19,7 +19,7 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoCatalogItemException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.NoCatalogItemException; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/NotificationsEDCFacadeTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/NotificationsEDCFacadeTest.java index 68740d7144..c83e8d1707 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/NotificationsEDCFacadeTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/NotificationsEDCFacadeTest.java @@ -27,13 +27,13 @@ import org.eclipse.tractusx.irs.edc.client.model.NegotiationResponse; import org.eclipse.tractusx.irs.edc.client.policy.PolicyCheckerService; import org.eclipse.tractusx.traceability.common.properties.EdcProperties; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.ContractNegotiationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoCatalogItemException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.service.NotificationsEDCFacade; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.ContractNegotiationException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.NoCatalogItemException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.service.NotificationsEDCFacade; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -73,9 +73,9 @@ void givenCorrectInvestigationMessageButSendRequestThrowsException_whenStartEdcT final String senderEdcUrl = "https://sender.com"; final String agreementId = "negotiationId"; final String dataReferenceEndpoint = "https://endpoint.com"; - final QualityNotificationMessage notificationMessage = QualityNotificationMessage.builder() - .type(QualityNotificationType.INVESTIGATION) - .notificationStatus(QualityNotificationStatus.CREATED) + final NotificationMessage notificationMessage = NotificationMessage.builder() + .type(NotificationType.INVESTIGATION) + .notificationStatus(NotificationStatus.CREATED) .build(); final CatalogItem catalogItem = CatalogItem.builder() .build(); @@ -102,9 +102,9 @@ void givenCorrectInvestigationMessageButNegotiateContractAgreementHasNoCatalogIt // given final String receiverEdcUrl = "https://receiver.com"; final String senderEdcUrl = "https://sender.com"; - final QualityNotificationMessage notificationMessage = QualityNotificationMessage.builder() - .type(QualityNotificationType.INVESTIGATION) - .notificationStatus(QualityNotificationStatus.CREATED) + final NotificationMessage notificationMessage = NotificationMessage.builder() + .type(NotificationType.INVESTIGATION) + .notificationStatus(NotificationStatus.CREATED) .build(); final CatalogItem catalogItem = CatalogItem.builder() .build(); @@ -124,9 +124,9 @@ void givenCorrectInvestigationMessageButCatalogItem_whenStartEdcTransfer_thenThr // given final String receiverEdcUrl = "https://receiver.com"; final String senderEdcUrl = "https://sender.com"; - final QualityNotificationMessage notificationMessage = QualityNotificationMessage.builder() - .type(QualityNotificationType.INVESTIGATION) - .notificationStatus(QualityNotificationStatus.CREATED) + final NotificationMessage notificationMessage = NotificationMessage.builder() + .type(NotificationType.INVESTIGATION) + .notificationStatus(NotificationStatus.CREATED) .build(); final String idsPath = "/api/v1/dsp"; when(edcProperties.getIdsPath()).thenReturn(idsPath); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/SendNotificationExceptionTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/SendNotificationExceptionTest.java index f2bbbfa5f0..01f8f7611a 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/SendNotificationExceptionTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/SendNotificationExceptionTest.java @@ -19,7 +19,7 @@ package org.eclipse.tractusx.traceability.infrastructure.edc.blackbox; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/validators/EDCNotificationValidatorTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/validators/EDCNotificationValidatorTest.java index ca8718ff92..986162f554 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/validators/EDCNotificationValidatorTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/blackbox/validators/EDCNotificationValidatorTest.java @@ -22,9 +22,9 @@ import jakarta.validation.ConstraintValidatorContext; import org.eclipse.tractusx.traceability.common.model.BPN; import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationReceiverBpnMismatchException; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.EDCNotificationValidator; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationReceiverBpnMismatchException; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.EDCNotificationValidator; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/model/EdcNotificationModelTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/model/EdcNotificationModelTest.java index 85cfbd9d9a..d21473efd7 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/model/EdcNotificationModelTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/model/EdcNotificationModelTest.java @@ -18,16 +18,16 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.infrastructure.edc.model; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationContent; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationHeader; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationContent; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationHeader; import org.junit.jupiter.api.Test; -import qualitynotification.base.request.CloseQualityNotificationRequest; -import qualitynotification.base.request.QualityNotificationSeverityRequest; -import qualitynotification.base.request.QualityNotificationTypeRequest; -import qualitynotification.base.request.StartQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; +import notification.request.CloseNotificationRequest; +import notification.request.NotificationSeverityRequest; +import notification.request.NotificationTypeRequest; +import notification.request.StartNotificationRequest; +import notification.request.UpdateNotificationRequest; +import notification.request.UpdateNotificationStatusRequest; import java.time.Instant; import java.util.ArrayList; @@ -78,15 +78,15 @@ public void testSanitizeEDCNotification() { } @Test - public void testSanitizeStartQualityNotificationRequest() { + public void testSanitizeStartNotificationRequest() { //GIVEN String title = "Title"; List partIds = new ArrayList<>(); partIds.add("urn:uuid:fe99da3d-b0de-4e80-81da-882aebcca978"); partIds.add("urn:uuid:fe99da3d-b0de-4e80-81da-882aebcca979\n"); Instant targetDate = Instant.parse("2023-09-22T14:30:00Z".trim()); - QualityNotificationSeverityRequest severity = QualityNotificationSeverityRequest.MINOR; - StartQualityNotificationRequest request = new StartQualityNotificationRequest( + NotificationSeverityRequest severity = NotificationSeverityRequest.MINOR; + StartNotificationRequest request = new StartNotificationRequest( title, partIds, "The description\n", @@ -94,12 +94,12 @@ public void testSanitizeStartQualityNotificationRequest() { severity, true, "BPN00001123123AS\n", - QualityNotificationTypeRequest.ALERT + NotificationTypeRequest.ALERT ); //WHEN - StartQualityNotificationRequest cleanRequest = sanitize(request); + StartNotificationRequest cleanRequest = sanitize(request); //THEN assertEquals("urn:uuid:fe99da3d-b0de-4e80-81da-882aebcca979 ", cleanRequest.getPartIds().get(1)); @@ -112,32 +112,32 @@ public void testSanitizeStartQualityNotificationRequest() { @Test public void testSanitizeCloseInvestigationRequest() { //GIVEN - CloseQualityNotificationRequest closeQualityNotificationRequest = CloseQualityNotificationRequest.builder() + CloseNotificationRequest closeNotificationRequest = CloseNotificationRequest.builder() .reason("Reason\n").build(); //WHEN - CloseQualityNotificationRequest cleanCloseQualityNotificationRequest = sanitize(closeQualityNotificationRequest); + CloseNotificationRequest cleanCloseNotificationRequest = sanitize(closeNotificationRequest); //THEN - assertEquals("Reason ", cleanCloseQualityNotificationRequest.getReason()); + assertEquals("Reason ", cleanCloseNotificationRequest.getReason()); } @Test - public void testSanitizeUpdateQualityNotificationRequest() { + public void testSanitizeUpdateNotificationRequest() { //GIVEN - UpdateQualityNotificationRequest updateQualityNotificationRequest = UpdateQualityNotificationRequest + UpdateNotificationRequest updateNotificationRequest = UpdateNotificationRequest .builder() .reason("Reason\n") - .status(UpdateQualityNotificationStatusRequest.ACCEPTED) + .status(UpdateNotificationStatusRequest.ACCEPTED) .build(); //WHEN - UpdateQualityNotificationRequest cleanUpdateQualityNotificationRequest = sanitize(updateQualityNotificationRequest); + UpdateNotificationRequest cleanUpdateNotificationRequest = sanitize(updateNotificationRequest); //THEN - assertEquals("Reason ", cleanUpdateQualityNotificationRequest.getReason()); + assertEquals("Reason ", cleanUpdateNotificationRequest.getReason()); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractServiceTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractServiceTest.java index 25a2e44bdf..59a6e218e7 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractServiceTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/infrastructure/edc/notificationcontract/service/EdcNotificationContractServiceTest.java @@ -34,12 +34,12 @@ import org.eclipse.tractusx.traceability.assets.application.importpoc.PolicyService; import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.IrsPolicyResponse; import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractException; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractRequest; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.CreateNotificationContractResponse; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.NotificationMethod; -import org.eclipse.tractusx.traceability.qualitynotification.application.contract.model.NotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.contract.EdcNotificationContractService; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractException; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractRequest; +import org.eclipse.tractusx.traceability.notification.application.contract.model.CreateNotificationContractResponse; +import org.eclipse.tractusx.traceability.notification.application.contract.model.NotificationMethod; +import org.eclipse.tractusx.traceability.notification.application.contract.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.contract.EdcNotificationContractService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerByIdIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerByIdIT.java index 9d407f38df..71b8b7130b 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerByIdIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerByIdIT.java @@ -39,14 +39,14 @@ import static io.restassured.RestAssured.given; import static org.eclipse.tractusx.traceability.common.security.JwtRole.ADMIN; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.ACCEPTED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.ACKNOWLEDGED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CANCELED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CLOSED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CREATED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.DECLINED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.ACCEPTED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.ACKNOWLEDGED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CANCELED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CLOSED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CREATED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.DECLINED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.junit.jupiter.params.provider.Arguments.arguments; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerFilteringIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerFilteringIT.java index 93b9218484..af9c9a29b5 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerFilteringIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/AssetAsBuiltControllerFilteringIT.java @@ -37,16 +37,16 @@ import static io.restassured.RestAssured.given; import static org.eclipse.tractusx.traceability.common.security.JwtRole.ADMIN; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity.RECEIVER; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity.SENDER; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.ACCEPTED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.ACKNOWLEDGED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CANCELED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CLOSED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CREATED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.DECLINED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity.RECEIVER; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity.SENDER; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.ACCEPTED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.ACKNOWLEDGED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CANCELED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CLOSED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CREATED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.DECLINED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; import static org.hamcrest.Matchers.equalTo; class AssetAsBuiltControllerFilteringIT extends IntegrationTestSpecification { diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/DashboardControllerIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/DashboardControllerIT.java index 9a2dd3e119..5d70d73bfb 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/DashboardControllerIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/assets/DashboardControllerIT.java @@ -36,9 +36,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException; import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper; -import qualitynotification.base.request.QualityNotificationSeverityRequest; -import qualitynotification.base.request.QualityNotificationTypeRequest; -import qualitynotification.base.request.StartQualityNotificationRequest; +import notification.request.NotificationSeverityRequest; +import notification.request.NotificationTypeRequest; +import notification.request.StartNotificationRequest; import java.util.List; import java.util.stream.Stream; @@ -47,8 +47,8 @@ import static org.eclipse.tractusx.traceability.common.security.JwtRole.ADMIN; import static org.eclipse.tractusx.traceability.common.security.JwtRole.SUPERVISOR; import static org.eclipse.tractusx.traceability.common.security.JwtRole.USER; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; import static org.hamcrest.Matchers.equalTo; import static org.junit.jupiter.params.provider.Arguments.arguments; @@ -161,11 +161,11 @@ void givenPendingInvestigation_whenGetDashboard_thenReturnPendingInvestigation() assetsSupport.defaultAssetsStored(); notificationSupport.defaultReceivedInvestigationStored(); String assetId = "urn:uuid:fe99da3d-b0de-4e80-81da-882aebcca978"; - var notificationRequest = StartQualityNotificationRequest.builder() + var notificationRequest = StartNotificationRequest.builder() .partIds(List.of(assetId)) .description("at least 15 characters long investigation description") - .severity(QualityNotificationSeverityRequest.MINOR) - .type(QualityNotificationTypeRequest.INVESTIGATION) + .severity(NotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.INVESTIGATION) .isAsBuilt(true) .build(); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/AlertNotificationsSupport.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/AlertNotificationsSupport.java index e7fecf05e4..d563450cce 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/AlertNotificationsSupport.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/AlertNotificationsSupport.java @@ -19,13 +19,13 @@ package org.eclipse.tractusx.traceability.integration.common.support; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationMessageRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationMessageRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -162,7 +162,7 @@ private void storeCreatedAlerts() { .status(NotificationStatusBaseEntity.CREATED) .sendTo(OTHER_BPN) .createdBy(OWN_BPN) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .targetDate(monthFromNow.minus(3L, DAYS)) .createdByName(OWN_BPN_COMPANY_NAME) .edcNotificationId("cda2d956-fa91-4a75-bb4a-8e5ba39b268a1") @@ -173,7 +173,7 @@ private void storeCreatedAlerts() { .createdBy(OWN_BPN) .createdByName(OWN_BPN_COMPANY_NAME) .status(NotificationStatusBaseEntity.SENT) - .severity(QualityNotificationSeverity.MAJOR) + .severity(NotificationSeverity.MAJOR) .id("2") .targetDate(monthFromNow.minus(2L, DAYS)) .notification(alert2) @@ -185,7 +185,7 @@ private void storeCreatedAlerts() { .id("3") .sendTo(OWN_BPN) .createdBy(OTHER_BPN) - .severity(QualityNotificationSeverity.CRITICAL) + .severity(NotificationSeverity.CRITICAL) .targetDate(monthFromNow.minus(1L, DAYS)) .createdByName(OTHER_BPN_COMPANY_NAME) .notification(alert3) @@ -196,7 +196,7 @@ private void storeCreatedAlerts() { .status(NotificationStatusBaseEntity.ACKNOWLEDGED) .id("4") .targetDate(monthFromNow) - .severity(QualityNotificationSeverity.LIFE_THREATENING) + .severity(NotificationSeverity.LIFE_THREATENING) .createdBy(OTHER_BPN) .createdByName(OTHER_BPN_COMPANY_NAME) .notification(alert4) @@ -207,7 +207,7 @@ private void storeCreatedAlerts() { .status(NotificationStatusBaseEntity.ACCEPTED) .id("5") .targetDate(monthFromNow) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .createdBy(OTHER_BPN) .createdByName(OTHER_BPN_COMPANY_NAME) .notification(alert5) @@ -217,7 +217,7 @@ private void storeCreatedAlerts() { .builder() .status(NotificationStatusBaseEntity.DECLINED) .id("6") - .severity(QualityNotificationSeverity.MAJOR) + .severity(NotificationSeverity.MAJOR) .targetDate(monthFromNow.plus(1L, DAYS)) .createdBy(OTHER_BPN) .createdByName(OTHER_BPN_COMPANY_NAME) @@ -229,7 +229,7 @@ private void storeCreatedAlerts() { .status(NotificationStatusBaseEntity.CANCELED) .id("7") .targetDate(monthFromNow.plus(2L, DAYS)) - .severity(QualityNotificationSeverity.CRITICAL) + .severity(NotificationSeverity.CRITICAL) .createdBy(OWN_BPN) .createdByName(OWN_BPN_COMPANY_NAME) .notification(alert7) @@ -239,7 +239,7 @@ private void storeCreatedAlerts() { .builder() .status(NotificationStatusBaseEntity.CLOSED) .id("8") - .severity(QualityNotificationSeverity.LIFE_THREATENING) + .severity(NotificationSeverity.LIFE_THREATENING) .targetDate(monthFromNow.plus(3L, DAYS)) .createdBy(OWN_BPN) .createdByName(OWN_BPN_COMPANY_NAME) diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/AlertsSupport.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/AlertsSupport.java index 15b65dec83..13c06ab97c 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/AlertsSupport.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/AlertsSupport.java @@ -21,12 +21,12 @@ import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.repository.JpaAssetAsBuiltRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -87,7 +87,7 @@ public void assertAlertsSize(int size) { assert alerts.size() == size; } - public void assertAlertStatus(QualityNotificationStatus alertStatus) { + public void assertAlertStatus(NotificationStatus alertStatus) { jpaNotificationRepository.findAll().forEach(alert -> assertThat(alert.getStatus().name()).isEqualTo(alertStatus.name()) ); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationNotificationsSupport.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationNotificationsSupport.java index 94a76a925a..9d249205f1 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationNotificationsSupport.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationNotificationsSupport.java @@ -20,13 +20,13 @@ package org.eclipse.tractusx.traceability.integration.common.support; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.repository.JpaAssetAsBuiltRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationMessageRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationMessageRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -166,7 +166,7 @@ private void storeCreatedInvestigations() { .id("1") .notification(investigation1) .status(NotificationStatusBaseEntity.CREATED) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .sendTo(OTHER_BPN) .createdBy(OWN_BPN) .targetDate(monthFromNow.minus(3L, DAYS)) @@ -179,7 +179,7 @@ private void storeCreatedInvestigations() { .createdBy(OWN_BPN) .createdByName(OWN_BPN_COMPANY_NAME) .status(NotificationStatusBaseEntity.SENT) - .severity(QualityNotificationSeverity.MAJOR) + .severity(NotificationSeverity.MAJOR) .id("2") .targetDate(monthFromNow.minus(2L, DAYS)) .notification(investigation2) @@ -189,7 +189,7 @@ private void storeCreatedInvestigations() { .builder() .status(NotificationStatusBaseEntity.RECEIVED) .id("3") - .severity(QualityNotificationSeverity.CRITICAL) + .severity(NotificationSeverity.CRITICAL) .targetDate(monthFromNow.minus(1L, DAYS)) .sendTo(OTHER_BPN) .createdBy(OTHER_BPN) @@ -202,7 +202,7 @@ private void storeCreatedInvestigations() { .status(NotificationStatusBaseEntity.ACKNOWLEDGED) .id("4") .targetDate(monthFromNow) - .severity(QualityNotificationSeverity.LIFE_THREATENING) + .severity(NotificationSeverity.LIFE_THREATENING) .sendTo(OTHER_BPN) .createdBy(OTHER_BPN) .createdByName(OTHER_BPN_COMPANY_NAME) @@ -212,7 +212,7 @@ private void storeCreatedInvestigations() { NotificationMessageEntity .builder() .status(NotificationStatusBaseEntity.ACCEPTED) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .id("5") .targetDate(monthFromNow) .sendTo(OTHER_BPN) @@ -224,7 +224,7 @@ private void storeCreatedInvestigations() { NotificationMessageEntity .builder() .status(NotificationStatusBaseEntity.DECLINED) - .severity(QualityNotificationSeverity.MAJOR) + .severity(NotificationSeverity.MAJOR) .targetDate(monthFromNow.plus(1L, DAYS)) .id("6") .sendTo(OTHER_BPN) @@ -240,7 +240,7 @@ private void storeCreatedInvestigations() { .sendTo(OTHER_BPN) .createdBy(OWN_BPN) .targetDate(monthFromNow.plus(2L, DAYS)) - .severity(QualityNotificationSeverity.CRITICAL) + .severity(NotificationSeverity.CRITICAL) .createdByName(OWN_BPN_COMPANY_NAME) .notification(investigation7) .edcNotificationId("cda2d956-fa91-4a75-bb4a-8e5ba39b268a7") @@ -248,7 +248,7 @@ private void storeCreatedInvestigations() { NotificationMessageEntity .builder() .status(NotificationStatusBaseEntity.CLOSED) - .severity(QualityNotificationSeverity.LIFE_THREATENING) + .severity(NotificationSeverity.LIFE_THREATENING) .targetDate(monthFromNow.plus(3L, DAYS)) .id("8") .sendTo(OTHER_BPN) diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationsRepositoryProvider.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationsRepositoryProvider.java index 2cb2c7f6d7..d6cb2da901 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationsRepositoryProvider.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationsRepositoryProvider.java @@ -18,7 +18,7 @@ ********************************************************************************/ package org.eclipse.tractusx.traceability.integration.common.support; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationRepository; import org.springframework.beans.factory.annotation.Autowired; public interface InvestigationsRepositoryProvider { diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationsSupport.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationsSupport.java index 0be76bb6b3..13db19786b 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationsSupport.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/InvestigationsSupport.java @@ -20,12 +20,12 @@ package org.eclipse.tractusx.traceability.integration.common.support; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -67,7 +67,7 @@ public void assertInvestigationsSize(int size) { assertThat(investigations).hasSize(size); } - public void assertInvestigationStatus(QualityNotificationStatus investigationStatus) { + public void assertInvestigationStatus(NotificationStatus investigationStatus) { jpaNotificationRepository.findAll().forEach( investigation -> assertThat(investigation.getStatus().name()).isEqualTo(investigationStatus.name()) ); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/NotificationMessageSupport.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/NotificationMessageSupport.java index 82c60af707..7121cf9b9d 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/NotificationMessageSupport.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/NotificationMessageSupport.java @@ -20,8 +20,8 @@ package org.eclipse.tractusx.traceability.integration.common.support; import lombok.RequiredArgsConstructor; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationMessageRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationMessageRepository; import org.springframework.stereotype.Component; import java.util.List; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/NotificationSupport.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/NotificationSupport.java index b3dff74e00..7fc6105a84 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/NotificationSupport.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/common/support/NotificationSupport.java @@ -21,12 +21,12 @@ import lombok.RequiredArgsConstructor; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationRepository; import org.springframework.stereotype.Component; import java.time.Instant; @@ -85,7 +85,7 @@ public void assertInvestigationsSize(int size) { assertThat(investigations).hasSize(size); } - public void assertInvestigationStatus(QualityNotificationStatus investigationStatus) { + public void assertInvestigationStatus(NotificationStatus investigationStatus) { jpaNotificationRepository.findAll().forEach( investigation -> assertThat(investigation.getStatus().name()).isEqualTo(investigationStatus.name()) ); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/edc/blackbox/EdcControllerIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/edc/blackbox/EdcControllerIT.java index feb24b41fc..522f1a5bbe 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/edc/blackbox/EdcControllerIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/edc/blackbox/EdcControllerIT.java @@ -27,13 +27,13 @@ import org.eclipse.tractusx.traceability.integration.common.support.AssetsSupport; import org.eclipse.tractusx.traceability.integration.common.support.InvestigationNotificationsSupport; import org.eclipse.tractusx.traceability.integration.common.support.InvestigationsSupport; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; import org.jose4j.lang.JoseException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -84,7 +84,7 @@ void shouldCreateAnInvestigationIncludingNotificationOnAPICallClass() throws IOE // then investigationNotificationsSupport.assertNotificationsSize(1); investigationsSupport.assertInvestigationsSize(1); - investigationsSupport.assertInvestigationStatus(QualityNotificationStatus.RECEIVED); + investigationsSupport.assertInvestigationStatus(NotificationStatus.RECEIVED); } @Test @@ -174,7 +174,7 @@ void shouldAddANotificationToExistingInvestigationOnAPICallback() throws IOExcep // then investigationNotificationsSupport.assertNotificationsSize(3); investigationsSupport.assertInvestigationsSize(1); - investigationsSupport.assertInvestigationStatus(QualityNotificationStatus.ACKNOWLEDGED); + investigationsSupport.assertInvestigationStatus(NotificationStatus.ACKNOWLEDGED); } @Test @@ -272,7 +272,7 @@ void shouldCallUpdateApiWithWrongRequestObject() throws JoseException { // then investigationNotificationsSupport.assertNotificationsSize(0); investigationsSupport.assertInvestigationsSize(1); - investigationsSupport.assertInvestigationStatus(QualityNotificationStatus.RECEIVED); + investigationsSupport.assertInvestigationStatus(NotificationStatus.RECEIVED); } private String readFile(final String filePath) throws IOException { diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/edc/blackbox/EdcNotificationModelIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/edc/blackbox/EdcNotificationModelIT.java index 532a171829..da4a1eb8df 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/edc/blackbox/EdcNotificationModelIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/edc/blackbox/EdcNotificationModelIT.java @@ -23,12 +23,12 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.jsonpath.JsonPath; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationContent; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationHeader; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationContent; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationHeader; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.NotificationType; import org.eclipse.tractusx.traceability.integration.IntegrationTestSpecification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -72,7 +72,7 @@ void shouldBeAbleToDeserializeEdcNotificationObjectWithUnknownFields() throws IO assertThat(edcNotification.content().listOfAffectedItems()).hasSize(1); assertThat(edcNotification.content().listOfAffectedItems().stream().findFirst().get()).contains("urn:uuid:171fed54-26aa-4848-a025-81aaca557f37"); - assertThat(edcNotification.convertNotificationStatus()).isEqualTo(QualityNotificationStatus.SENT); + assertThat(edcNotification.convertNotificationStatus()).isEqualTo(NotificationStatus.SENT); assertThat(edcNotification.convertNotificationType()).isEqualTo(NotificationType.QMINVESTIGATION); } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/AlertControllerFilterIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/AlertControllerFilterIT.java similarity index 93% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/AlertControllerFilterIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/AlertControllerFilterIT.java index 4ae37339fc..521c7eb258 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/AlertControllerFilterIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/AlertControllerFilterIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.alert; +package org.eclipse.tractusx.traceability.integration.notification.alert; import io.restassured.http.ContentType; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; @@ -40,14 +40,14 @@ import static io.restassured.RestAssured.given; import static org.eclipse.tractusx.traceability.common.security.JwtRole.ADMIN; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.ACCEPTED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.ACKNOWLEDGED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CANCELED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CLOSED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CREATED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.DECLINED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.ACCEPTED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.ACKNOWLEDGED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CANCELED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CLOSED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CREATED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.DECLINED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; import static org.hamcrest.Matchers.equalTo; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/AlertControllerFilterValuesIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/AlertControllerFilterValuesIT.java similarity index 99% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/AlertControllerFilterValuesIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/AlertControllerFilterValuesIT.java index 3e3dc7dc7c..c120c270f8 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/AlertControllerFilterValuesIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/AlertControllerFilterValuesIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.alert; +package org.eclipse.tractusx.traceability.integration.notification.alert; import io.restassured.http.ContentType; import org.eclipse.tractusx.traceability.integration.IntegrationTestSpecification; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/PublisherAlertsControllerIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/PublisherAlertsControllerIT.java similarity index 85% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/PublisherAlertsControllerIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/PublisherAlertsControllerIT.java index 7e80ef0f85..42e0854d78 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/PublisherAlertsControllerIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/PublisherAlertsControllerIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.alert; +package org.eclipse.tractusx.traceability.integration.notification.alert; import io.restassured.http.ContentType; import lombok.val; @@ -33,14 +33,14 @@ import org.eclipse.tractusx.traceability.integration.common.support.AlertNotificationsSupport; import org.eclipse.tractusx.traceability.integration.common.support.AlertsSupport; import org.eclipse.tractusx.traceability.integration.common.support.AssetsSupport; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.service.NotificationReceiverService; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationFactory; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.service.NotificationReceiverService; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationFactory; import org.hamcrest.Matchers; import org.jose4j.lang.JoseException; import org.junit.jupiter.api.BeforeEach; @@ -49,12 +49,12 @@ import org.springframework.transaction.annotation.Transactional; import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException; import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper; -import qualitynotification.base.request.CloseQualityNotificationRequest; -import qualitynotification.base.request.QualityNotificationSeverityRequest; -import qualitynotification.base.request.QualityNotificationTypeRequest; -import qualitynotification.base.request.StartQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; +import notification.request.CloseNotificationRequest; +import notification.request.NotificationSeverityRequest; +import notification.request.NotificationTypeRequest; +import notification.request.StartNotificationRequest; +import notification.request.UpdateNotificationRequest; +import notification.request.UpdateNotificationStatusRequest; import java.time.Instant; import java.util.Collections; @@ -90,19 +90,19 @@ void setUp() { void shouldReceiveAlert() { // given assetsSupport.defaultAssetsStored(); - QualityNotificationType notificationType = QualityNotificationType.ALERT; - QualityNotificationMessage notificationBuild = QualityNotificationMessage.builder() + NotificationType notificationType = NotificationType.ALERT; + NotificationMessage notificationBuild = NotificationMessage.builder() .id("some-id") - .notificationStatus(QualityNotificationStatus.SENT) - .affectedParts(List.of(new QualityNotificationAffectedPart("urn:uuid:d387fa8e-603c-42bd-98c3-4d87fef8d2bb"))) + .notificationStatus(NotificationStatus.SENT) + .affectedParts(List.of(new NotificationAffectedPart("urn:uuid:d387fa8e-603c-42bd-98c3-4d87fef8d2bb"))) .createdByName("bpn-a") .createdBy("Sender Manufacturer name") .sendTo("BPNL00000003AXS3") .sendToName("Receiver manufacturer name") - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .targetDate(Instant.parse("2018-11-30T18:35:24.00Z")) .type(notificationType) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .messageId("messageId") .build(); EDCNotification notification = EDCNotificationFactory.createEdcNotification( @@ -127,16 +127,16 @@ void shouldStartAlert() throws JsonProcessingException, JoseException { "urn:uuid:0ce83951-bc18-4e8f-892d-48bad4eb67ef" // BPN: BPNL00000003AXS3 ); String description = "at least 15 characters long investigation description"; - QualityNotificationSeverityRequest severity = QualityNotificationSeverityRequest.MINOR; + NotificationSeverityRequest severity = NotificationSeverityRequest.MINOR; String receiverBpn = "BPN"; assetsSupport.defaultAssetsStored(); - val request = StartQualityNotificationRequest.builder() + val request = StartNotificationRequest.builder() .partIds(partIds) .description(description) .severity(severity) - .type(QualityNotificationTypeRequest.ALERT) + .type(NotificationTypeRequest.ALERT) .receiverBpn(receiverBpn) .isAsBuilt(true) .build(); @@ -184,7 +184,7 @@ void givenMissingSeverity_whenStartAlert_thenBadRequest() throws JsonProcessingE "urn:uuid:0ce83951-bc18-4e8f-892d-48bad4eb67ef" // BPN: BPNL00000003AXS3 ); String description = "at least 15 characters long investigation description"; - val request = StartQualityNotificationRequest.builder() + val request = StartNotificationRequest.builder() .partIds(partIds) .description(description) .build(); @@ -211,10 +211,10 @@ void givenDescriptionOverMaxLength_whenStartAlert_thenBadRequest() throws JsonPr String description = RandomStringUtils.random(1001); - val request = StartQualityNotificationRequest.builder() + val request = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .severity(QualityNotificationSeverityRequest.MINOR) + .severity(NotificationSeverityRequest.MINOR) .receiverBpn("BPN") .build(); @@ -235,9 +235,9 @@ void givenTooLongAlertReason_whenUpdateAlert_thenBadRequest() throws JsonProcess // given String description = RandomStringUtils.random(1001); - UpdateQualityNotificationRequest request = UpdateQualityNotificationRequest + UpdateNotificationRequest request = UpdateNotificationRequest .builder() - .status(UpdateQualityNotificationStatusRequest.ACCEPTED) + .status(UpdateNotificationStatusRequest.ACCEPTED) .reason(description) .build(); @@ -259,9 +259,9 @@ void givenWrongStatus_whenUpdateAlert_thenBadRequest() throws JsonProcessingExce String description = RandomStringUtils.random(15); - UpdateQualityNotificationRequest request = UpdateQualityNotificationRequest + UpdateNotificationRequest request = UpdateNotificationRequest .builder() - .status(UpdateQualityNotificationStatusRequest.ACCEPTED) + .status(UpdateNotificationStatusRequest.ACCEPTED) .reason(description) .build(); @@ -284,11 +284,11 @@ void shouldCancelAlert() throws JsonProcessingException, JoseException { // given String filterString = "channel,EQUAL,SENDER,AND"; assetsSupport.defaultAssetsStored(); - val startAlertRequest = StartQualityNotificationRequest.builder() + val startAlertRequest = StartNotificationRequest.builder() .partIds(List.of("urn:uuid:fe99da3d-b0de-4e80-81da-882aebcca978")) .description("at least 15 characters long investigation description") - .severity(QualityNotificationSeverityRequest.MAJOR) - .type(QualityNotificationTypeRequest.ALERT) + .severity(NotificationSeverityRequest.MAJOR) + .type(NotificationTypeRequest.ALERT) .receiverBpn("BPN") .isAsBuilt(true) .build(); @@ -350,11 +350,11 @@ void shouldApproveAlertStatus() throws JsonProcessingException, JoseException { assetsSupport.defaultAssetsStored(); - val startAlertRequest = StartQualityNotificationRequest.builder() + val startAlertRequest = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .severity(QualityNotificationSeverityRequest.MINOR) - .type(QualityNotificationTypeRequest.ALERT) + .severity(NotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.ALERT) .receiverBpn("BPN") .isAsBuilt(true) .build(); @@ -407,11 +407,11 @@ void shouldCloseAlertStatus() throws JsonProcessingException, JoseException { assetsSupport.defaultAssetsStored(); - val startAlertRequest = StartQualityNotificationRequest.builder() + val startAlertRequest = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .severity(QualityNotificationSeverityRequest.MINOR) - .type(QualityNotificationTypeRequest.ALERT) + .severity(NotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.ALERT) .receiverBpn("BPN") .isAsBuilt(true) .build(); @@ -454,7 +454,7 @@ void shouldCloseAlertStatus() throws JsonProcessingException, JoseException { .body("content[0].sendTo", Matchers.is(Matchers.not(Matchers.blankOrNullString()))); // when - CloseQualityNotificationRequest closeAlertRequest = CloseQualityNotificationRequest + CloseNotificationRequest closeAlertRequest = CloseNotificationRequest .builder() .reason("this is the close reason for that investigation") .build(); @@ -482,7 +482,7 @@ void shouldCloseAlertStatus() throws JsonProcessingException, JoseException { .body("content", Matchers.hasSize(1)); alertsSupport.assertAlertsSize(1); - alertsSupport.assertAlertStatus(QualityNotificationStatus.CLOSED); + alertsSupport.assertAlertStatus(NotificationStatus.CLOSED); } @Test @@ -520,11 +520,11 @@ void shouldBeCreatedBySender() throws JsonProcessingException, JoseException { ); String description = "at least 15 characters long investigation description"; assetsSupport.defaultAssetsStored(); - val startAlertRequest = StartQualityNotificationRequest.builder() + val startAlertRequest = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .severity(QualityNotificationSeverityRequest.MINOR) - .type(QualityNotificationTypeRequest.ALERT) + .severity(NotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.ALERT) .receiverBpn("BPN") .isAsBuilt(true) .build(); @@ -572,10 +572,10 @@ void shouldReturn404WhenNoNotificationTypeSpecified() throws JsonProcessingExcep assetsSupport.defaultAssetsStored(); - val startAlertRequest = StartQualityNotificationRequest.builder() + val startAlertRequest = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .severity(QualityNotificationSeverityRequest.MINOR) + .severity(NotificationSeverityRequest.MINOR) .receiverBpn("BPN") .isAsBuilt(true) .build(); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/ReadAlertsControllerIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/ReadAlertsControllerIT.java similarity index 95% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/ReadAlertsControllerIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/ReadAlertsControllerIT.java index 39c0a8aacf..6a472071b4 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/ReadAlertsControllerIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/ReadAlertsControllerIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.alert; +package org.eclipse.tractusx.traceability.integration.notification.alert; import io.restassured.http.ContentType; import org.eclipse.tractusx.traceability.common.request.OwnPageable; @@ -27,11 +27,11 @@ import org.eclipse.tractusx.traceability.integration.common.support.AlertNotificationsSupport; import org.eclipse.tractusx.traceability.integration.common.support.AlertsSupport; import org.eclipse.tractusx.traceability.integration.common.support.BpnSupport; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; import org.hamcrest.Matchers; import org.jose4j.lang.JoseException; import org.junit.jupiter.api.Test; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/ReceiverAlertsControllerIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/ReceiverAlertsControllerIT.java similarity index 89% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/ReceiverAlertsControllerIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/ReceiverAlertsControllerIT.java index c902d7e6d3..9903d079ca 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/alert/ReceiverAlertsControllerIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/alert/ReceiverAlertsControllerIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.alert; +package org.eclipse.tractusx.traceability.integration.notification.alert; import io.restassured.http.ContentType; import org.eclipse.tractusx.traceability.common.request.OwnPageable; @@ -33,7 +33,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.springframework.beans.factory.annotation.Autowired; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; +import notification.request.UpdateNotificationStatusRequest; import java.util.List; import java.util.stream.Stream; @@ -64,7 +64,7 @@ void shouldNotUpdateToAcknowledgedNonExistingAlert() throws JoseException { { "status" : "$status" } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACKNOWLEDGED.name())) + """.replace("$status", UpdateNotificationStatusRequest.ACKNOWLEDGED.name())) .header(oAuth2Support.jwtAuthorization(SUPERVISOR)) .when() .post("/api/notifications/$notExistingAlertId/update".replace("$notExistingAlertId", Long.toString(notExistingAlertId))) @@ -99,7 +99,7 @@ void shouldNotUpdateToAcceptedNonExistingAlert() throws JoseException { "status" : "$status", "reason" : "some reason, why not" } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACCEPTED.name())) + """.replace("$status", UpdateNotificationStatusRequest.ACCEPTED.name())) .header(oAuth2Support.jwtAuthorization(SUPERVISOR)) .when() .post("/api/notifications/$notExistingAlertId/update".replace("$notExistingAlertId", Long.toString(notExistingAlertId))) @@ -134,7 +134,7 @@ void shouldNotUpdateToDeclinedNonExistingAlert() throws JoseException { "status" : "$status", "reason" : "some reason, why not" } - """.replace("$status", UpdateQualityNotificationStatusRequest.DECLINED.name())) + """.replace("$status", UpdateNotificationStatusRequest.DECLINED.name())) .header(oAuth2Support.jwtAuthorization(SUPERVISOR)) .when() .post("/api/notifications/$notExistingAlertId/update".replace("$notExistingAlertId", Long.toString(notExistingAlertId))) @@ -193,31 +193,31 @@ private static Stream invalidRequest() { "status" : "$status", "reason" : "No reason should be for acknowledging" } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACKNOWLEDGED.name())), + """.replace("$status", UpdateNotificationStatusRequest.ACKNOWLEDGED.name())), arguments(""" { "status" : "$status", "reason" : null } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACCEPTED.name())), + """.replace("$status", UpdateNotificationStatusRequest.ACCEPTED.name())), arguments(""" { "status" : "$status", "reason" : " " } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACCEPTED.name())), + """.replace("$status", UpdateNotificationStatusRequest.ACCEPTED.name())), arguments(""" { "status" : "$status", "reason" : null } - """.replace("$status", UpdateQualityNotificationStatusRequest.DECLINED.name())), + """.replace("$status", UpdateNotificationStatusRequest.DECLINED.name())), arguments(""" { "status" : "$status", "reason" : " " } - """.replace("$status", UpdateQualityNotificationStatusRequest.DECLINED.name())) + """.replace("$status", UpdateNotificationStatusRequest.DECLINED.name())) ); } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/InvestigationControllerFilterIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/InvestigationControllerFilterIT.java similarity index 94% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/InvestigationControllerFilterIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/InvestigationControllerFilterIT.java index db75541aa6..413fdbab24 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/InvestigationControllerFilterIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/InvestigationControllerFilterIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.investigation; +package org.eclipse.tractusx.traceability.integration.notification.investigation; import io.restassured.http.ContentType; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; @@ -41,14 +41,14 @@ import static io.restassured.RestAssured.given; import static org.eclipse.tractusx.traceability.common.security.JwtRole.ADMIN; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.ACCEPTED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.ACKNOWLEDGED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CANCELED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CLOSED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.CREATED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.DECLINED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; -import static org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.ACCEPTED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.ACKNOWLEDGED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CANCELED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CLOSED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.CREATED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.DECLINED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.RECEIVED; +import static org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity.SENT; import static org.hamcrest.Matchers.equalTo; class InvestigationControllerFilterIT extends IntegrationTestSpecification { diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/InvestigationControllerFilterValuesIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/InvestigationControllerFilterValuesIT.java similarity index 99% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/InvestigationControllerFilterValuesIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/InvestigationControllerFilterValuesIT.java index cf2a46afc0..ba2e5ea8c1 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/InvestigationControllerFilterValuesIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/InvestigationControllerFilterValuesIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.investigation; +package org.eclipse.tractusx.traceability.integration.notification.investigation; import io.restassured.http.ContentType; import org.eclipse.tractusx.traceability.integration.IntegrationTestSpecification; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/PublisherInvestigationsControllerIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/PublisherInvestigationsControllerIT.java similarity index 84% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/PublisherInvestigationsControllerIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/PublisherInvestigationsControllerIT.java index 1df8dce290..db1439e0d7 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/PublisherInvestigationsControllerIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/PublisherInvestigationsControllerIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.investigation; +package org.eclipse.tractusx.traceability.integration.notification.investigation; import io.restassured.http.ContentType; import lombok.val; @@ -32,14 +32,14 @@ import org.eclipse.tractusx.traceability.integration.common.support.AssetsSupport; import org.eclipse.tractusx.traceability.integration.common.support.NotificationMessageSupport; import org.eclipse.tractusx.traceability.integration.common.support.NotificationSupport; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.service.NotificationReceiverService; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationFactory; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.service.NotificationReceiverService; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationFactory; import org.hamcrest.Matchers; import org.jose4j.lang.JoseException; import org.junit.jupiter.api.BeforeEach; @@ -48,12 +48,12 @@ import org.springframework.transaction.annotation.Transactional; import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException; import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper; -import qualitynotification.base.request.CloseQualityNotificationRequest; -import qualitynotification.base.request.QualityNotificationSeverityRequest; -import qualitynotification.base.request.QualityNotificationTypeRequest; -import qualitynotification.base.request.StartQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; +import notification.request.CloseNotificationRequest; +import notification.request.NotificationSeverityRequest; +import notification.request.NotificationTypeRequest; +import notification.request.StartNotificationRequest; +import notification.request.UpdateNotificationRequest; +import notification.request.UpdateNotificationStatusRequest; import java.time.Instant; import java.util.Collections; @@ -91,19 +91,19 @@ void shouldReceiveNotification() { // given assetsSupport.defaultAssetsStored(); - QualityNotificationType notificationType = QualityNotificationType.INVESTIGATION; - QualityNotificationMessage notificationBuild = QualityNotificationMessage.builder() + NotificationType notificationType = NotificationType.INVESTIGATION; + NotificationMessage notificationBuild = NotificationMessage.builder() .id("some-id") - .notificationStatus(QualityNotificationStatus.SENT) - .affectedParts(List.of(new QualityNotificationAffectedPart("urn:uuid:d387fa8e-603c-42bd-98c3-4d87fef8d2bb"))) + .notificationStatus(NotificationStatus.SENT) + .affectedParts(List.of(new NotificationAffectedPart("urn:uuid:d387fa8e-603c-42bd-98c3-4d87fef8d2bb"))) .createdByName("bpn-a") .createdBy("Sender Manufacturer name") .sendTo("BPNL00000003AXS3") .sendToName("Receiver manufacturer name") - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .targetDate(Instant.parse("2018-11-30T18:35:24.00Z")) .type(notificationType) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .messageId("messageId") .build(); EDCNotification notification = EDCNotificationFactory.createEdcNotification( @@ -129,11 +129,11 @@ void shouldStartInvestigation() throws JsonProcessingException, JoseException { assetsSupport.defaultAssetsStored(); - val request = StartQualityNotificationRequest.builder() + val request = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .type(QualityNotificationTypeRequest.INVESTIGATION) - .severity(QualityNotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.INVESTIGATION) + .severity(NotificationSeverityRequest.MINOR) .isAsBuilt(true) .build(); @@ -179,7 +179,7 @@ void givenMissingSeverity_whenStartInvestigation_thenBadRequest() throws JsonPro ); String description = "at least 15 characters long investigation description"; - val request = StartQualityNotificationRequest.builder() + val request = StartNotificationRequest.builder() .partIds(partIds) .description(description) .build(); @@ -205,10 +205,10 @@ void givenDescriptionExceedsMaxLength_whenStartInvestigation_thenBadRequest() th String description = RandomStringUtils.random(1001); - val request = StartQualityNotificationRequest.builder() + val request = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .severity(QualityNotificationSeverityRequest.MINOR) + .severity(NotificationSeverityRequest.MINOR) .build(); // when/then @@ -228,11 +228,11 @@ void givenInvestigationReasonTooLong_whenUpdate_thenBadRequest() throws JsonProc // given String description = RandomStringUtils.random(1001); - UpdateQualityNotificationRequest request = - UpdateQualityNotificationRequest + UpdateNotificationRequest request = + UpdateNotificationRequest .builder() .reason(description) - .status(UpdateQualityNotificationStatusRequest.ACCEPTED) + .status(UpdateNotificationStatusRequest.ACCEPTED) .build(); // when/then given() @@ -251,11 +251,11 @@ void givenWrongStatus_whenUpdateInvestigation_thenBadRequest() throws JsonProces // given String description = RandomStringUtils.random(15); - UpdateQualityNotificationRequest request = - UpdateQualityNotificationRequest + UpdateNotificationRequest request = + UpdateNotificationRequest .builder() .reason(description) - .status(UpdateQualityNotificationStatusRequest.ACCEPTED) + .status(UpdateNotificationStatusRequest.ACCEPTED) .build(); // when/then @@ -275,11 +275,11 @@ void givenWrongStatus_whenUpdateInvestigation_thenBadRequest() throws JsonProces void shouldCancelInvestigation() throws JsonProcessingException, JoseException { // given assetsSupport.defaultAssetsStored(); - val startInvestigationRequest = StartQualityNotificationRequest.builder() + val startInvestigationRequest = StartNotificationRequest.builder() .partIds(List.of("urn:uuid:fe99da3d-b0de-4e80-81da-882aebcca978")) .description("at least 15 characters long investigation description") - .type(QualityNotificationTypeRequest.INVESTIGATION) - .severity(QualityNotificationSeverityRequest.MAJOR) + .type(NotificationTypeRequest.INVESTIGATION) + .severity(NotificationSeverityRequest.MAJOR) .isAsBuilt(true) .build(); @@ -336,11 +336,11 @@ void shouldApproveInvestigationStatus() throws JsonProcessingException, JoseExce String description = "at least 15 characters long investigation description"; assetsSupport.defaultAssetsStored(); - val startInvestigationRequest = StartQualityNotificationRequest.builder() + val startInvestigationRequest = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .severity(QualityNotificationSeverityRequest.MINOR) - .type(QualityNotificationTypeRequest.INVESTIGATION) + .severity(NotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.INVESTIGATION) .isAsBuilt(true) .build(); @@ -393,11 +393,11 @@ void shouldCloseInvestigationStatus() throws JsonProcessingException, JoseExcept oAuth2ApiSupport.oauth2ApiReturnsTechnicalUserToken(); assetsSupport.defaultAssetsStored(); - val startInvestigationRequest = StartQualityNotificationRequest.builder() + val startInvestigationRequest = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .type(QualityNotificationTypeRequest.INVESTIGATION) - .severity(QualityNotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.INVESTIGATION) + .severity(NotificationSeverityRequest.MINOR) .isAsBuilt(true) .build(); @@ -439,8 +439,8 @@ void shouldCloseInvestigationStatus() throws JsonProcessingException, JoseExcept .body("content[0].sendTo", Matchers.is(Matchers.not(Matchers.blankOrNullString()))); // when - CloseQualityNotificationRequest closeInvestigationRequest = - CloseQualityNotificationRequest + CloseNotificationRequest closeInvestigationRequest = + CloseNotificationRequest .builder() .reason("this is the close reason for that investigation") .build(); @@ -468,7 +468,7 @@ void shouldCloseInvestigationStatus() throws JsonProcessingException, JoseExcept notificationMessageSupport.assertNotificationsSize(3); notificationSupport.assertInvestigationsSize(1); - notificationSupport.assertInvestigationStatus(QualityNotificationStatus.CLOSED); + notificationSupport.assertInvestigationStatus(NotificationStatus.CLOSED); } @Test @@ -505,11 +505,11 @@ void shouldBeCreatedBySender() throws JsonProcessingException, JoseException { ); String description = "at least 15 characters long investigation description"; assetsSupport.defaultAssetsStored(); - val startInvestigationRequest = StartQualityNotificationRequest.builder() + val startInvestigationRequest = StartNotificationRequest.builder() .partIds(partIds) .description(description) - .severity(QualityNotificationSeverityRequest.MINOR) - .type(QualityNotificationTypeRequest.INVESTIGATION) + .severity(NotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.INVESTIGATION) .isAsBuilt(true) .build(); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/ReadInvestigationsControllerIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/ReadInvestigationsControllerIT.java similarity index 94% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/ReadInvestigationsControllerIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/ReadInvestigationsControllerIT.java index a0bcce7124..4dc70ae4c3 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/ReadInvestigationsControllerIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/ReadInvestigationsControllerIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.investigation; +package org.eclipse.tractusx.traceability.integration.notification.investigation; import io.restassured.http.ContentType; import org.eclipse.tractusx.traceability.common.request.OwnPageable; @@ -27,11 +27,11 @@ import org.eclipse.tractusx.traceability.integration.common.support.BpnSupport; import org.eclipse.tractusx.traceability.integration.common.support.InvestigationNotificationsSupport; import org.eclipse.tractusx.traceability.integration.common.support.InvestigationsSupport; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationSideBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationStatusBaseEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationTypeEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationSideBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationStatusBaseEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationTypeEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; import org.hamcrest.Matchers; import org.jose4j.lang.JoseException; import org.junit.jupiter.api.Test; diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/ReceiverInvestigationsControllerIT.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/ReceiverInvestigationsControllerIT.java similarity index 84% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/ReceiverInvestigationsControllerIT.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/ReceiverInvestigationsControllerIT.java index 8e2847c071..17f9eff30d 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/qualitynotification/investigation/ReceiverInvestigationsControllerIT.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/integration/notification/investigation/ReceiverInvestigationsControllerIT.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.integration.qualitynotification.investigation; +package org.eclipse.tractusx.traceability.integration.notification.investigation; import io.restassured.http.ContentType; import org.eclipse.tractusx.traceability.integration.IntegrationTestSpecification; @@ -28,7 +28,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.springframework.beans.factory.annotation.Autowired; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; +import notification.request.UpdateNotificationStatusRequest; import java.util.stream.Stream; @@ -53,7 +53,7 @@ void shouldNotUpdateToAcknowledgedNonExistingInvestigation() throws JoseExceptio { "status" : "$status" } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACKNOWLEDGED.name())) + """.replace("$status", UpdateNotificationStatusRequest.ACKNOWLEDGED.name())) .header(oAuth2Support.jwtAuthorization(SUPERVISOR)) .when() .post("/api/notifications/{notExistingInvestigationId}/update", notExistingInvestigationId) @@ -74,7 +74,7 @@ void shouldNotUpdateToAcceptedNonExistingInvestigation() throws JoseException { "status" : "$status", "reason" : "some reason, why not" } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACCEPTED.name())) + """.replace("$status", UpdateNotificationStatusRequest.ACCEPTED.name())) .header(oAuth2Support.jwtAuthorization(SUPERVISOR)) .when() .post("/api/notifications/{notExistingInvestigationId}/update", notExistingInvestigationId) @@ -95,7 +95,7 @@ void shouldNotUpdateToDeclinedNonExistingInvestigation() throws JoseException { "status" : "$status", "reason" : "some reason, why not" } - """.replace("$status", UpdateQualityNotificationStatusRequest.DECLINED.name())) + """.replace("$status", UpdateNotificationStatusRequest.DECLINED.name())) .header(oAuth2Support.jwtAuthorization(SUPERVISOR)) .when() .post("/api/notifications/{notExistingInvestigationId}/update", notExistingInvestigationId) @@ -128,31 +128,31 @@ private static Stream invalidRequest() { "status" : "$status", "reason" : "No reason should be for acknowledging" } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACKNOWLEDGED.name())), + """.replace("$status", UpdateNotificationStatusRequest.ACKNOWLEDGED.name())), arguments(""" { "status" : "$status", "reason" : null } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACCEPTED.name())), + """.replace("$status", UpdateNotificationStatusRequest.ACCEPTED.name())), arguments(""" { "status" : "$status", "reason" : " " } - """.replace("$status", UpdateQualityNotificationStatusRequest.ACCEPTED.name())), + """.replace("$status", UpdateNotificationStatusRequest.ACCEPTED.name())), arguments(""" { "status" : "$status", "reason" : null } - """.replace("$status", UpdateQualityNotificationStatusRequest.DECLINED.name())), + """.replace("$status", UpdateNotificationStatusRequest.DECLINED.name())), arguments(""" { "status" : "$status", "reason" : " " } - """.replace("$status", UpdateQualityNotificationStatusRequest.DECLINED.name())) + """.replace("$status", UpdateNotificationStatusRequest.DECLINED.name())) ); } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/alert/response/AlertResponseTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/alert/response/AlertResponseTest.java similarity index 56% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/alert/response/AlertResponseTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/alert/response/AlertResponseTest.java index a08b83809f..f1f74535bf 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/alert/response/AlertResponseTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/alert/response/AlertResponseTest.java @@ -17,20 +17,20 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.alert.response; +package org.eclipse.tractusx.traceability.notification.application.alert.response; import org.eclipse.tractusx.traceability.common.model.PageResult; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.mapper.NotificationResponseMapper; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.application.notification.mapper.NotificationResponseMapper; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import org.eclipse.tractusx.traceability.testdata.InvestigationTestDataFactory; import org.junit.jupiter.api.Test; -import qualitynotification.base.response.QualityNotificationReasonResponse; -import qualitynotification.base.response.QualityNotificationResponse; -import qualitynotification.base.response.QualityNotificationSeverityResponse; -import qualitynotification.base.response.QualityNotificationSideResponse; -import qualitynotification.base.response.QualityNotificationStatusResponse; +import notification.response.NotificationReasonResponse; +import notification.response.NotificationResponse; +import notification.response.NotificationSeverityResponse; +import notification.response.NotificationSideResponse; +import notification.response.NotificationStatusResponse; import java.util.List; @@ -39,52 +39,52 @@ class AlertResponseTest { @Test - void givenQualityNotification_whenFrom_thenConstructProperAlertResponse() { + void givenNotification_whenFrom_thenConstructProperAlertResponse() { // given - final QualityNotification notification = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.ACCEPTED, QualityNotificationStatus.CREATED); + final Notification notification = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.ACCEPTED, NotificationStatus.CREATED); // when - final QualityNotificationResponse result = NotificationResponseMapper.from(notification); + final NotificationResponse result = NotificationResponseMapper.from(notification); // then assertThat(result) .hasFieldOrPropertyWithValue("id", notification.getNotificationId().value()) - .hasFieldOrPropertyWithValue("status", QualityNotificationStatusResponse.ACCEPTED) + .hasFieldOrPropertyWithValue("status", NotificationStatusResponse.ACCEPTED) .hasFieldOrPropertyWithValue("description", notification.getDescription()) .hasFieldOrPropertyWithValue("createdBy", notification.getNotifications().stream() .findFirst() - .map(QualityNotificationMessage::getCreatedBy) + .map(NotificationMessage::getCreatedBy) .orElse(null)) .hasFieldOrPropertyWithValue("createdByName", notification.getNotifications().stream() .findFirst() - .map(QualityNotificationMessage::getCreatedByName) + .map(NotificationMessage::getCreatedByName) .orElse(null)) .hasFieldOrPropertyWithValue("createdDate", notification.getCreatedAt().toString()) .hasFieldOrPropertyWithValue("assetIds", notification.getAssetIds()) - .hasFieldOrPropertyWithValue("channel", QualityNotificationSideResponse.SENDER) - .hasFieldOrPropertyWithValue("reason", new QualityNotificationReasonResponse( + .hasFieldOrPropertyWithValue("channel", NotificationSideResponse.SENDER) + .hasFieldOrPropertyWithValue("reason", new NotificationReasonResponse( notification.getCloseReason(), notification.getAcceptReason(), notification.getDeclineReason() )) .hasFieldOrPropertyWithValue("sendTo", "recipientBPN") .hasFieldOrPropertyWithValue("sendToName", "receiverManufacturerName") - .hasFieldOrPropertyWithValue("severity", QualityNotificationSeverityResponse.MINOR) + .hasFieldOrPropertyWithValue("severity", NotificationSeverityResponse.MINOR) .hasFieldOrPropertyWithValue("targetDate", null); } @Test - void givenQualityNotificationPaged_whenFromAsPageResult_thenConstructProperAlertResponse() { + void givenNotificationPaged_whenFromAsPageResult_thenConstructProperAlertResponse() { // given - final QualityNotification notification = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.ACCEPTED, QualityNotificationStatus.CREATED); + final Notification notification = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.ACCEPTED, NotificationStatus.CREATED); final Integer page1 = 1; final Integer pageCount1 = 1; final Integer pageSize1 = 1; final Long totalItems1 = 1L; - final PageResult pagedNotification = new PageResult<>(List.of(notification), page1, pageCount1, pageSize1, totalItems1); + final PageResult pagedNotification = new PageResult<>(List.of(notification), page1, pageCount1, pageSize1, totalItems1); // when - final PageResult result = NotificationResponseMapper.fromAsPageResult(pagedNotification); + final PageResult result = NotificationResponseMapper.fromAsPageResult(pagedNotification); // then assertThat(result) diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/alert/rest/AlertControllerTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/alert/rest/AlertControllerTest.java similarity index 56% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/alert/rest/AlertControllerTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/alert/rest/AlertControllerTest.java index 08b0eca11d..a317dc43cb 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/alert/rest/AlertControllerTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/alert/rest/AlertControllerTest.java @@ -17,14 +17,14 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.alert.rest; - -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.service.QualityNotificationService; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.rest.NotificationController; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +package org.eclipse.tractusx.traceability.notification.application.alert.rest; + +import org.eclipse.tractusx.traceability.notification.application.notification.service.NotificationService; +import org.eclipse.tractusx.traceability.notification.application.notification.rest.NotificationController; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import org.eclipse.tractusx.traceability.testdata.InvestigationTestDataFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -32,24 +32,24 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import qualitynotification.base.request.CloseQualityNotificationRequest; -import qualitynotification.base.request.QualityNotificationSeverityRequest; -import qualitynotification.base.request.QualityNotificationTypeRequest; -import qualitynotification.base.request.StartQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; -import qualitynotification.base.response.QualityNotificationIdResponse; -import qualitynotification.base.response.QualityNotificationReasonResponse; -import qualitynotification.base.response.QualityNotificationResponse; -import qualitynotification.base.response.QualityNotificationSeverityResponse; -import qualitynotification.base.response.QualityNotificationSideResponse; -import qualitynotification.base.response.QualityNotificationStatusResponse; +import notification.request.CloseNotificationRequest; +import notification.request.NotificationSeverityRequest; +import notification.request.NotificationTypeRequest; +import notification.request.StartNotificationRequest; +import notification.request.UpdateNotificationRequest; +import notification.request.UpdateNotificationStatusRequest; +import notification.response.NotificationIdResponse; +import notification.response.NotificationReasonResponse; +import notification.response.NotificationResponse; +import notification.response.NotificationSeverityResponse; +import notification.response.NotificationSideResponse; +import notification.response.NotificationStatusResponse; import java.time.Instant; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.notification.model.StartQualityNotification.from; +import static org.eclipse.tractusx.traceability.notification.domain.notification.model.StartNotification.from; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -58,7 +58,7 @@ class AlertControllerTest { @Mock - private QualityNotificationService alertService; + private NotificationService alertService; @InjectMocks @@ -69,19 +69,19 @@ void givenRequestBody_whenAlertAssets_thenResponse() { // given final List partIds = List.of("partId1", "partId2"); final Instant targetDate = Instant.parse("2099-03-11T22:44:06.333826952Z"); - final QualityNotificationId notificationId = new QualityNotificationId(666L); - final StartQualityNotificationRequest request = StartQualityNotificationRequest.builder() + final NotificationId notificationId = new NotificationId(666L); + final StartNotificationRequest request = StartNotificationRequest.builder() .partIds(partIds) .description("description") .targetDate(targetDate) - .type(QualityNotificationTypeRequest.ALERT) - .severity(QualityNotificationSeverityRequest.MINOR) + .type(NotificationTypeRequest.ALERT) + .severity(NotificationSeverityRequest.MINOR) .receiverBpn("BPN00001") .build(); when(alertService.start(Mockito.eq(from(request)))).thenReturn(notificationId); // when - final QualityNotificationIdResponse result = controller.alertAssets(request); + final NotificationIdResponse result = controller.alertAssets(request); // then assertThat(result).hasFieldOrPropertyWithValue("id", notificationId.value()); @@ -91,39 +91,39 @@ void givenRequestBody_whenAlertAssets_thenResponse() { void givenRequest_whenGetAlert_thenProperResponse() { // given final Long request = 69L; - final QualityNotification notification = InvestigationTestDataFactory.createInvestigationTestData( - QualityNotificationStatus.ACCEPTED, + final Notification notification = InvestigationTestDataFactory.createInvestigationTestData( + NotificationStatus.ACCEPTED, "bpn" ); when(alertService.find(request)).thenReturn(notification); // when - final QualityNotificationResponse result = controller.getAlert(request); + final NotificationResponse result = controller.getAlert(request); // then assertThat(result) .hasFieldOrPropertyWithValue("id", notification.getNotificationId().value()) - .hasFieldOrPropertyWithValue("status", QualityNotificationStatusResponse.ACCEPTED) + .hasFieldOrPropertyWithValue("status", NotificationStatusResponse.ACCEPTED) .hasFieldOrPropertyWithValue("description", notification.getDescription()) .hasFieldOrPropertyWithValue("createdBy", notification.getNotifications().stream() .findFirst() - .map(QualityNotificationMessage::getCreatedBy) + .map(NotificationMessage::getCreatedBy) .orElse(null)) .hasFieldOrPropertyWithValue("createdByName", notification.getNotifications().stream() .findFirst() - .map(QualityNotificationMessage::getCreatedByName) + .map(NotificationMessage::getCreatedByName) .orElse(null)) .hasFieldOrPropertyWithValue("createdDate", notification.getCreatedAt().toString()) .hasFieldOrPropertyWithValue("assetIds", notification.getAssetIds()) - .hasFieldOrPropertyWithValue("channel", QualityNotificationSideResponse.SENDER) - .hasFieldOrPropertyWithValue("reason", new QualityNotificationReasonResponse( + .hasFieldOrPropertyWithValue("channel", NotificationSideResponse.SENDER) + .hasFieldOrPropertyWithValue("reason", new NotificationReasonResponse( notification.getCloseReason(), notification.getAcceptReason(), notification.getDeclineReason() )) .hasFieldOrPropertyWithValue("sendTo", "recipientBPN") .hasFieldOrPropertyWithValue("sendToName", "receiverManufacturerName") - .hasFieldOrPropertyWithValue("severity", QualityNotificationSeverityResponse.MINOR); + .hasFieldOrPropertyWithValue("severity", NotificationSeverityResponse.MINOR); } @Test @@ -155,13 +155,13 @@ void givenRequest_whenCloseAlert_thenProcessCorrectly() { // given final Long param = 1L; - CloseQualityNotificationRequest request = CloseQualityNotificationRequest.builder().reason("just because").build(); + CloseNotificationRequest request = CloseNotificationRequest.builder().reason("just because").build(); // when controller.closeAlert(param, request); // then - verify(alertService, times(1)).update(param, QualityNotificationStatus.CLOSED, "just because"); + verify(alertService, times(1)).update(param, NotificationStatus.CLOSED, "just because"); } @Test @@ -170,9 +170,9 @@ void givenRequest_whenUpdateAlert_thenProcessCorrectly() { final Long param = 1L; - UpdateQualityNotificationRequest request = - UpdateQualityNotificationRequest.builder() - .status(UpdateQualityNotificationStatusRequest.ACCEPTED) + UpdateNotificationRequest request = + UpdateNotificationRequest.builder() + .status(UpdateNotificationStatusRequest.ACCEPTED) .reason("just because I say so") .build(); @@ -181,7 +181,7 @@ void givenRequest_whenUpdateAlert_thenProcessCorrectly() { controller.updateAlert(param, request); // then - verify(alertService, times(1)).update(param, QualityNotificationStatus.ACCEPTED, "just because I say so"); + verify(alertService, times(1)).update(param, NotificationStatus.ACCEPTED, "just because I say so"); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/request/QualityNotificationSeverityRequestTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/request/NotificationSeverityRequestTest.java similarity index 69% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/request/QualityNotificationSeverityRequestTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/request/NotificationSeverityRequestTest.java index 8be6ab3366..c5f18c63ca 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/request/QualityNotificationSeverityRequestTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/request/NotificationSeverityRequestTest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.request; +package org.eclipse.tractusx.traceability.notification.application.request; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.ValueInstantiationException; @@ -26,7 +26,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import qualitynotification.base.request.QualityNotificationSeverityRequest; +import notification.request.NotificationSeverityRequest; import java.io.IOException; import java.util.NoSuchElementException; @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; -class QualityNotificationSeverityRequestTest { +class NotificationSeverityRequestTest { private ObjectMapper objectMapper; @@ -46,10 +46,10 @@ void setUp() { @ParameterizedTest @MethodSource("validValues") void givenValidSeverity_whenDeserialize_thenCreateProperValue( - final String input, final QualityNotificationSeverityRequest output + final String input, final NotificationSeverityRequest output ) throws IOException { // when - final QualityNotificationSeverityRequest result = objectMapper.readValue(input, QualityNotificationSeverityRequest.class); + final NotificationSeverityRequest result = objectMapper.readValue(input, NotificationSeverityRequest.class); // then assertThat(result).isEqualTo(output); @@ -62,20 +62,20 @@ void givenInvalidSeverity_whenDeserialize_thenThrowException() throws IOExceptio // when/then try { - objectMapper.readValue(input, QualityNotificationSeverityRequest.class); + objectMapper.readValue(input, NotificationSeverityRequest.class); } catch (ValueInstantiationException exception) { assertThat(exception.getCause()).isExactlyInstanceOf(NoSuchElementException.class); assertThat(exception.getCause().getMessage()) - .isEqualTo("Unsupported QualityNotificationSeverityRequest: NON_EXISTENT. Must be one of: MINOR, MAJOR, CRITICAL, LIFE-THREATENING"); + .isEqualTo("Unsupported NotificationSeverityRequest: NON_EXISTENT. Must be one of: MINOR, MAJOR, CRITICAL, LIFE-THREATENING"); } } private static Stream validValues() { return Stream.of( - Arguments.of("\"MINOR\"", QualityNotificationSeverityRequest.MINOR), - Arguments.of("\"CRITICAL\"", QualityNotificationSeverityRequest.CRITICAL), - Arguments.of("\"MAJOR\"", QualityNotificationSeverityRequest.MAJOR), - Arguments.of("\"LIFE-THREATENING\"", QualityNotificationSeverityRequest.LIFE_THREATENING) + Arguments.of("\"MINOR\"", NotificationSeverityRequest.MINOR), + Arguments.of("\"CRITICAL\"", NotificationSeverityRequest.CRITICAL), + Arguments.of("\"MAJOR\"", NotificationSeverityRequest.MAJOR), + Arguments.of("\"LIFE-THREATENING\"", NotificationSeverityRequest.LIFE_THREATENING) ); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/response/QualityNotificationSeverityResponseTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/response/NotificationSeverityResponseTest.java similarity index 83% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/response/QualityNotificationSeverityResponseTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/response/NotificationSeverityResponseTest.java index 4d25df9683..bdfbe7bba4 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/application/response/QualityNotificationSeverityResponseTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/application/response/NotificationSeverityResponseTest.java @@ -17,17 +17,17 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.application.response; +package org.eclipse.tractusx.traceability.notification.application.response; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException; import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper; -import qualitynotification.base.response.QualityNotificationSeverityResponse; +import notification.response.NotificationSeverityResponse; import static org.assertj.core.api.Assertions.assertThat; -class QualityNotificationSeverityResponseTest { +class NotificationSeverityResponseTest { private ObjectMapper objectMapper; @@ -39,7 +39,7 @@ void setUp() { @Test void givenSeverityResponse_whenCreateJson_thenSerializeProperly() throws JsonProcessingException { // given - QualityNotificationSeverityResponse input = QualityNotificationSeverityResponse.LIFE_THREATENING; + NotificationSeverityResponse input = NotificationSeverityResponse.LIFE_THREATENING; // when String result = objectMapper.writeValueAsString(input); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationTest.java similarity index 64% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationTest.java index 6a1ac1f8b9..489a13719e 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/model/QualityNotificationTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/base/model/NotificationTest.java @@ -16,7 +16,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.base.model; +package org.eclipse.tractusx.traceability.notification.domain.base.model; import org.junit.jupiter.api.Test; @@ -28,21 +28,21 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -class QualityNotificationTest { +class NotificationTest { @Test void testSecondLatestNotifications() { // Given - List notifications = new ArrayList<>(); - QualityNotificationMessage message1 = QualityNotificationMessage.builder().notificationStatus(QualityNotificationStatus.ACKNOWLEDGED).created(LocalDateTime.now()).build(); - QualityNotificationMessage message2 = QualityNotificationMessage.builder().notificationStatus(QualityNotificationStatus.ACKNOWLEDGED).created(LocalDateTime.now()).build(); + List notifications = new ArrayList<>(); + NotificationMessage message1 = NotificationMessage.builder().notificationStatus(NotificationStatus.ACKNOWLEDGED).created(LocalDateTime.now()).build(); + NotificationMessage message2 = NotificationMessage.builder().notificationStatus(NotificationStatus.ACKNOWLEDGED).created(LocalDateTime.now()).build(); notifications.add(message1); notifications.add(message2); - QualityNotification qualityNotification = QualityNotification.builder().notifications(notifications).build(); + Notification notification = Notification.builder().notifications(notifications).build(); // When - List result = qualityNotification.secondLatestNotifications(); + List result = notification.secondLatestNotifications(); // Then assertNotNull(result); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/investigation/service/InvestigationServiceImplTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/investigation/service/InvestigationServiceImplTest.java similarity index 62% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/investigation/service/InvestigationServiceImplTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/investigation/service/InvestigationServiceImplTest.java index 52dd2c808b..faa888f9ec 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/investigation/service/InvestigationServiceImplTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/investigation/service/InvestigationServiceImplTest.java @@ -16,14 +16,14 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.investigation.service; - -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationNotFoundException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.service.NotificationServiceImpl; +package org.eclipse.tractusx.traceability.notification.domain.investigation.service; + +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationNotFoundException; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.notification.service.NotificationServiceImpl; import org.eclipse.tractusx.traceability.testdata.InvestigationTestDataFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -49,7 +49,7 @@ class InvestigationServiceImplTest { @Test void testFindNotPresentInvestigationThrowsException() { // given - when(notificationRepository.findOptionalQualityNotificationById(any(QualityNotificationId.class))).thenReturn(Optional.empty()); + when(notificationRepository.findOptionalNotificationById(any(NotificationId.class))).thenReturn(Optional.empty()); // expect assertThrows(NotificationNotFoundException.class, () -> notificationService.find(0L)); @@ -58,12 +58,12 @@ void testFindNotPresentInvestigationThrowsException() { @Test void testFindExistingInvestigation() { // given - when(notificationRepository.findOptionalQualityNotificationById(any(QualityNotificationId.class))).thenReturn(Optional.of( - InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.ACKNOWLEDGED, QualityNotificationStatus.ACKNOWLEDGED) + when(notificationRepository.findOptionalNotificationById(any(NotificationId.class))).thenReturn(Optional.of( + InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.ACKNOWLEDGED, NotificationStatus.ACKNOWLEDGED) )); // expect - QualityNotification investigation = notificationService.find(0L); + Notification investigation = notificationService.find(0L); // then assertThat(investigation).isNotNull(); @@ -72,22 +72,22 @@ void testFindExistingInvestigation() { @Test void testLoadNotPresentInvestigationThrowsException() { // given - when(notificationRepository.findOptionalQualityNotificationById(any(QualityNotificationId.class))).thenReturn(Optional.empty()); + when(notificationRepository.findOptionalNotificationById(any(NotificationId.class))).thenReturn(Optional.empty()); // expect - QualityNotificationId investigationId = new QualityNotificationId(0L); + NotificationId investigationId = new NotificationId(0L); assertThrows(NotificationNotFoundException.class, () -> notificationService.loadOrNotFoundException(investigationId)); } @Test void testLoadExistingInvestigation() { // given - when(notificationRepository.findOptionalQualityNotificationById(any(QualityNotificationId.class))).thenReturn(Optional.of( - InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.ACKNOWLEDGED, QualityNotificationStatus.ACKNOWLEDGED) + when(notificationRepository.findOptionalNotificationById(any(NotificationId.class))).thenReturn(Optional.of( + InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.ACKNOWLEDGED, NotificationStatus.ACKNOWLEDGED) )); // expect - QualityNotification investigation = notificationService.loadOrNotFoundException(new QualityNotificationId(0L)); + Notification investigation = notificationService.loadOrNotFoundException(new NotificationId(0L)); // then assertThat(investigation).isNotNull(); @@ -106,12 +106,12 @@ void testLoadNotPresentInvestigationByEdcNotificationIdThrowsException() { void testLoadPresentInvestigationByEdcNotificationId() { // given when(notificationRepository.findByEdcNotificationId(any())).thenReturn(Optional.of( - InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.ACKNOWLEDGED, QualityNotificationStatus.ACKNOWLEDGED) + InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.ACKNOWLEDGED, NotificationStatus.ACKNOWLEDGED) ) ); // when - QualityNotification investigation = notificationService.loadByEdcNotificationIdOrNotFoundException("0"); + Notification investigation = notificationService.loadByEdcNotificationIdOrNotFoundException("0"); // then assertThat(investigation).isNotNull(); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/model/NotificationTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/model/NotificationTest.java similarity index 76% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/model/NotificationTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/model/NotificationTest.java index 60adcc2a2f..a384c42503 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/model/NotificationTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/model/NotificationTest.java @@ -18,10 +18,10 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.model; +package org.eclipse.tractusx.traceability.notification.domain.model; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; import org.eclipse.tractusx.traceability.testdata.NotificationTestDataFactory; import org.junit.jupiter.api.Test; @@ -32,13 +32,13 @@ class NotificationTest { @Test void testCopyAndSwitchSenderAndReceiverIsAppBpn() { // Given - QualityNotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); + NotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); BPN applicationBPN = new BPN("recipientBPN"); String senderBPN = "senderBPN"; String receiverBPN = applicationBPN.value(); // When - QualityNotificationMessage switchedNotification = notificationTestData.copyAndSwitchSenderAndReceiver(applicationBPN); + NotificationMessage switchedNotification = notificationTestData.copyAndSwitchSenderAndReceiver(applicationBPN); // Then assertThat(switchedNotification.getSendTo()).isEqualTo(senderBPN); @@ -48,14 +48,14 @@ void testCopyAndSwitchSenderAndReceiverIsAppBpn() { @Test void testCopyAndSwitchSenderAndReceiverIsNotAppBpn() { // Given - QualityNotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); + NotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); BPN applicationBPN = new BPN("senderBPN"); String senderBPN = applicationBPN.value(); String receiverBPN = "recipientBPN"; // When - QualityNotificationMessage switchedNotification = notificationTestData.copyAndSwitchSenderAndReceiver(applicationBPN); + NotificationMessage switchedNotification = notificationTestData.copyAndSwitchSenderAndReceiver(applicationBPN); // Then assertThat(switchedNotification.getSendTo()).isEqualTo(receiverBPN); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/model/investigation/InvestigationTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/model/investigation/InvestigationTest.java similarity index 76% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/model/investigation/InvestigationTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/model/investigation/InvestigationTest.java index 9f22b23169..339ea3e398 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/model/investigation/InvestigationTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/model/investigation/InvestigationTest.java @@ -19,15 +19,15 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.model.investigation; +package org.eclipse.tractusx.traceability.notification.domain.model.investigation; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.InvestigationStatusTransitionNotAllowed; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.InvestigationStatusTransitionNotAllowed; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -39,26 +39,26 @@ import java.time.Instant; import java.util.stream.Stream; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.ACCEPTED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.ACKNOWLEDGED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.CANCELED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.CLOSED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.CREATED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.DECLINED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.RECEIVED; -import static org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus.SENT; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.ACCEPTED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.ACKNOWLEDGED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.CANCELED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.CLOSED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.CREATED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.DECLINED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.RECEIVED; +import static org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus.SENT; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @ExtendWith(MockitoExtension.class) class InvestigationTest { - QualityNotification investigation; + Notification investigation; @Test @DisplayName("Forbid Cancel Investigation with disallowed status") void forbidCancellingInvestigationWithDisallowedStatus() { - QualityNotificationStatus status = RECEIVED; + NotificationStatus status = RECEIVED; BPN bpn = new BPN("BPNL000000000001"); investigation = senderInvestigationWithStatus(bpn, status); assertThrows(InvestigationStatusTransitionNotAllowed.class, () -> investigation.cancel(bpn)); @@ -68,7 +68,7 @@ void forbidCancellingInvestigationWithDisallowedStatus() { @Test @DisplayName("Forbid Send Investigation with disallowed status") void forbidSendingInvestigationWithDisallowedStatus() { - QualityNotificationStatus status = SENT; + NotificationStatus status = SENT; BPN bpn = new BPN("BPNL000000000001"); investigation = senderInvestigationWithStatus(bpn, status); assertThrows(InvestigationStatusTransitionNotAllowed.class, () -> investigation.send(bpn)); @@ -78,7 +78,7 @@ void forbidSendingInvestigationWithDisallowedStatus() { @Test @DisplayName("Forbid Close Investigation for different BPN") void forbidCloseInvestigationWithDisallowedStatus() { - QualityNotificationStatus status = CREATED; + NotificationStatus status = CREATED; BPN bpn = new BPN("BPNL000000000001"); BPN bpnOther = new BPN("BPNL12321321321"); investigation = senderInvestigationWithStatus(bpnOther, status); @@ -89,7 +89,7 @@ void forbidCloseInvestigationWithDisallowedStatus() { @Test @DisplayName("Forbid Cancel Investigation for different BPN") void forbidCancelInvestigationForDifferentBpn() { - QualityNotificationStatus status = CREATED; + NotificationStatus status = CREATED; BPN bpn = new BPN("BPNL000000000001"); investigation = senderInvestigationWithStatus(bpn, status); BPN bpn2 = new BPN("BPNL000000000002"); @@ -100,7 +100,7 @@ void forbidCancelInvestigationForDifferentBpn() { @Test @DisplayName("Forbid Send Investigation for different BPN") void forbidSendInvestigationForDifferentBpn() { - QualityNotificationStatus status = CREATED; + NotificationStatus status = CREATED; BPN bpn = new BPN("BPNL000000000001"); investigation = senderInvestigationWithStatus(bpn, status); BPN bpn2 = new BPN("BPNL000000000002"); @@ -111,7 +111,7 @@ void forbidSendInvestigationForDifferentBpn() { @Test @DisplayName("Forbid Close Investigation for different BPN") void forbidCloseInvestigationForDifferentBpn() { - QualityNotificationStatus status = CREATED; + NotificationStatus status = CREATED; BPN bpn = new BPN("BPNL000000000001"); investigation = senderInvestigationWithStatus(bpn, status); BPN bpn2 = new BPN("BPNL000000000002"); @@ -148,8 +148,8 @@ void closeInvestigationWithAllowedStatusSuccessfully() { // util functions - private QualityNotification senderInvestigationWithStatus(BPN bpn, QualityNotificationStatus status) { - return investigationWithStatus(bpn, status, QualityNotificationSide.SENDER); + private Notification senderInvestigationWithStatus(BPN bpn, NotificationStatus status) { + return investigationWithStatus(bpn, status, NotificationSide.SENDER); } private static Stream provideInvalidStatusForAcknowledgeInvestigation() { @@ -217,10 +217,10 @@ private static Stream provideInvalidStatusForCancelInvestigation() { ); } - private QualityNotification investigationWithStatus(BPN bpn, QualityNotificationStatus status, QualityNotificationSide side) { + private Notification investigationWithStatus(BPN bpn, NotificationStatus status, NotificationSide side) { - return QualityNotification.builder() - .notificationId(new QualityNotificationId(1L)) + return Notification.builder() + .notificationId(new NotificationId(1L)) .bpn(bpn) .notificationStatus(status) .notificationSide(side) @@ -233,7 +233,7 @@ private QualityNotification investigationWithStatus(BPN bpn, QualityNotification @ParameterizedTest @DisplayName("Forbid Acknowledge Investigation with invalid status") @MethodSource("provideInvalidStatusForAcknowledgeInvestigation") - void forbidAcknowledgeInvestigationWithStatusClosed(QualityNotificationStatus status) { + void forbidAcknowledgeInvestigationWithStatusClosed(NotificationStatus status) { // Given investigation = receiverInvestigationWithStatus(status); @@ -246,7 +246,7 @@ void forbidAcknowledgeInvestigationWithStatusClosed(QualityNotificationStatus st @ParameterizedTest @DisplayName("Forbid Accept Investigation with invalid status") @MethodSource("provideInvalidStatusForAcceptInvestigation") - void forbidAcceptInvestigationWithDisallowedStatus(QualityNotificationStatus status) { + void forbidAcceptInvestigationWithDisallowedStatus(NotificationStatus status) { investigation = receiverInvestigationWithStatus(status); assertThrows(InvestigationStatusTransitionNotAllowed.class, () -> investigation.accept("some reason")); assertEquals(status, investigation.getNotificationStatus()); @@ -256,7 +256,7 @@ void forbidAcceptInvestigationWithDisallowedStatus(QualityNotificationStatus sta @ParameterizedTest @DisplayName("Forbid Decline Investigation with invalid status") @MethodSource("provideInvalidStatusForDeclineInvestigation") - void forbidDeclineInvestigationWithInvalidStatus(QualityNotificationStatus status) { + void forbidDeclineInvestigationWithInvalidStatus(NotificationStatus status) { investigation = receiverInvestigationWithStatus(status); assertThrows(InvestigationStatusTransitionNotAllowed.class, () -> investigation.decline("some-reason")); assertEquals(status, investigation.getNotificationStatus()); @@ -265,7 +265,7 @@ void forbidDeclineInvestigationWithInvalidStatus(QualityNotificationStatus statu @ParameterizedTest @DisplayName("Forbid Close Investigation with invalid status") @MethodSource("provideInvalidStatusForCloseInvestigation") - void forbidCloseInvestigationWithInvalidStatus(QualityNotificationStatus status) { + void forbidCloseInvestigationWithInvalidStatus(NotificationStatus status) { investigation = receiverInvestigationWithStatus(status); BPN bpn = new BPN("BPNL000000000001"); assertThrows(InvestigationStatusTransitionNotAllowed.class, () -> investigation.close(bpn, "some-reason")); @@ -277,7 +277,7 @@ void forbidCloseInvestigationWithInvalidStatus(QualityNotificationStatus status) @ParameterizedTest @DisplayName("Forbid Send Investigation with invalid status") @MethodSource("provideInvalidStatusForSendInvestigation") - void forbidSendInvestigationWithInvalidStatus(QualityNotificationStatus status) { + void forbidSendInvestigationWithInvalidStatus(NotificationStatus status) { investigation = receiverInvestigationWithStatus(status); BPN bpn = new BPN("BPNL000000000001"); @@ -290,8 +290,8 @@ void forbidSendInvestigationWithInvalidStatus(QualityNotificationStatus status) @ParameterizedTest @DisplayName("Forbid Cancel Investigation with invalid statuses") @MethodSource("provideInvalidStatusForCancelInvestigation") - void forbidCancelInvestigationWithInvalidStatus(QualityNotificationStatus status) { - QualityNotification investigation = receiverInvestigationWithStatus(status); + void forbidCancelInvestigationWithInvalidStatus(NotificationStatus status) { + Notification investigation = receiverInvestigationWithStatus(status); BPN bpn = new BPN("BPNL000000000001"); assertThrows(InvestigationStatusTransitionNotAllowed.class, () -> investigation.cancel(bpn)); @@ -325,14 +325,14 @@ void declineInvestigationSuccessfully() { } //util functions - private QualityNotification receiverInvestigationWithStatus(QualityNotificationStatus status) { - return investigationWithStatus(status, QualityNotificationSide.RECEIVER); + private Notification receiverInvestigationWithStatus(NotificationStatus status) { + return investigationWithStatus(status, NotificationSide.RECEIVER); } - private QualityNotification investigationWithStatus(QualityNotificationStatus status, QualityNotificationSide side) { + private Notification investigationWithStatus(NotificationStatus status, NotificationSide side) { BPN bpn = new BPN("BPNL000000000001"); - return QualityNotification.builder() - .notificationId(new QualityNotificationId(1L)) + return Notification.builder() + .notificationId(new NotificationId(1L)) .bpn(bpn) .notificationStatus(status) .notificationSide(side) diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/EdcNotificationServiceImplTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/EdcNotificationServiceImplTest.java similarity index 69% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/EdcNotificationServiceImplTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/EdcNotificationServiceImplTest.java index 1fc7ef59c7..c6d7bfd9fb 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/EdcNotificationServiceImplTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/EdcNotificationServiceImplTest.java @@ -17,20 +17,20 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.service; +package org.eclipse.tractusx.traceability.notification.domain.service; import org.eclipse.tractusx.traceability.discovery.domain.model.Discovery; import org.eclipse.tractusx.traceability.discovery.domain.service.DiscoveryService; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.ContractNegotiationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoCatalogItemException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoEndpointDataReferenceException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.service.EdcNotificationServiceImpl; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.service.NotificationsEDCFacade; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.ContractNegotiationException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.NoCatalogItemException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.NoEndpointDataReferenceException; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.service.EdcNotificationServiceImpl; +import org.eclipse.tractusx.traceability.notification.domain.base.service.NotificationsEDCFacade; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -73,18 +73,18 @@ void testNotificationsServiceUpdateAsync() { // and when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); // and - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.INVESTIGATION) + .type(NotificationType.INVESTIGATION) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); // when notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @Test @@ -98,18 +98,18 @@ void testNotificationsServiceAlertNotificationUpdateAsync() { // and when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); // and - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.ALERT) + .type(NotificationType.ALERT) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); // when notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @Test @@ -121,18 +121,18 @@ void givenNoCatalogItemException_whenHandleSendingInvestigation_thenHandleIt() { Discovery discovery = Discovery.builder().senderUrl(edcSenderUrl).receiverUrls(List.of(edcReceiverUrl)).build(); when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.INVESTIGATION) + .type(NotificationType.INVESTIGATION) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); doThrow(new NoCatalogItemException()).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); // when notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @Test @@ -144,18 +144,18 @@ void givenSendNotificationException_whenHandleSendingInvestigation_thenHandleIt( Discovery discovery = Discovery.builder().senderUrl(edcSenderUrl).receiverUrls(List.of(edcReceiverUrl)).build(); when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.INVESTIGATION) + .type(NotificationType.INVESTIGATION) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); doThrow(new SendNotificationException("message", new RuntimeException())).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); // when notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @Test @@ -167,11 +167,11 @@ void givenSendNoEndpointDataReferenceException_whenHandleSendingInvestigation_th Discovery discovery = Discovery.builder().senderUrl(edcSenderUrl).receiverUrls(List.of(edcReceiverUrl)).build(); when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.INVESTIGATION) + .type(NotificationType.INVESTIGATION) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); doThrow(new NoEndpointDataReferenceException("message")).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); @@ -179,7 +179,7 @@ void givenSendNoEndpointDataReferenceException_whenHandleSendingInvestigation_th notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @Test @@ -191,11 +191,11 @@ void givenContractNegotiationException_whenHandleSendingInvestigation_thenHandle Discovery discovery = Discovery.builder().senderUrl(edcSenderUrl).receiverUrls(List.of(edcReceiverUrl)).build(); when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.INVESTIGATION) + .type(NotificationType.INVESTIGATION) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); doThrow(new ContractNegotiationException("message")).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); @@ -203,7 +203,7 @@ void givenContractNegotiationException_whenHandleSendingInvestigation_thenHandle notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @@ -216,11 +216,11 @@ void givenNoCatalogItemException_whenHandleSendingAlert_thenHandleIt() { Discovery discovery = Discovery.builder().senderUrl(edcSenderUrl).receiverUrls(List.of(edcReceiverUrl)).build(); when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.ALERT) + .type(NotificationType.ALERT) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); doThrow(new NoCatalogItemException()).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); @@ -228,7 +228,7 @@ void givenNoCatalogItemException_whenHandleSendingAlert_thenHandleIt() { notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @Test @@ -241,11 +241,11 @@ void givenSendNotificationException_whenHandleSendingAlert_thenHandleIt() { Discovery discovery = Discovery.builder().senderUrl(edcSenderUrl).receiverUrls(List.of(edcReceiverUrl)).build(); when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.ALERT) + .type(NotificationType.ALERT) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); doThrow(new SendNotificationException("message", new RuntimeException())).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); @@ -254,7 +254,7 @@ void givenSendNotificationException_whenHandleSendingAlert_thenHandleIt() { notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @Test @@ -266,11 +266,11 @@ void givenSendNoEndpointDataReferenceException_whenHandleSendingAlert_thenHandle Discovery discovery = Discovery.builder().senderUrl(edcSenderUrl).receiverUrls(List.of(edcReceiverUrl)).build(); when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.ALERT) + .type(NotificationType.ALERT) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); doThrow(new NoEndpointDataReferenceException("message")).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); @@ -278,7 +278,7 @@ void givenSendNoEndpointDataReferenceException_whenHandleSendingAlert_thenHandle notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } @Test @@ -290,11 +290,11 @@ void givenContractNegotiationException_whenHandleSendingAlert_thenHandleIt() { Discovery discovery = Discovery.builder().senderUrl(edcSenderUrl).receiverUrls(List.of(edcReceiverUrl)).build(); when(discoveryService.getDiscoveryByBPN(bpn)).thenReturn(discovery); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .sendTo(bpn) - .type(QualityNotificationType.ALERT) + .type(NotificationType.ALERT) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .build(); doThrow(new ContractNegotiationException("message")).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); @@ -302,6 +302,6 @@ void givenContractNegotiationException_whenHandleSendingAlert_thenHandleIt() { notificationsService.asyncNotificationMessageExecutor(notification); // then - verify(edcFacade).startEdcTransfer(any(QualityNotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); + verify(edcFacade).startEdcTransfer(any(NotificationMessage.class), eq(edcReceiverUrl), eq(edcSenderUrl)); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/InvestigationsReceiverServiceTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/InvestigationsReceiverServiceTest.java similarity index 54% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/InvestigationsReceiverServiceTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/InvestigationsReceiverServiceTest.java index c21b8d729e..849414d7ea 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/InvestigationsReceiverServiceTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/InvestigationsReceiverServiceTest.java @@ -17,21 +17,21 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.service; +package org.eclipse.tractusx.traceability.notification.domain.service; import org.eclipse.tractusx.traceability.common.mapper.NotificationMessageMapper; -import org.eclipse.tractusx.traceability.common.mapper.QualityNotificationMapper; +import org.eclipse.tractusx.traceability.common.mapper.NotificationMapper; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.service.NotificationReceiverService; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotification; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.edc.model.EDCNotificationFactory; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.notification.service.NotificationReceiverService; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification; +import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotificationFactory; import org.eclipse.tractusx.traceability.testdata.InvestigationTestDataFactory; import org.eclipse.tractusx.traceability.testdata.NotificationTestDataFactory; import org.junit.jupiter.api.DisplayName; @@ -58,10 +58,10 @@ class InvestigationsReceiverServiceTest { private NotificationRepository notificationRepository; @Mock - private NotificationMessageMapper mockNotificationMapper; + private NotificationMessageMapper mockNotificationMessageMapper; @Mock - private QualityNotificationMapper mockQualityNotificationMapper; + private NotificationMapper mockNotificationMapper; @InjectMocks @@ -73,9 +73,9 @@ class InvestigationsReceiverServiceTest { void testhandleReceiveValidSentNotification() { // Given - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationType notificationType = QualityNotificationType.INVESTIGATION; - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationType notificationType = NotificationType.INVESTIGATION; + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .createdBy("senderBPN") @@ -84,9 +84,9 @@ void testhandleReceiveValidSentNotification() { .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description("123") - .notificationStatus(QualityNotificationStatus.SENT) + .notificationStatus(NotificationStatus.SENT) .affectedParts(affectedParts) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .type(notificationType) .targetDate(Instant.now()) @@ -94,18 +94,18 @@ void testhandleReceiveValidSentNotification() { .build(); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.RECEIVED, "recipientBPN"); - QualityNotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.RECEIVED, "recipientBPN"); + NotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); EDCNotification edcNotification = EDCNotificationFactory.createEdcNotification( "it", notification); - when(mockNotificationMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); - when(mockQualityNotificationMapper.toQualityNotification(any(BPN.class), anyString(), any(QualityNotificationMessage.class), any(QualityNotificationType.class))).thenReturn(investigationTestData); + when(mockNotificationMessageMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); + when(mockNotificationMapper.toNotification(any(BPN.class), anyString(), any(NotificationMessage.class), any(NotificationType.class))).thenReturn(investigationTestData); // When service.handleReceive(edcNotification, notificationType); // Then - Mockito.verify(notificationRepository).saveQualityNotificationEntity(investigationTestData); + Mockito.verify(notificationRepository).saveNotification(investigationTestData); } @Test @@ -113,10 +113,10 @@ void testhandleReceiveValidSentNotification() { void testHandleNotificationUpdateValidAcknowledgeNotificationTransition() { // Given - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); + List affectedParts = List.of(new NotificationAffectedPart("partId")); - QualityNotificationType notificationType = QualityNotificationType.INVESTIGATION; - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationType notificationType = NotificationType.INVESTIGATION; + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .createdBy("senderBPN") @@ -125,28 +125,28 @@ void testHandleNotificationUpdateValidAcknowledgeNotificationTransition() { .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description("123") - .notificationStatus(QualityNotificationStatus.ACKNOWLEDGED) + .notificationStatus(NotificationStatus.ACKNOWLEDGED) .affectedParts(affectedParts) .type(notificationType) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .targetDate(Instant.now()) .messageId("messageId") .build(); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.RECEIVED, "recipientBPN"); - QualityNotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.RECEIVED, "recipientBPN"); + NotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); EDCNotification edcNotification = EDCNotificationFactory.createEdcNotification( "it", notification); - when(mockNotificationMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); + when(mockNotificationMessageMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); when(notificationRepository.findByEdcNotificationId(edcNotification.getNotificationId())).thenReturn(Optional.of(investigationTestData)); // When service.handleUpdate(edcNotification, notificationType); // Then - Mockito.verify(notificationRepository).updateQualityNotificationEntity(investigationTestData); + Mockito.verify(notificationRepository).updateNotification(investigationTestData); } @Test @@ -154,9 +154,9 @@ void testHandleNotificationUpdateValidAcknowledgeNotificationTransition() { void testhandleUpdateValidDeclineNotificationTransition() { // Given - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationType notificationType = QualityNotificationType.INVESTIGATION; - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationType notificationType = NotificationType.INVESTIGATION; + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .createdBy("senderBPN") @@ -165,27 +165,27 @@ void testhandleUpdateValidDeclineNotificationTransition() { .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description("123") - .notificationStatus(QualityNotificationStatus.DECLINED) + .notificationStatus(NotificationStatus.DECLINED) .affectedParts(affectedParts) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .type(notificationType) .targetDate(Instant.now()) .messageId("messageId") .build(); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.ACKNOWLEDGED, "recipientBPN"); - QualityNotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.ACKNOWLEDGED, "recipientBPN"); + NotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); EDCNotification edcNotification = EDCNotificationFactory.createEdcNotification( "it", notification); - when(mockNotificationMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); + when(mockNotificationMessageMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); when(notificationRepository.findByEdcNotificationId(edcNotification.getNotificationId())).thenReturn(Optional.of(investigationTestData)); // When service.handleUpdate(edcNotification, notificationType); // Then - Mockito.verify(notificationRepository).updateQualityNotificationEntity(investigationTestData); + Mockito.verify(notificationRepository).updateNotification(investigationTestData); } @Test @@ -193,9 +193,9 @@ void testhandleUpdateValidDeclineNotificationTransition() { void testhandleUpdateValidAcceptedNotificationTransition() { // Given - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationType notificationType = QualityNotificationType.INVESTIGATION; - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationType notificationType = NotificationType.INVESTIGATION; + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .createdBy("senderBPN") @@ -204,27 +204,27 @@ void testhandleUpdateValidAcceptedNotificationTransition() { .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description("123") - .notificationStatus(QualityNotificationStatus.ACCEPTED) + .notificationStatus(NotificationStatus.ACCEPTED) .affectedParts(affectedParts) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .type(notificationType) .targetDate(Instant.now()) .messageId("messageId") .build(); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.ACKNOWLEDGED, "recipientBPN"); - QualityNotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.ACKNOWLEDGED, "recipientBPN"); + NotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); EDCNotification edcNotification = EDCNotificationFactory.createEdcNotification( "it", notification); - when(mockNotificationMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); + when(mockNotificationMessageMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); when(notificationRepository.findByEdcNotificationId(edcNotification.getNotificationId())).thenReturn(Optional.of(investigationTestData)); // When service.handleUpdate(edcNotification, notificationType); // Then - Mockito.verify(notificationRepository).updateQualityNotificationEntity(investigationTestData); + Mockito.verify(notificationRepository).updateNotification(investigationTestData); } @Test @@ -232,9 +232,9 @@ void testhandleUpdateValidAcceptedNotificationTransition() { void testhandleUpdateValidCloseNotificationTransition() { // Given - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationType notificationType = QualityNotificationType.INVESTIGATION; - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationType notificationType = NotificationType.INVESTIGATION; + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .createdBy("senderBPN") @@ -243,27 +243,27 @@ void testhandleUpdateValidCloseNotificationTransition() { .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description("123") - .notificationStatus(QualityNotificationStatus.CLOSED) + .notificationStatus(NotificationStatus.CLOSED) .affectedParts(affectedParts) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .type(notificationType) .targetDate(Instant.now()) .messageId("messageId") .build(); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.ACKNOWLEDGED, "senderBPN"); - QualityNotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.ACKNOWLEDGED, "senderBPN"); + NotificationMessage notificationTestData = NotificationTestDataFactory.createNotificationTestData(); EDCNotification edcNotification = EDCNotificationFactory.createEdcNotification( "it", notification); - when(mockNotificationMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); + when(mockNotificationMessageMapper.toNotification(edcNotification, notificationType)).thenReturn(notificationTestData); when(notificationRepository.findByEdcNotificationId(edcNotification.getNotificationId())).thenReturn(Optional.of(investigationTestData)); // When service.handleUpdate(edcNotification, notificationType); // Then - Mockito.verify(notificationRepository).updateQualityNotificationEntity(investigationTestData); + Mockito.verify(notificationRepository).updateNotification(investigationTestData); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/NotificationPublisherServiceTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/NotificationPublisherServiceTest.java similarity index 56% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/NotificationPublisherServiceTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/NotificationPublisherServiceTest.java index 9a6a3ea9f9..3d7fd8529a 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/NotificationPublisherServiceTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/domain/service/NotificationPublisherServiceTest.java @@ -17,27 +17,27 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.domain.service; +package org.eclipse.tractusx.traceability.notification.domain.service; import org.eclipse.tractusx.traceability.assets.domain.asbuilt.repository.AssetAsBuiltRepository; import org.eclipse.tractusx.traceability.assets.domain.asbuilt.service.AssetAsBuiltServiceImpl; import org.eclipse.tractusx.traceability.bpn.domain.service.BpnRepository; import org.eclipse.tractusx.traceability.common.model.BPN; import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.SendNotificationException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.exception.QualityNotificationIllegalUpdate; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.service.EdcNotificationService; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.service.NotificationPublisherService; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.exception.NotificationNotSupportedException; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.model.StartQualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.notification.repository.NotificationRepository; +import org.eclipse.tractusx.traceability.notification.domain.base.exception.SendNotificationException; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.model.exception.NotificationIllegalUpdate; +import org.eclipse.tractusx.traceability.notification.domain.base.service.EdcNotificationService; +import org.eclipse.tractusx.traceability.notification.domain.base.service.NotificationPublisherService; +import org.eclipse.tractusx.traceability.notification.domain.notification.exception.NotificationNotSupportedException; +import org.eclipse.tractusx.traceability.notification.domain.notification.model.StartNotification; +import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository; import org.eclipse.tractusx.traceability.testdata.AssetTestDataFactory; import org.eclipse.tractusx.traceability.testdata.InvestigationTestDataFactory; import org.junit.jupiter.api.DisplayName; @@ -94,27 +94,27 @@ void testStartInvestigationSuccessful() { when(assetRepository.getAssetsById(assets)).thenReturn(List.of(AssetTestDataFactory.createAssetTestData())); when(traceabilityProperties.getBpn()).thenReturn(BPN.of("bpn-123")); String receiverBpn = "someReceiverBpn"; - StartQualityNotification startNotification = StartQualityNotification.builder() + StartNotification startNotification = StartNotification.builder() .title(title) .partIds(assets) .description(description) .targetDate(targetDate) - .severity(QualityNotificationSeverity.MINOR) - .type(QualityNotificationType.INVESTIGATION) + .severity(NotificationSeverity.MINOR) + .type(NotificationType.INVESTIGATION) .receiverBpn(receiverBpn) .isAsBuilt(true) .build(); // When - QualityNotification result = notificationPublisherService.startQualityNotification(startNotification); + Notification result = notificationPublisherService.startNotification(startNotification); // Then assertThat(result.getTitle()).isEqualTo(title); - assertThat(result.getNotificationStatus()).isEqualTo(QualityNotificationStatus.CREATED); + assertThat(result.getNotificationStatus()).isEqualTo(NotificationStatus.CREATED); assertThat(result.getDescription()).isEqualTo(description); - assertThat(result.getNotificationSide()).isEqualTo(QualityNotificationSide.SENDER); + assertThat(result.getNotificationSide()).isEqualTo(NotificationSide.SENDER); assertThat(result.getNotifications()).extracting("severity") - .containsExactly(QualityNotificationSeverity.MINOR); + .containsExactly(NotificationSeverity.MINOR); verify(assetRepository).getAssetsById(Arrays.asList("asset-1", "asset-2")); } @@ -126,19 +126,19 @@ void testThrowNotificationNotSupportedException() { String receiverBpn = "someReceiverBpn"; Instant targetDate = Instant.parse("2022-03-01T12:00:00Z"); List assets = Arrays.asList("asset-1", "asset-2"); - StartQualityNotification startNotification = StartQualityNotification.builder() + StartNotification startNotification = StartNotification.builder() .title(title) .partIds(assets) .description(description) .targetDate(targetDate) - .severity(QualityNotificationSeverity.MINOR) - .type(QualityNotificationType.INVESTIGATION) + .severity(NotificationSeverity.MINOR) + .type(NotificationType.INVESTIGATION) .receiverBpn(receiverBpn) .isAsBuilt(false) .build(); // Then - assertThrows(NotificationNotSupportedException.class, () -> notificationPublisherService.startQualityNotification(startNotification)); + assertThrows(NotificationNotSupportedException.class, () -> notificationPublisherService.startNotification(startNotification)); } @Test @@ -151,25 +151,25 @@ void testStartAlertSuccessful() { List assets = Arrays.asList("asset-1", "asset-2"); when(traceabilityProperties.getBpn()).thenReturn(BPN.of("bpn-123")); when(assetRepository.getAssetsById(assets)).thenReturn(List.of(AssetTestDataFactory.createAssetTestData())); - StartQualityNotification startNotification = StartQualityNotification.builder() + StartNotification startNotification = StartNotification.builder() .title(title) .partIds(assets) .description(description) .targetDate(targetDate) - .severity(QualityNotificationSeverity.MINOR) - .type(QualityNotificationType.INVESTIGATION) + .severity(NotificationSeverity.MINOR) + .type(NotificationType.INVESTIGATION) .receiverBpn(receiverBpn) .isAsBuilt(true) .build(); // When - QualityNotification result = notificationPublisherService.startQualityNotification(startNotification); + Notification result = notificationPublisherService.startNotification(startNotification); // Then - assertThat(result.getNotificationStatus()).isEqualTo(QualityNotificationStatus.CREATED); + assertThat(result.getNotificationStatus()).isEqualTo(NotificationStatus.CREATED); assertThat(result.getDescription()).isEqualTo(description); - assertThat(result.getNotificationSide()).isEqualTo(QualityNotificationSide.SENDER); + assertThat(result.getNotificationSide()).isEqualTo(NotificationSide.SENDER); assertThat(result.getNotifications()).extracting("severity") - .containsExactly(QualityNotificationSeverity.MINOR); + .containsExactly(NotificationSeverity.MINOR); assertThat(result.getNotifications()).hasSize(1) .first() .hasFieldOrPropertyWithValue("sendTo", receiverBpn); @@ -181,29 +181,29 @@ void testStartAlertSuccessful() { void testCancelInvestigationSuccessful() { // Given BPN bpn = new BPN("bpn123"); - QualityNotification investigation = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.CREATED, QualityNotificationStatus.CREATED); + Notification investigation = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.CREATED, NotificationStatus.CREATED); when(traceabilityProperties.getBpn()).thenReturn(bpn); // When - QualityNotification result = notificationPublisherService.cancelNotification(investigation); + Notification result = notificationPublisherService.cancelNotification(investigation); // Then - assertThat(result.getNotificationStatus()).isEqualTo(QualityNotificationStatus.CANCELED); + assertThat(result.getNotificationStatus()).isEqualTo(NotificationStatus.CANCELED); } @Test void testSendInvestigationSuccessful() { // Given final BPN bpn = new BPN("bpn123"); - QualityNotification investigation = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.CREATED, QualityNotificationStatus.CREATED); - QualityNotificationMessage notificationMessage = investigation.getNotifications().stream().findFirst().get(); + Notification investigation = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.CREATED, NotificationStatus.CREATED); + NotificationMessage notificationMessage = investigation.getNotifications().stream().findFirst().get(); when(traceabilityProperties.getBpn()).thenReturn(bpn); when(notificationsService.asyncNotificationMessageExecutor(any())).thenReturn(CompletableFuture.completedFuture(notificationMessage)); // When - QualityNotification result = notificationPublisherService.approveNotification(investigation); + Notification result = notificationPublisherService.approveNotification(investigation); // Then - assertThat(result.getNotificationStatus()).isEqualTo(QualityNotificationStatus.SENT); + assertThat(result.getNotificationStatus()).isEqualTo(NotificationStatus.SENT); verify(notificationsService).asyncNotificationMessageExecutor(any()); } @@ -211,7 +211,7 @@ void testSendInvestigationSuccessful() { void testSendInvestigationFailed() { // Given final BPN bpn = new BPN("bpn123"); - QualityNotification investigation = InvestigationTestDataFactory.createInvestigationTestData(QualityNotificationStatus.CREATED, QualityNotificationStatus.CREATED); + Notification investigation = InvestigationTestDataFactory.createInvestigationTestData(NotificationStatus.CREATED, NotificationStatus.CREATED); when(traceabilityProperties.getBpn()).thenReturn(bpn); when(notificationsService.asyncNotificationMessageExecutor(any())).thenReturn(CompletableFuture.completedFuture(null)); @@ -226,44 +226,44 @@ void testUpdateInvestigation() { // Given BPN bpn = BPN.of("senderBPN"); - QualityNotificationStatus status = QualityNotificationStatus.ACKNOWLEDGED; + NotificationStatus status = NotificationStatus.ACKNOWLEDGED; String reason = "the update reason"; - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .created(LocalDateTime.now()) .targetDate(Instant.now()) - .notificationStatus(QualityNotificationStatus.CREATED) + .notificationStatus(NotificationStatus.CREATED) .affectedParts(affectedParts) .build(); - QualityNotificationMessage notification2 = QualityNotificationMessage.builder() + NotificationMessage notification2 = NotificationMessage.builder() .id("456") .notificationReferenceId("id123") .created(LocalDateTime.now().plusSeconds(10)) .targetDate(Instant.now()) - .notificationStatus(QualityNotificationStatus.ACKNOWLEDGED) + .notificationStatus(NotificationStatus.ACKNOWLEDGED) .build(); - List notifications = new ArrayList<>(); + List notifications = new ArrayList<>(); notifications.add(notification); notifications.add(notification2); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(QualityNotificationStatus.RECEIVED, "recipientBPN", notifications); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(NotificationStatus.RECEIVED, "recipientBPN", notifications); when(traceabilityProperties.getBpn()).thenReturn(bpn); when(notificationsService.asyncNotificationMessageExecutor(any())).thenReturn(CompletableFuture.completedFuture(notification2)); // When - QualityNotification result = notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason); + Notification result = notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason); // Then - assertThat(result.getNotificationStatus()).isEqualTo(QualityNotificationStatus.ACKNOWLEDGED); + assertThat(result.getNotificationStatus()).isEqualTo(NotificationStatus.ACKNOWLEDGED); assertThat(result.getDeclineReason()).isNull(); assertThat(result.getCloseReason()).isNull(); assertThat(result.getDeclineReason()).isNull(); - Mockito.verify(notificationsService, times(1)).asyncNotificationMessageExecutor(any(QualityNotificationMessage.class)); + Mockito.verify(notificationsService, times(1)).asyncNotificationMessageExecutor(any(NotificationMessage.class)); } @Test @@ -272,43 +272,43 @@ void testUpdateInvestigationAccepted() { // Given BPN bpn = BPN.of("senderBPN"); - QualityNotificationStatus status = QualityNotificationStatus.ACCEPTED; + NotificationStatus status = NotificationStatus.ACCEPTED; String reason = "the update reason"; - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .created(LocalDateTime.now()) .targetDate(Instant.now()) - .notificationStatus(QualityNotificationStatus.CREATED) + .notificationStatus(NotificationStatus.CREATED) .affectedParts(affectedParts) .build(); - QualityNotificationMessage notification2 = QualityNotificationMessage.builder() + NotificationMessage notification2 = NotificationMessage.builder() .id("456") .notificationReferenceId("id123") .created(LocalDateTime.now().plusSeconds(10)) .targetDate(Instant.now()) - .notificationStatus(QualityNotificationStatus.ACCEPTED) + .notificationStatus(NotificationStatus.ACCEPTED) .affectedParts(affectedParts) .build(); - List notifications = new ArrayList<>(); + List notifications = new ArrayList<>(); notifications.add(notification); notifications.add(notification2); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(QualityNotificationStatus.ACKNOWLEDGED, "recipientBPN", notifications); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(NotificationStatus.ACKNOWLEDGED, "recipientBPN", notifications); when(traceabilityProperties.getBpn()).thenReturn(bpn); when(notificationsService.asyncNotificationMessageExecutor(any())).thenReturn(CompletableFuture.completedFuture(notification2)); // When - QualityNotification result = notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason); + Notification result = notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason); // Then - assertThat(result.getNotificationStatus()).isEqualTo(QualityNotificationStatus.ACCEPTED); + assertThat(result.getNotificationStatus()).isEqualTo(NotificationStatus.ACCEPTED); assertThat(result.getAcceptReason()).isEqualTo(reason); - Mockito.verify(notificationsService, times(1)).asyncNotificationMessageExecutor(any(QualityNotificationMessage.class)); + Mockito.verify(notificationsService, times(1)).asyncNotificationMessageExecutor(any(NotificationMessage.class)); } @Test @@ -317,43 +317,43 @@ void testUpdateInvestigationDeclined() { // Given BPN bpn = BPN.of("senderBPN"); - QualityNotificationStatus status = QualityNotificationStatus.DECLINED; + NotificationStatus status = NotificationStatus.DECLINED; String reason = "the update reason"; - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .created(LocalDateTime.now()) .targetDate(Instant.now()) - .notificationStatus(QualityNotificationStatus.ACKNOWLEDGED) + .notificationStatus(NotificationStatus.ACKNOWLEDGED) .affectedParts(affectedParts) .build(); - QualityNotificationMessage notification2 = QualityNotificationMessage.builder() + NotificationMessage notification2 = NotificationMessage.builder() .id("456") .notificationReferenceId("id123") - .notificationStatus(QualityNotificationStatus.DECLINED) + .notificationStatus(NotificationStatus.DECLINED) .affectedParts(affectedParts) .created(LocalDateTime.now().plusSeconds(10)) .targetDate(Instant.now()) .build(); - List notifications = new ArrayList<>(); + List notifications = new ArrayList<>(); notifications.add(notification); notifications.add(notification2); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(QualityNotificationStatus.ACKNOWLEDGED, "recipientBPN", notifications); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(NotificationStatus.ACKNOWLEDGED, "recipientBPN", notifications); when(traceabilityProperties.getBpn()).thenReturn(bpn); when(notificationsService.asyncNotificationMessageExecutor(any())).thenReturn(CompletableFuture.completedFuture(notification2)); // When - QualityNotification result = notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason); + Notification result = notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason); // Then - assertThat(result.getNotificationStatus()).isEqualTo(QualityNotificationStatus.DECLINED); + assertThat(result.getNotificationStatus()).isEqualTo(NotificationStatus.DECLINED); assertThat(result.getDeclineReason()).isEqualTo(reason); - Mockito.verify(notificationsService, times(1)).asyncNotificationMessageExecutor(any(QualityNotificationMessage.class)); + Mockito.verify(notificationsService, times(1)).asyncNotificationMessageExecutor(any(NotificationMessage.class)); } @Test @@ -362,41 +362,41 @@ void testUpdateInvestigationClose() { // Given BPN bpn = BPN.of("senderBPN"); - QualityNotificationStatus status = QualityNotificationStatus.CLOSED; + NotificationStatus status = NotificationStatus.CLOSED; String reason = "the update reason"; - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .created(LocalDateTime.now()) - .notificationStatus(QualityNotificationStatus.CREATED) + .notificationStatus(NotificationStatus.CREATED) .affectedParts(affectedParts) .build(); - QualityNotificationMessage notification2 = QualityNotificationMessage.builder() + NotificationMessage notification2 = NotificationMessage.builder() .id("456") .notificationReferenceId("id123") .created(LocalDateTime.now().plusSeconds(10)) - .notificationStatus(QualityNotificationStatus.CLOSED) + .notificationStatus(NotificationStatus.CLOSED) .affectedParts(affectedParts) .build(); - List notifications = new ArrayList<>(); + List notifications = new ArrayList<>(); notifications.add(notification); notifications.add(notification2); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(QualityNotificationStatus.ACCEPTED, "senderBPN", notifications); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(NotificationStatus.ACCEPTED, "senderBPN", notifications); when(traceabilityProperties.getBpn()).thenReturn(bpn); when(notificationsService.asyncNotificationMessageExecutor(any())).thenReturn(CompletableFuture.completedFuture(notification2)); // When - QualityNotification result = notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason); + Notification result = notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason); // Then - assertThat(result.getNotificationStatus()).isEqualTo(QualityNotificationStatus.CLOSED); + assertThat(result.getNotificationStatus()).isEqualTo(NotificationStatus.CLOSED); assertThat(result.getCloseReason()).isEqualTo(reason); - Mockito.verify(notificationsService, times(1)).asyncNotificationMessageExecutor(any(QualityNotificationMessage.class)); + Mockito.verify(notificationsService, times(1)).asyncNotificationMessageExecutor(any(NotificationMessage.class)); } @Test @@ -405,28 +405,28 @@ void testUpdateInvestigationInvalid() { // Given BPN bpn = BPN.of("recipientBPN"); - QualityNotificationStatus status = QualityNotificationStatus.CREATED; + NotificationStatus status = NotificationStatus.CREATED; String reason = "the update reason"; - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + List affectedParts = List.of(new NotificationAffectedPart("partId")); + NotificationMessage notification = NotificationMessage.builder() .id("123") .notificationReferenceId("id123") - .notificationStatus(QualityNotificationStatus.CREATED) + .notificationStatus(NotificationStatus.CREATED) .affectedParts(affectedParts) .build(); - List notifications = new ArrayList<>(); + List notifications = new ArrayList<>(); notifications.add(notification); - QualityNotification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(QualityNotificationStatus.SENT, "recipientBPN", notifications); + Notification investigationTestData = InvestigationTestDataFactory.createInvestigationTestDataWithNotificationList(NotificationStatus.SENT, "recipientBPN", notifications); when(traceabilityProperties.getBpn()).thenReturn(bpn); // When - assertThrows(QualityNotificationIllegalUpdate.class, () -> notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason)); + assertThrows(NotificationIllegalUpdate.class, () -> notificationPublisherService.updateNotificationPublisher(investigationTestData, status, reason)); // Then - Mockito.verify(repository, never()).updateQualityNotificationEntity(investigationTestData); - Mockito.verify(notificationsService, never()).asyncNotificationMessageExecutor(any(QualityNotificationMessage.class)); + Mockito.verify(repository, never()).updateNotification(investigationTestData); + Mockito.verify(notificationsService, never()).asyncNotificationMessageExecutor(any(NotificationMessage.class)); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/investigation/repository/InvestigationsRepositoryImplTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/infrastructure/investigation/repository/InvestigationsRepositoryImplTest.java similarity index 62% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/investigation/repository/InvestigationsRepositoryImplTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/infrastructure/investigation/repository/InvestigationsRepositoryImplTest.java index 8ee010d926..8f75a39118 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/investigation/repository/InvestigationsRepositoryImplTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/infrastructure/investigation/repository/InvestigationsRepositoryImplTest.java @@ -16,21 +16,21 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.investigation.repository; +package org.eclipse.tractusx.traceability.notification.infrastructure.investigation.repository; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.repository.JpaAssetAsBuiltRepository; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationMessageRepository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.NotificationRepositoryImpl; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationMessageRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.NotificationRepositoryImpl; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -70,8 +70,8 @@ class InvestigationsRepositoryImplTest { void updateErrorMessage() { // Given - QualityNotificationMessage message = QualityNotificationMessage.builder().notificationStatus(QualityNotificationStatus.ACKNOWLEDGED).affectedParts(List.of(new QualityNotificationAffectedPart("123"))).build(); - QualityNotification qualityNotification = QualityNotification.builder().notificationStatus(QualityNotificationStatus.ACKNOWLEDGED).assetIds(List.of("123")).notificationId(new QualityNotificationId(123L)).bpn(BPN.of("ABC")).notifications(List.of(message)).build(); + NotificationMessage message = NotificationMessage.builder().notificationStatus(NotificationStatus.ACKNOWLEDGED).affectedParts(List.of(new NotificationAffectedPart("123"))).build(); + Notification notification = Notification.builder().notificationStatus(NotificationStatus.ACKNOWLEDGED).assetIds(List.of("123")).notificationId(new NotificationId(123L)).bpn(BPN.of("ABC")).notifications(List.of(message)).build(); AssetAsBuiltEntity assetAsBuiltEntity = AssetAsBuiltEntity.builder().id("123").build(); NotificationEntity entity = NotificationEntity.builder().assets(List.of(assetAsBuiltEntity)).build(); NotificationMessageEntity notificationEntity = NotificationMessageEntity.from(entity, message, List.of(assetAsBuiltEntity)); @@ -81,7 +81,7 @@ void updateErrorMessage() { when(clock.instant()).thenReturn(Instant.now()); when(clock.getZone()).thenReturn(ZoneId.systemDefault()); // When - investigationsRepository.updateErrorMessage(qualityNotification); + investigationsRepository.updateErrorMessage(notification); // Then verify(jpaNotificationMessageRepository, times(1)).save(any()); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/investigation/repository/NotificationRepositoryImplTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/infrastructure/investigation/repository/NotificationRepositoryImplTest.java similarity index 62% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/investigation/repository/NotificationRepositoryImplTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/infrastructure/investigation/repository/NotificationRepositoryImplTest.java index ddc7420e21..83134ef3c8 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/investigation/repository/NotificationRepositoryImplTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/infrastructure/investigation/repository/NotificationRepositoryImplTest.java @@ -16,21 +16,21 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.infrastructure.investigation.repository; +package org.eclipse.tractusx.traceability.notification.infrastructure.investigation.repository; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity; import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.repository.JpaAssetAsBuiltRepository; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.model.NotificationMessageEntity; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationMessageRepository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.JpaNotificationRepository; -import org.eclipse.tractusx.traceability.qualitynotification.infrastructure.notification.repository.NotificationRepositoryImpl; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.model.NotificationMessageEntity; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationMessageRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.JpaNotificationRepository; +import org.eclipse.tractusx.traceability.notification.infrastructure.notification.repository.NotificationRepositoryImpl; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -70,8 +70,8 @@ class NotificationRepositoryImplTest { void updateErrorMessage() { // Given - QualityNotificationMessage message = QualityNotificationMessage.builder().notificationStatus(QualityNotificationStatus.ACKNOWLEDGED).affectedParts(List.of(new QualityNotificationAffectedPart("123"))).build(); - QualityNotification qualityNotification = QualityNotification.builder().notificationStatus(QualityNotificationStatus.ACKNOWLEDGED).assetIds(List.of("123")).notificationId(new QualityNotificationId(123L)).bpn(BPN.of("ABC")).notifications(List.of(message)).build(); + NotificationMessage message = NotificationMessage.builder().notificationStatus(NotificationStatus.ACKNOWLEDGED).affectedParts(List.of(new NotificationAffectedPart("123"))).build(); + Notification notification = Notification.builder().notificationStatus(NotificationStatus.ACKNOWLEDGED).assetIds(List.of("123")).notificationId(new NotificationId(123L)).bpn(BPN.of("ABC")).notifications(List.of(message)).build(); AssetAsBuiltEntity assetAsBuiltEntity = AssetAsBuiltEntity.builder().id("123").build(); NotificationEntity entity = NotificationEntity.builder().assets(List.of(assetAsBuiltEntity)).build(); NotificationMessageEntity notificationEntity = NotificationMessageEntity.from(entity, message, List.of(assetAsBuiltEntity)); @@ -81,7 +81,7 @@ void updateErrorMessage() { when(clock.instant()).thenReturn(Instant.now()); when(clock.getZone()).thenReturn(ZoneId.systemDefault()); // When - notificationRepository.updateErrorMessage(qualityNotification); + notificationRepository.updateErrorMessage(notification); // Then verify(jpaNotificationMessageRepository, times(1)).save(any()); diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/investigation/rest/model/UpdateQualityNotificationStatusTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/investigation/rest/model/UpdateNotificationStatusTest.java similarity index 72% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/investigation/rest/model/UpdateQualityNotificationStatusTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/investigation/rest/model/UpdateNotificationStatusTest.java index 351e0dfb86..da5557b7d2 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/investigation/rest/model/UpdateQualityNotificationStatusTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/investigation/rest/model/UpdateNotificationStatusTest.java @@ -17,33 +17,33 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.investigation.rest.model; +package org.eclipse.tractusx.traceability.notification.investigation.rest.model; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; import org.junit.jupiter.api.Test; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; -class UpdateQualityNotificationStatusTest { +class UpdateNotificationStatusTest { @Test void testToInvestigationStatusACCEPTED() { String accepted = "ACCEPTED"; - QualityNotificationStatus actualInvestigationStatus = QualityNotificationStatus.fromStringValue(accepted); + NotificationStatus actualInvestigationStatus = NotificationStatus.fromStringValue(accepted); assertThat(actualInvestigationStatus.name()).isEqualTo("ACCEPTED"); } @Test void testToInvestigationStatusACKNOWLEDGED() { String acknowledged = "ACKNOWLEDGED"; - QualityNotificationStatus actualInvestigationStatus = QualityNotificationStatus.fromStringValue(acknowledged); + NotificationStatus actualInvestigationStatus = NotificationStatus.fromStringValue(acknowledged); assertThat(actualInvestigationStatus.name()).isEqualTo("ACKNOWLEDGED"); } @Test void testToInvestigationStatusDECLINED() { String declined = "DECLINED"; - QualityNotificationStatus actualInvestigationStatus = QualityNotificationStatus.fromStringValue(declined); + NotificationStatus actualInvestigationStatus = NotificationStatus.fromStringValue(declined); assertThat(actualInvestigationStatus.name()).isEqualTo("DECLINED"); } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/investigation/rest/validation/UpdateQualityNotificationValidatorTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/investigation/rest/validation/UpdateNotificationValidatorTest.java similarity index 59% rename from tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/investigation/rest/validation/UpdateQualityNotificationValidatorTest.java rename to tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/investigation/rest/validation/UpdateNotificationValidatorTest.java index 1a61f10b1c..e2922ad1c8 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/investigation/rest/validation/UpdateQualityNotificationValidatorTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/notification/investigation/rest/validation/UpdateNotificationValidatorTest.java @@ -19,40 +19,35 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package org.eclipse.tractusx.traceability.qualitynotification.investigation.rest.validation; +package org.eclipse.tractusx.traceability.notification.investigation.rest.validation; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.validation.UpdateQualityNotificationValidationException; -import org.eclipse.tractusx.traceability.qualitynotification.application.notification.validation.UpdateQualityNotificationValidator; +import org.eclipse.tractusx.traceability.notification.application.notification.validation.UpdateNotificationValidationException; +import org.eclipse.tractusx.traceability.notification.application.notification.validation.UpdateNotificationValidator; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; -import qualitynotification.base.request.UpdateQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; +import notification.request.UpdateNotificationRequest; +import notification.request.UpdateNotificationStatusRequest; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @ExtendWith(MockitoExtension.class) -class UpdateQualityNotificationValidatorTest { - - @InjectMocks - UpdateQualityNotificationValidator updateInvestigationValidator; - +class UpdateNotificationValidatorTest { @Test @DisplayName("No Validation Success for invalid Reason") void testUnsuccessfulValidationForInvalidReason() { - UpdateQualityNotificationStatusRequest acknowledged = UpdateQualityNotificationStatusRequest.ACKNOWLEDGED; + UpdateNotificationStatusRequest acknowledged = UpdateNotificationStatusRequest.ACKNOWLEDGED; String reason = "some-reason-for-update"; String errorMessage = "Update investigation reason can't be present for ACKNOWLEDGED status"; - UpdateQualityNotificationRequest request = UpdateQualityNotificationRequest.builder().build(); + UpdateNotificationRequest request = UpdateNotificationRequest.builder().build(); request.setReason(reason); request.setStatus(acknowledged); - UpdateQualityNotificationValidationException exception = assertThrows(UpdateQualityNotificationValidationException.class, () -> UpdateQualityNotificationValidator.validate(request)); + UpdateNotificationValidationException exception = assertThrows(UpdateNotificationValidationException.class, () -> UpdateNotificationValidator.validate(request)); assertEquals(errorMessage, exception.getMessage()); } @@ -60,11 +55,11 @@ void testUnsuccessfulValidationForInvalidReason() { @Test @DisplayName("Execute Validation successfully") void testSuccessfulValidation() { - UpdateQualityNotificationStatusRequest accepted = UpdateQualityNotificationStatusRequest.ACCEPTED; - UpdateQualityNotificationRequest request = UpdateQualityNotificationRequest.builder().build(); + UpdateNotificationStatusRequest accepted = UpdateNotificationStatusRequest.ACCEPTED; + UpdateNotificationRequest request = UpdateNotificationRequest.builder().build(); request.setReason("abcdefg12313212321123"); request.setStatus(accepted); - UpdateQualityNotificationValidator.validate(request); + UpdateNotificationValidator.validate(request); } } diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/testdata/InvestigationTestDataFactory.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/testdata/InvestigationTestDataFactory.java index 4a94c60643..ac2e0e40e6 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/testdata/InvestigationTestDataFactory.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/testdata/InvestigationTestDataFactory.java @@ -20,29 +20,29 @@ package org.eclipse.tractusx.traceability.testdata; import org.eclipse.tractusx.traceability.common.model.BPN; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotification; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationId; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSide; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationId; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; import java.time.Instant; import java.util.ArrayList; import java.util.List; public class InvestigationTestDataFactory { - public static QualityNotification createInvestigationTestData(QualityNotificationStatus investigationStatus, final String bpnString) { - QualityNotificationId investigationId = new QualityNotificationId(1L); + public static Notification createInvestigationTestData(NotificationStatus investigationStatus, final String bpnString) { + NotificationId investigationId = new NotificationId(1L); BPN bpn = new BPN(bpnString); - QualityNotificationSide investigationSide = QualityNotificationSide.SENDER; + NotificationSide investigationSide = NotificationSide.SENDER; String description = "Test Investigation"; Instant createdAt = Instant.now(); List assetIds = List.of("asset123", "asset456"); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .id("1") .notificationReferenceId("notificationId") .createdBy("senderBPN") @@ -52,21 +52,21 @@ public static QualityNotification createInvestigationTestData(QualityNotificatio .contractAgreementId("agreement") .description(description) .notificationStatus(investigationStatus) - .affectedParts(List.of(new QualityNotificationAffectedPart("part123"))) + .affectedParts(List.of(new NotificationAffectedPart("part123"))) .targetDate(Instant.now()) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .edcNotificationId("1") .messageId("messageId") .build(); - List notifications = List.of(notification); + List notifications = List.of(notification); - return QualityNotification.builder() + return Notification.builder() .notificationId(investigationId) .bpn(bpn) .notificationStatus(investigationStatus) .notificationSide(investigationSide) .description(description) - .notificationType(QualityNotificationType.INVESTIGATION) + .notificationType(NotificationType.INVESTIGATION) .createdAt(createdAt) .assetIds(assetIds) .notifications(notifications) @@ -74,15 +74,15 @@ public static QualityNotification createInvestigationTestData(QualityNotificatio } - public static QualityNotification createInvestigationTestDataWithNotificationList(QualityNotificationStatus investigationStatus, String bpnString, List notifications) { - QualityNotificationId investigationId = new QualityNotificationId(1L); + public static Notification createInvestigationTestDataWithNotificationList(NotificationStatus investigationStatus, String bpnString, List notifications) { + NotificationId investigationId = new NotificationId(1L); BPN bpn = new BPN(bpnString); - QualityNotificationSide investigationSide = QualityNotificationSide.SENDER; + NotificationSide investigationSide = NotificationSide.SENDER; String description = "Test Investigation"; Instant createdAt = Instant.now(); List assetIds = List.of("asset123", "asset456"); - return QualityNotification.builder() + return Notification.builder() .notificationId(investigationId) .bpn(bpn) .notificationStatus(investigationStatus) @@ -94,15 +94,15 @@ public static QualityNotification createInvestigationTestDataWithNotificationLis .build(); } - public static QualityNotification createInvestigationTestData(QualityNotificationStatus investigationStatus, QualityNotificationStatus notificationInvestigationStatus) { - QualityNotificationId investigationId = new QualityNotificationId(1L); + public static Notification createInvestigationTestData(NotificationStatus investigationStatus, NotificationStatus notificationInvestigationStatus) { + NotificationId investigationId = new NotificationId(1L); BPN bpn = new BPN("bpn123"); - QualityNotificationSide investigationSide = QualityNotificationSide.SENDER; + NotificationSide investigationSide = NotificationSide.SENDER; String description = "Test Investigation"; Instant createdAt = Instant.now(); List assetIds = List.of("asset123", "asset456"); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .id("1") .notificationReferenceId("notificationId") .createdBy("senderBPN") @@ -112,14 +112,14 @@ public static QualityNotification createInvestigationTestData(QualityNotificatio .contractAgreementId("agreement") .description(description) .notificationStatus(notificationInvestigationStatus) - .type(QualityNotificationType.INVESTIGATION) - .affectedParts(List.of(new QualityNotificationAffectedPart("part123"))) - .severity(QualityNotificationSeverity.MINOR) + .type(NotificationType.INVESTIGATION) + .affectedParts(List.of(new NotificationAffectedPart("part123"))) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .messageId("messageId") .build(); - QualityNotificationMessage notification2 = QualityNotificationMessage.builder() + NotificationMessage notification2 = NotificationMessage.builder() .id("1") .notificationReferenceId("notificationId") .createdBy("senderBPN") @@ -128,39 +128,39 @@ public static QualityNotification createInvestigationTestData(QualityNotificatio .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description(description) - .notificationStatus(QualityNotificationStatus.SENT) - .type(QualityNotificationType.INVESTIGATION) - .affectedParts(List.of(new QualityNotificationAffectedPart("part123"))) - .severity(QualityNotificationSeverity.MINOR) + .notificationStatus(NotificationStatus.SENT) + .type(NotificationType.INVESTIGATION) + .affectedParts(List.of(new NotificationAffectedPart("part123"))) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .messageId("messageId") .build(); - List notifications = new ArrayList<>(); + List notifications = new ArrayList<>(); notifications.add(notification); notifications.add(notification2); - return QualityNotification.builder() + return Notification.builder() .notificationId(investigationId) .bpn(bpn) .notificationStatus(investigationStatus) .notificationSide(investigationSide) .description(description) .createdAt(createdAt) - .notificationType(QualityNotificationType.INVESTIGATION) + .notificationType(NotificationType.INVESTIGATION) .assetIds(assetIds) .notifications(notifications) .build(); } - public static QualityNotification createInvestigationTestData(QualityNotificationSide investigationSide) { - QualityNotificationId investigationId = new QualityNotificationId(1L); + public static Notification createInvestigationTestData(NotificationSide investigationSide) { + NotificationId investigationId = new NotificationId(1L); BPN bpn = new BPN("bpn123"); String description = "Test Investigation"; Instant createdAt = Instant.now(); List assetIds = List.of("asset123", "asset456"); - QualityNotificationMessage notification = QualityNotificationMessage.builder() + NotificationMessage notification = NotificationMessage.builder() .id("1") .notificationReferenceId("notificationId") .createdBy("senderBPN") @@ -169,18 +169,18 @@ public static QualityNotification createInvestigationTestData(QualityNotificatio .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description(description) - .notificationStatus(QualityNotificationStatus.ACKNOWLEDGED) - .affectedParts(List.of(new QualityNotificationAffectedPart("part123"))) - .severity(QualityNotificationSeverity.MINOR) + .notificationStatus(NotificationStatus.ACKNOWLEDGED) + .affectedParts(List.of(new NotificationAffectedPart("part123"))) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .messageId("messageId") .build(); - List notifications = List.of(notification); + List notifications = List.of(notification); - return QualityNotification.builder() + return Notification.builder() .notificationId(investigationId) .bpn(bpn) - .notificationStatus(QualityNotificationStatus.ACKNOWLEDGED) + .notificationStatus(NotificationStatus.ACKNOWLEDGED) .notificationSide(investigationSide) .description(description) .createdAt(createdAt) diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/testdata/NotificationTestDataFactory.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/testdata/NotificationTestDataFactory.java index f654c00c71..9c5c9c6085 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/testdata/NotificationTestDataFactory.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/testdata/NotificationTestDataFactory.java @@ -19,21 +19,21 @@ package org.eclipse.tractusx.traceability.testdata; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationAffectedPart; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationMessage; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationSeverity; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationStatus; -import org.eclipse.tractusx.traceability.qualitynotification.domain.base.model.QualityNotificationType; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationAffectedPart; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSeverity; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationStatus; +import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationType; import java.time.Instant; import java.util.List; public class NotificationTestDataFactory { - public static QualityNotificationMessage createNotificationTestData() { - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); + public static NotificationMessage createNotificationTestData() { + List affectedParts = List.of(new NotificationAffectedPart("partId")); - return QualityNotificationMessage.builder() + return NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .createdBy("senderBPN") @@ -42,20 +42,20 @@ public static QualityNotificationMessage createNotificationTestData() { .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description("123") - .notificationStatus(QualityNotificationStatus.ACKNOWLEDGED) + .notificationStatus(NotificationStatus.ACKNOWLEDGED) .affectedParts(affectedParts) - .type(QualityNotificationType.INVESTIGATION) - .severity(QualityNotificationSeverity.MINOR) + .type(NotificationType.INVESTIGATION) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .targetDate(Instant.parse("2022-03-01T12:00:00Z")) .messageId("messageId") .build(); } - public static QualityNotificationMessage createNotificationTestData(QualityNotificationType qualityNotificationType) { - List affectedParts = List.of(new QualityNotificationAffectedPart("partId")); + public static NotificationMessage createNotificationTestData(NotificationType notificationType) { + List affectedParts = List.of(new NotificationAffectedPart("partId")); - return QualityNotificationMessage.builder() + return NotificationMessage.builder() .id("123") .notificationReferenceId("id123") .createdBy("senderBPN") @@ -64,13 +64,13 @@ public static QualityNotificationMessage createNotificationTestData(QualityNotif .sendToName("receiverManufacturerName") .contractAgreementId("agreement") .description("123") - .notificationStatus(QualityNotificationStatus.ACKNOWLEDGED) + .notificationStatus(NotificationStatus.ACKNOWLEDGED) .affectedParts(affectedParts) - .severity(QualityNotificationSeverity.MINOR) + .severity(NotificationSeverity.MINOR) .edcNotificationId("123") .targetDate(Instant.parse("2022-03-01T12:00:00Z")) .messageId("messageId") - .type(qualityNotificationType) + .type(notificationType) .build(); } } 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 987c9e9e7f..67d71d2ab1 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 @@ -34,9 +34,9 @@ import org.eclipse.tractusx.traceability.test.tooling.rest.RestProvider; import org.eclipse.tractusx.traceability.test.validator.NotificationValidator; import org.hamcrest.Matchers; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; -import qualitynotification.base.response.QualityNotificationIdResponse; -import qualitynotification.base.response.QualityNotificationResponse; +import notification.request.UpdateNotificationStatusRequest; +import notification.response.NotificationIdResponse; +import notification.response.NotificationResponse; import java.time.Instant; import java.util.Arrays; @@ -101,7 +101,7 @@ public void iCreateQualityInvestigation(DataTable dataTable) { final String severity = input.get("severity"); - final QualityNotificationIdResponse idResponse = restProvider.createNotification( + final NotificationIdResponse idResponse = restProvider.createNotification( testAssets, notificationDescription, targetDate, @@ -121,7 +121,7 @@ public void iCheckIfQualityInvestigationHasProperValues(DataTable dataTable) { .ignoreExceptions() .until(() -> { try { - QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv()); + NotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv()); NotificationValidator.assertHasFields(result, normalize(dataTable.asMap())); return true; } catch (AssertionError assertionError) { @@ -160,12 +160,12 @@ public void iCloseQualityAlert() { @When("I check, if quality investigation has been received") public void iCanSeeNotificationWasReceived() { System.out.println("searching for notificationDescription: " + notificationDescription); - final QualityNotificationResponse notification = await() + final NotificationResponse notification = await() .atMost(Duration.FIVE_MINUTES) .pollInterval(1, TimeUnit.SECONDS) .until(() -> { - final List result = restProvider.getReceivedNotifications(); - result.stream().map(QualityNotificationResponse::getDescription).forEach(System.out::println); + final List result = restProvider.getReceivedNotifications(); + result.stream().map(NotificationResponse::getDescription).forEach(System.out::println); return result.stream().filter(qn -> Objects.equals(qn.getDescription(), notificationDescription)).findFirst().orElse(null); }, Matchers.notNullValue() ); @@ -177,8 +177,8 @@ public void iCanSeeNotificationWasReceived() { @When("I check, if quality investigation has not been received") public void iCanSeeInvestigationWasNotReceived() { - final List result = restProvider.getReceivedNotifications(); - Optional first = result.stream() + final List result = restProvider.getReceivedNotifications(); + Optional first = result.stream() .filter(qualityNotificationResponse -> Objects.equals(qualityNotificationResponse.getId(), getNotificationIdBasedOnEnv())) .findFirst(); assertThat(first.isEmpty()).isTrue(); @@ -186,8 +186,8 @@ public void iCanSeeInvestigationWasNotReceived() { @When("I check, if quality alert has not been received") public void iCanSeeAlertWasNotReceived() { - final List result = restProvider.getReceivedNotifications(); - Optional first = result.stream() + final List result = restProvider.getReceivedNotifications(); + Optional first = result.stream() .filter(qualityNotificationResponse -> Objects.equals(qualityNotificationResponse.getId(), getNotificationIdBasedOnEnv())) .findFirst(); assertThat(first.isEmpty()).isTrue(); @@ -195,28 +195,28 @@ public void iCanSeeAlertWasNotReceived() { @When("I acknowledge quality investigation") public void iAcknowledgeQualityInvestigation() { - restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACKNOWLEDGED, ""); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateNotificationStatusRequest.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(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACCEPTED, reason); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateNotificationStatusRequest.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(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.DECLINED, reason); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateNotificationStatusRequest.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(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.DECLINED, reason); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateNotificationStatusRequest.DECLINED, reason); } private Long getNotificationIdBasedOnEnv() { @@ -255,7 +255,7 @@ public void iCreateQualityAlert(DataTable dataTable) { final String severity = input.get("severity"); - final QualityNotificationIdResponse idResponse = restProvider.createNotification( + final NotificationIdResponse idResponse = restProvider.createNotification( testAssets, notificationDescription, targetDate, @@ -275,7 +275,7 @@ public void iCheckIfQualityAlertHasProperValues(DataTable dataTable) { .ignoreExceptions() .until(() -> { try { - QualityNotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv()); + NotificationResponse result = restProvider.getNotification(getNotificationIdBasedOnEnv()); NotificationValidator.assertHasFields(result, normalize(dataTable.asMap())); return true; } catch (AssertionError assertionError) { @@ -296,12 +296,12 @@ public void iApproveQualityAlert() { @When("I check, if quality alert has been received") public void iCanSeeQualityAlertWasReceived() { System.out.println("searching for notificationDescription: " + notificationDescription); - final QualityNotificationResponse notification = await() + final NotificationResponse notification = await() .atMost(Duration.FIVE_MINUTES) .pollInterval(1, TimeUnit.SECONDS) .until(() -> { - final List result = restProvider.getReceivedNotifications(); - result.stream().map(QualityNotificationResponse::getDescription).forEach(System.out::println); + final List result = restProvider.getReceivedNotifications(); + result.stream().map(NotificationResponse::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(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACKNOWLEDGED, ""); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateNotificationStatusRequest.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(getNotificationIdBasedOnEnv(), UpdateQualityNotificationStatusRequest.ACCEPTED, reason); + restProvider.updateNotification(getNotificationIdBasedOnEnv(), UpdateNotificationStatusRequest.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 20265f9c10..fbcd3019b1 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; -import qualitynotification.base.request.QualityNotificationTypeRequest; +import notification.request.NotificationTypeRequest; public enum NotificationTypeEnum { ALERT, INVESTIGATION; - public QualityNotificationTypeRequest toRequest() { - return QualityNotificationTypeRequest.fromValue(this.name()); + public NotificationTypeRequest toRequest() { + return NotificationTypeRequest.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 f346f205bb..60174ed25a 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 @@ -36,12 +36,12 @@ 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 qualitynotification.base.request.QualityNotificationSeverityRequest; -import qualitynotification.base.request.StartQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationRequest; -import qualitynotification.base.request.UpdateQualityNotificationStatusRequest; -import qualitynotification.base.response.QualityNotificationIdResponse; -import qualitynotification.base.response.QualityNotificationResponse; +import notification.request.NotificationSeverityRequest; +import notification.request.StartNotificationRequest; +import notification.request.UpdateNotificationRequest; +import notification.request.UpdateNotificationStatusRequest; +import notification.response.NotificationIdResponse; +import notification.response.NotificationResponse; import java.time.Instant; import java.util.List; @@ -91,19 +91,19 @@ public void loginToEnvironment(TraceXEnvironmentEnum environment) { System.out.println(host); } - public QualityNotificationIdResponse createNotification( + public NotificationIdResponse createNotification( List partIds, String description, Instant targetDate, String severity, String receiverBpn, NotificationTypeEnum notificationType) { - final StartQualityNotificationRequest requestBody = StartQualityNotificationRequest.builder() + final StartNotificationRequest requestBody = StartNotificationRequest.builder() .partIds(partIds) .isAsBuilt(true) .description(description) .targetDate(targetDate) - .severity(QualityNotificationSeverityRequest.fromValue(severity)) + .severity(NotificationSeverityRequest.fromValue(severity)) .type(notificationType.toRequest()) .receiverBpn(receiverBpn) .build(); @@ -116,7 +116,7 @@ public QualityNotificationIdResponse createNotification( .then() .statusCode(HttpStatus.SC_CREATED) .extract() - .as(QualityNotificationIdResponse.class); + .as(NotificationIdResponse.class); } @@ -184,8 +184,8 @@ public void closeNotification(final Long notificationId) { } public void updateNotification(final Long notificationId, - UpdateQualityNotificationStatusRequest status, String reason) { - UpdateQualityNotificationRequest requestBody = UpdateQualityNotificationRequest.builder() + UpdateNotificationStatusRequest status, String reason) { + UpdateNotificationRequest requestBody = UpdateNotificationRequest.builder() .status(status) .reason(reason) .build(); @@ -216,7 +216,7 @@ public void updateNotification(final Long notificationId, } - public List getReceivedNotifications() { + public List getReceivedNotifications() { return given().spec(getRequestSpecification()) .contentType(ContentType.JSON) @@ -236,10 +236,10 @@ public List getReceivedNotifications() { .statusCode(HttpStatus.SC_OK) .extract() .body() - .jsonPath().getList("content", QualityNotificationResponse.class); + .jsonPath().getList("content", NotificationResponse.class); } - public QualityNotificationResponse getNotification(Long investigationId) { + public NotificationResponse getNotification(Long investigationId) { return given().spec(getRequestSpecification()) .contentType(ContentType.JSON) .when() @@ -249,7 +249,7 @@ public QualityNotificationResponse getNotification(Long investigationId) { .log() .body() .extract() - .body().as(QualityNotificationResponse.class); + .body().as(NotificationResponse.class); } private RequestSpecification getRequestSpecification() { diff --git a/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/validator/NotificationValidator.java b/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/validator/NotificationValidator.java index 83ac5f9681..4503c75cbe 100644 --- a/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/validator/NotificationValidator.java +++ b/tx-cucumber-tests/src/test/java/org/eclipse/tractusx/traceability/test/validator/NotificationValidator.java @@ -20,7 +20,7 @@ package org.eclipse.tractusx.traceability.test.validator; import lombok.Getter; -import qualitynotification.base.response.QualityNotificationResponse; +import notification.response.NotificationResponse; import java.util.Arrays; @@ -44,7 +44,7 @@ public class NotificationValidator { private final static String UNSUPPORTED_VALIDATION_MESSAGE = "Test validation for following fields %s is not supported currently supported fields are %s. Request developers to implement missing validation :)"; - public static void assertHasFields(QualityNotificationResponse notification, Map fieldsToCheck) { + public static void assertHasFields(NotificationResponse notification, Map fieldsToCheck) { checkIfMapHasSupportedValidationRequest(fieldsToCheck); if (fieldsToCheck.containsKey(STATUS.getFieldName())) { diff --git a/tx-models/src/main/java/qualitynotification/base/request/CloseQualityNotificationRequest.java b/tx-models/src/main/java/notification/request/CloseNotificationRequest.java similarity index 93% rename from tx-models/src/main/java/qualitynotification/base/request/CloseQualityNotificationRequest.java rename to tx-models/src/main/java/notification/request/CloseNotificationRequest.java index 2d24398bc0..c51857e304 100644 --- a/tx-models/src/main/java/qualitynotification/base/request/CloseQualityNotificationRequest.java +++ b/tx-models/src/main/java/notification/request/CloseNotificationRequest.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.request; +package notification.request; import io.swagger.v3.oas.annotations.media.Schema; @@ -28,7 +28,6 @@ import lombok.Builder; import lombok.Data; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -40,7 +39,7 @@ @Data @RequiredArgsConstructor @AllArgsConstructor -public class CloseQualityNotificationRequest { +public class CloseNotificationRequest { @Schema(example = "The reason.", minLength = 15, maxLength = 1000) @Size(min = 15, max = 1000, message = "Close reason should have at least 15 characters and at most 1000 characters") private String reason; diff --git a/tx-models/src/main/java/qualitynotification/base/request/QualityNotificationSeverityRequest.java b/tx-models/src/main/java/notification/request/NotificationSeverityRequest.java similarity index 71% rename from tx-models/src/main/java/qualitynotification/base/request/QualityNotificationSeverityRequest.java rename to tx-models/src/main/java/notification/request/NotificationSeverityRequest.java index 3668d6ee7f..ff6fc77cd8 100644 --- a/tx-models/src/main/java/qualitynotification/base/request/QualityNotificationSeverityRequest.java +++ b/tx-models/src/main/java/notification/request/NotificationSeverityRequest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.request; +package notification.request; import com.fasterxml.jackson.annotation.JsonCreator; @@ -29,7 +29,7 @@ import java.util.stream.Stream; @ApiModel(description = "Describes the criticality of a notification") -public enum QualityNotificationSeverityRequest { +public enum NotificationSeverityRequest { MINOR("MINOR"), MAJOR("MAJOR"), CRITICAL("CRITICAL"), @@ -37,22 +37,22 @@ public enum QualityNotificationSeverityRequest { final String realName; - QualityNotificationSeverityRequest(final String realName) { + NotificationSeverityRequest(final String realName) { this.realName = realName; } @JsonCreator - public static QualityNotificationSeverityRequest fromValue(final String value) { - return Stream.of(QualityNotificationSeverityRequest.values()) + public static NotificationSeverityRequest fromValue(final String value) { + return Stream.of(NotificationSeverityRequest.values()) .filter(severity -> severity.getRealName().equals(value)) .findFirst() - .orElseThrow(() -> new NoSuchElementException("Unsupported QualityNotificationSeverityRequest: " + value - + ". Must be one of: " + supportedQualityNotificationSeverityRequest())); + .orElseThrow(() -> new NoSuchElementException("Unsupported NotificationSeverityRequest: " + value + + ". Must be one of: " + supportedNotificationSeverityRequest())); } - private static String supportedQualityNotificationSeverityRequest() { - return Stream.of(QualityNotificationSeverityRequest.values()) - .map(QualityNotificationSeverityRequest::getRealName) + private static String supportedNotificationSeverityRequest() { + return Stream.of(NotificationSeverityRequest.values()) + .map(NotificationSeverityRequest::getRealName) .collect(Collectors.joining(", ")); } diff --git a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationSideResponse.java b/tx-models/src/main/java/notification/request/NotificationSideParamRequest.java similarity index 92% rename from tx-models/src/main/java/qualitynotification/base/response/QualityNotificationSideResponse.java rename to tx-models/src/main/java/notification/request/NotificationSideParamRequest.java index f2f2551b86..48e921f079 100644 --- a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationSideResponse.java +++ b/tx-models/src/main/java/notification/request/NotificationSideParamRequest.java @@ -16,12 +16,13 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.response; + +package notification.request; import io.swagger.annotations.ApiModel; @ApiModel(description = "Describes the side of quality notification") -public enum QualityNotificationSideResponse { +public enum NotificationSideParamRequest { SENDER, RECEIVER } diff --git a/tx-models/src/main/java/qualitynotification/base/request/QualityNotificationStatusRequest.java b/tx-models/src/main/java/notification/request/NotificationStatusRequest.java similarity index 91% rename from tx-models/src/main/java/qualitynotification/base/request/QualityNotificationStatusRequest.java rename to tx-models/src/main/java/notification/request/NotificationStatusRequest.java index 2d8a0a098d..f4e6076149 100644 --- a/tx-models/src/main/java/qualitynotification/base/request/QualityNotificationStatusRequest.java +++ b/tx-models/src/main/java/notification/request/NotificationStatusRequest.java @@ -16,13 +16,11 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.request; +package notification.request; import io.swagger.annotations.ApiModel; @ApiModel(description = "Describes status for closed action") -public enum QualityNotificationStatusRequest { +public enum NotificationStatusRequest { CLOSED - - } diff --git a/tx-models/src/main/java/qualitynotification/base/request/QualityNotificationTypeRequest.java b/tx-models/src/main/java/notification/request/NotificationTypeRequest.java similarity index 81% rename from tx-models/src/main/java/qualitynotification/base/request/QualityNotificationTypeRequest.java rename to tx-models/src/main/java/notification/request/NotificationTypeRequest.java index 0f1c916f26..57bcdb8850 100644 --- a/tx-models/src/main/java/qualitynotification/base/request/QualityNotificationTypeRequest.java +++ b/tx-models/src/main/java/notification/request/NotificationTypeRequest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.request; +package notification.request; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; @@ -28,19 +28,19 @@ import java.util.stream.Stream; @ApiModel(description = "Describes the type of a notification") -public enum QualityNotificationTypeRequest { +public enum NotificationTypeRequest { ALERT("ALERT"), INVESTIGATION("INVESTIGATION"); final String realName; - QualityNotificationTypeRequest(final String realName) { + NotificationTypeRequest(final String realName) { this.realName = realName; } @JsonCreator - public static QualityNotificationTypeRequest fromValue(final String value) { - return Stream.of(QualityNotificationTypeRequest.values()) + public static NotificationTypeRequest fromValue(final String value) { + return Stream.of(NotificationTypeRequest.values()) .filter(severity -> severity.getRealName().equals(value)) .findFirst() .orElseThrow(() -> new NoSuchElementException("Unsupported QualityNotificationTypeRequest: " + value @@ -48,8 +48,8 @@ public static QualityNotificationTypeRequest fromValue(final String value) { } private static String supportedQualityNotificationTypeRequest() { - return Stream.of(QualityNotificationSeverityRequest.values()) - .map(QualityNotificationSeverityRequest::getRealName) + return Stream.of(NotificationSeverityRequest.values()) + .map(NotificationSeverityRequest::getRealName) .collect(Collectors.joining(", ")); } diff --git a/tx-models/src/main/java/qualitynotification/base/request/StartQualityNotificationRequest.java b/tx-models/src/main/java/notification/request/StartNotificationRequest.java similarity index 92% rename from tx-models/src/main/java/qualitynotification/base/request/StartQualityNotificationRequest.java rename to tx-models/src/main/java/notification/request/StartNotificationRequest.java index 898af3337b..2bf7190f94 100644 --- a/tx-models/src/main/java/qualitynotification/base/request/StartQualityNotificationRequest.java +++ b/tx-models/src/main/java/notification/request/StartNotificationRequest.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.request; +package notification.request; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Future; @@ -37,7 +37,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class StartQualityNotificationRequest { +public class StartNotificationRequest { @Size(min = 1, max = 255, message = "Specify at least 1 and at most 50 assetIds") @Schema(example = "title", minLength = 1, maxLength = 255) @@ -56,7 +56,7 @@ public class StartQualityNotificationRequest { private Instant targetDate; @NotNull - private QualityNotificationSeverityRequest severity; + private NotificationSeverityRequest severity; @Schema(example = "true") private boolean isAsBuilt = true; @@ -66,6 +66,6 @@ public class StartQualityNotificationRequest { @Schema(example = "ALERT") @NotNull - private QualityNotificationTypeRequest type; + private NotificationTypeRequest type; } diff --git a/tx-models/src/main/java/qualitynotification/base/request/UpdateQualityNotificationRequest.java b/tx-models/src/main/java/notification/request/UpdateNotificationRequest.java similarity index 90% rename from tx-models/src/main/java/qualitynotification/base/request/UpdateQualityNotificationRequest.java rename to tx-models/src/main/java/notification/request/UpdateNotificationRequest.java index e990a05ba4..432bc41aa2 100644 --- a/tx-models/src/main/java/qualitynotification/base/request/UpdateQualityNotificationRequest.java +++ b/tx-models/src/main/java/notification/request/UpdateNotificationRequest.java @@ -19,7 +19,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.request; +package notification.request; import io.swagger.v3.oas.annotations.media.Schema; @@ -33,9 +33,9 @@ @Builder @AllArgsConstructor @RequiredArgsConstructor -public class UpdateQualityNotificationRequest { +public class UpdateNotificationRequest { @NotNull(message = "status must be present") - private UpdateQualityNotificationStatusRequest status; + private UpdateNotificationStatusRequest status; @Schema(example = "The reason.") private String reason; } diff --git a/tx-models/src/main/java/qualitynotification/base/request/UpdateQualityNotificationStatusRequest.java b/tx-models/src/main/java/notification/request/UpdateNotificationStatusRequest.java similarity index 81% rename from tx-models/src/main/java/qualitynotification/base/request/UpdateQualityNotificationStatusRequest.java rename to tx-models/src/main/java/notification/request/UpdateNotificationStatusRequest.java index c14c664db4..12f2d2331b 100644 --- a/tx-models/src/main/java/qualitynotification/base/request/UpdateQualityNotificationStatusRequest.java +++ b/tx-models/src/main/java/notification/request/UpdateNotificationStatusRequest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.request; +package notification.request; import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.v3.oas.annotations.media.Schema; @@ -27,15 +27,15 @@ import java.util.stream.Stream; @Schema(description = "The UpdateInvestigationStatus") -public enum UpdateQualityNotificationStatusRequest { +public enum UpdateNotificationStatusRequest { ACKNOWLEDGED, ACCEPTED, DECLINED; @JsonCreator - public static UpdateQualityNotificationStatusRequest fromValue(final String value) { - return Stream.of(UpdateQualityNotificationStatusRequest.values()) + public static UpdateNotificationStatusRequest fromValue(final String value) { + return Stream.of(UpdateNotificationStatusRequest.values()) .filter(updateInvestigationStatus -> updateInvestigationStatus.name().equals(value)) .findFirst() .orElseThrow(() -> new NoSuchElementException("Unsupported UpdateInvestigationStatus: " + value @@ -43,7 +43,7 @@ public static UpdateQualityNotificationStatusRequest fromValue(final String valu } private static String supportedUpdateInvestigationStatus() { - return Stream.of(UpdateQualityNotificationStatusRequest.values()).map(Enum::name).collect(Collectors.joining(", ")); + return Stream.of(UpdateNotificationStatusRequest.values()).map(Enum::name).collect(Collectors.joining(", ")); } diff --git a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationIdResponse.java b/tx-models/src/main/java/notification/response/NotificationIdResponse.java similarity index 92% rename from tx-models/src/main/java/qualitynotification/base/response/QualityNotificationIdResponse.java rename to tx-models/src/main/java/notification/response/NotificationIdResponse.java index 314f340ab1..e64f79971c 100644 --- a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationIdResponse.java +++ b/tx-models/src/main/java/notification/response/NotificationIdResponse.java @@ -19,11 +19,11 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.response; +package notification.response; import io.swagger.v3.oas.annotations.media.Schema; -public record QualityNotificationIdResponse( +public record NotificationIdResponse( @Schema(example = "1") Long id ) { diff --git a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationMessageResponse.java b/tx-models/src/main/java/notification/response/NotificationMessageResponse.java similarity index 90% rename from tx-models/src/main/java/qualitynotification/base/response/QualityNotificationMessageResponse.java rename to tx-models/src/main/java/notification/response/NotificationMessageResponse.java index 02b360c9e2..8d0349e7e7 100644 --- a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationMessageResponse.java +++ b/tx-models/src/main/java/notification/response/NotificationMessageResponse.java @@ -16,7 +16,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.response; +package notification.response; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.persistence.EnumType; @@ -33,7 +33,7 @@ @Builder @AllArgsConstructor @RequiredArgsConstructor -public class QualityNotificationMessageResponse { +public class NotificationMessageResponse { private String id; private String createdBy; @@ -44,13 +44,13 @@ public class QualityNotificationMessageResponse { private String notificationReferenceId; private Instant targetDate; @Enumerated(EnumType.STRING) - private QualityNotificationSeverityResponse severity; + private NotificationSeverityResponse severity; private String edcNotificationId; private LocalDateTime created; private LocalDateTime updated; private String messageId; @Enumerated(EnumType.STRING) - private QualityNotificationStatusResponse status; + private NotificationStatusResponse status; @Schema(example = "EDC not reachable", maxLength = 255) @Size(max = 255) private String errorMessage; diff --git a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationReasonResponse.java b/tx-models/src/main/java/notification/response/NotificationReasonResponse.java similarity index 94% rename from tx-models/src/main/java/qualitynotification/base/response/QualityNotificationReasonResponse.java rename to tx-models/src/main/java/notification/response/NotificationReasonResponse.java index 53abc18109..c1fc2a6e3b 100644 --- a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationReasonResponse.java +++ b/tx-models/src/main/java/notification/response/NotificationReasonResponse.java @@ -19,14 +19,14 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.response; +package notification.response; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Size; -public record QualityNotificationReasonResponse( +public record NotificationReasonResponse( @Schema(example = "description of closing reason", maxLength = 1000) @Size(max = 1000) String close, diff --git a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationResponse.java b/tx-models/src/main/java/notification/response/NotificationResponse.java similarity index 82% rename from tx-models/src/main/java/qualitynotification/base/response/QualityNotificationResponse.java rename to tx-models/src/main/java/notification/response/NotificationResponse.java index 2d34e7bba2..e4a3ceab87 100644 --- a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationResponse.java +++ b/tx-models/src/main/java/notification/response/NotificationResponse.java @@ -16,7 +16,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.response; +package notification.response; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; @@ -35,7 +35,7 @@ @AllArgsConstructor @RequiredArgsConstructor @ArraySchema(arraySchema = @Schema(description = "Notifications", additionalProperties = Schema.AdditionalPropertiesValue.FALSE), maxItems = Integer.MAX_VALUE) -public class QualityNotificationResponse { +public class NotificationResponse { @Schema(example = "66", maxLength = 255) @Size(max = 255) @@ -47,7 +47,7 @@ public class QualityNotificationResponse { @Schema(example = "CREATED", maxLength = 255) @Size(max = 255) - private QualityNotificationStatusResponse status; + private NotificationStatusResponse status; @Schema(example = "DescriptionText", maxLength = 1000) @Size(max = 1000) @@ -72,9 +72,9 @@ public class QualityNotificationResponse { @Schema(example = "SENDER", maxLength = 255) @Size(max = 255) - private QualityNotificationSideResponse channel; + private NotificationSideResponse channel; - private QualityNotificationReasonResponse reason; + private NotificationReasonResponse reason; @Schema(example = "BPNL00000003AYRE", maxLength = 255) @Size(max = 255) @@ -86,21 +86,21 @@ public class QualityNotificationResponse { @Schema(example = "MINOR", maxLength = 255) @Size(max = 255) - private QualityNotificationSeverityResponse severity; + private NotificationSeverityResponse severity; @Schema(example = "ALERT", maxLength = 50) @Size(max = 50) - private QualityNotificationTypeResponse type; + private NotificationTypeResponse type; @Schema(example = "2099-02-21T21:27:10.734950Z", maxLength = 50) @Size(max = 50) private String targetDate; - private List messages; + private List messages; - public Optional latestNotification() { - return messages.stream().max(Comparator.comparing(QualityNotificationMessageResponse::getCreated)).stream().findFirst(); + public Optional latestNotification() { + return messages.stream().max(Comparator.comparing(NotificationMessageResponse::getCreated)).stream().findFirst(); } } diff --git a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationSeverityResponse.java b/tx-models/src/main/java/notification/response/NotificationSeverityResponse.java similarity index 79% rename from tx-models/src/main/java/qualitynotification/base/response/QualityNotificationSeverityResponse.java rename to tx-models/src/main/java/notification/response/NotificationSeverityResponse.java index 0e8f8057d9..aadcf28801 100644 --- a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationSeverityResponse.java +++ b/tx-models/src/main/java/notification/response/NotificationSeverityResponse.java @@ -16,33 +16,33 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.response; +package notification.response; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; @ApiModel(description = "Describes the criticality of a notification") -public enum QualityNotificationSeverityResponse { +public enum NotificationSeverityResponse { MINOR("MINOR"), MAJOR("MAJOR"), CRITICAL("CRITICAL"), LIFE_THREATENING("LIFE-THREATENING"); private final String realName; - QualityNotificationSeverityResponse(String realName) { + NotificationSeverityResponse(String realName) { this.realName = realName; } @JsonCreator - public static QualityNotificationSeverityResponse fromString(String str) { - for (QualityNotificationSeverityResponse s : QualityNotificationSeverityResponse.values()) { + public static NotificationSeverityResponse fromString(String str) { + for (NotificationSeverityResponse s : NotificationSeverityResponse.values()) { if (s.getRealName().equalsIgnoreCase(str)) { return s; } } - throw new IllegalArgumentException("No enum constant " + QualityNotificationSeverityResponse.class.getCanonicalName() + "." + str); + throw new IllegalArgumentException("No enum constant " + NotificationSeverityResponse.class.getCanonicalName() + "." + str); } @JsonValue diff --git a/tx-models/src/main/java/qualitynotification/base/request/QualityNotificationSideParamRequest.java b/tx-models/src/main/java/notification/response/NotificationSideResponse.java similarity index 85% rename from tx-models/src/main/java/qualitynotification/base/request/QualityNotificationSideParamRequest.java rename to tx-models/src/main/java/notification/response/NotificationSideResponse.java index aac02db82a..2a1379797c 100644 --- a/tx-models/src/main/java/qualitynotification/base/request/QualityNotificationSideParamRequest.java +++ b/tx-models/src/main/java/notification/response/NotificationSideResponse.java @@ -16,13 +16,12 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ - -package qualitynotification.base.request; +package notification.response; import io.swagger.annotations.ApiModel; -@ApiModel(description = "Describes the side of quality notification") -public enum QualityNotificationSideParamRequest { +@ApiModel(description = "Describes the side of notification") +public enum NotificationSideResponse { SENDER, RECEIVER } diff --git a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationStatusResponse.java b/tx-models/src/main/java/notification/response/NotificationStatusResponse.java similarity index 51% rename from tx-models/src/main/java/qualitynotification/base/response/QualityNotificationStatusResponse.java rename to tx-models/src/main/java/notification/response/NotificationStatusResponse.java index 8fd9119e7b..7e074790fd 100644 --- a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationStatusResponse.java +++ b/tx-models/src/main/java/notification/response/NotificationStatusResponse.java @@ -16,7 +16,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.response; +package notification.response; import io.swagger.annotations.ApiModel; import java.util.Arrays; import java.util.Map; @@ -26,20 +26,20 @@ import static java.util.Collections.emptySet; import static java.util.Set.of; -@ApiModel(description = "Describes status of quality notification") -public enum QualityNotificationStatusResponse { - CREATED(QualityNotificationSideResponse.SENDER, emptySet()), - SENT(QualityNotificationSideResponse.SENDER, Set.of(QualityNotificationSideResponse.SENDER)), - RECEIVED(QualityNotificationSideResponse.RECEIVER, emptySet()), - ACKNOWLEDGED(QualityNotificationSideResponse.RECEIVER, Set.of(QualityNotificationSideResponse.RECEIVER, QualityNotificationSideResponse.SENDER)), - ACCEPTED(QualityNotificationSideResponse.RECEIVER, Set.of(QualityNotificationSideResponse.RECEIVER)), - DECLINED(QualityNotificationSideResponse.RECEIVER, Set.of(QualityNotificationSideResponse.RECEIVER)), - CANCELED(QualityNotificationSideResponse.SENDER, Set.of(QualityNotificationSideResponse.SENDER)), - CLOSED(QualityNotificationSideResponse.SENDER, of(QualityNotificationSideResponse.SENDER, QualityNotificationSideResponse.RECEIVER)); +@ApiModel(description = "Describes status of notification") +public enum NotificationStatusResponse { + CREATED(NotificationSideResponse.SENDER, emptySet()), + SENT(NotificationSideResponse.SENDER, Set.of(NotificationSideResponse.SENDER)), + RECEIVED(NotificationSideResponse.RECEIVER, emptySet()), + ACKNOWLEDGED(NotificationSideResponse.RECEIVER, Set.of(NotificationSideResponse.RECEIVER, NotificationSideResponse.SENDER)), + ACCEPTED(NotificationSideResponse.RECEIVER, Set.of(NotificationSideResponse.RECEIVER)), + DECLINED(NotificationSideResponse.RECEIVER, Set.of(NotificationSideResponse.RECEIVER)), + CANCELED(NotificationSideResponse.SENDER, Set.of(NotificationSideResponse.SENDER)), + CLOSED(NotificationSideResponse.SENDER, of(NotificationSideResponse.SENDER, NotificationSideResponse.RECEIVER)); - private static final Map> STATE_MACHINE; - private static final Set NO_TRANSITION_ALLOWED = emptySet(); - private static final Map MAPPINGS; + private static final Map> STATE_MACHINE; + private static final Set NO_TRANSITION_ALLOWED = emptySet(); + private static final Map MAPPINGS; static { STATE_MACHINE = Map.of( @@ -53,19 +53,19 @@ DECLINED, of(CLOSED), CANCELED, NO_TRANSITION_ALLOWED ); - MAPPINGS = Arrays.stream(QualityNotificationStatusResponse.values()) + MAPPINGS = Arrays.stream(NotificationStatusResponse.values()) .collect(Collectors.toMap(Enum::name, qualityNotificationStatus -> qualityNotificationStatus)); } - private final QualityNotificationSideResponse qualityNotificationSide; - private final Set allowedTransitionFromSide; + private final NotificationSideResponse qualityNotificationSide; + private final Set allowedTransitionFromSide; - QualityNotificationStatusResponse(QualityNotificationSideResponse qualityNotificationSide, Set allowedTransitionFromSide) { + NotificationStatusResponse(NotificationSideResponse qualityNotificationSide, Set allowedTransitionFromSide) { this.qualityNotificationSide = qualityNotificationSide; this.allowedTransitionFromSide = allowedTransitionFromSide; } - public static QualityNotificationStatusResponse fromStringValue(String value) { + public static NotificationStatusResponse fromStringValue(String value) { return MAPPINGS.get(value); } } diff --git a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationTypeResponse.java b/tx-models/src/main/java/notification/response/NotificationTypeResponse.java similarity index 92% rename from tx-models/src/main/java/qualitynotification/base/response/QualityNotificationTypeResponse.java rename to tx-models/src/main/java/notification/response/NotificationTypeResponse.java index a8a229e8a8..b223ca4ed3 100644 --- a/tx-models/src/main/java/qualitynotification/base/response/QualityNotificationTypeResponse.java +++ b/tx-models/src/main/java/notification/response/NotificationTypeResponse.java @@ -17,12 +17,12 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -package qualitynotification.base.response; +package notification.response; import io.swagger.annotations.ApiModel; @ApiModel(description = "Describes the type of a notification") -public enum QualityNotificationTypeResponse { +public enum NotificationTypeResponse { ALERT, INVESTIGATION } diff --git a/tx-models/src/main/java/qualitynotification/investigation/response/InvestigationResponse.java b/tx-models/src/main/java/qualitynotification/investigation/response/InvestigationResponse.java deleted file mode 100644 index c9538083a4..0000000000 --- a/tx-models/src/main/java/qualitynotification/investigation/response/InvestigationResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://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. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -package qualitynotification.investigation.response; - -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.experimental.SuperBuilder; -import qualitynotification.base.response.QualityNotificationResponse; - - -@SuperBuilder -@ArraySchema(arraySchema = @Schema(description = "Investigations", additionalProperties = Schema.AdditionalPropertiesValue.FALSE), minItems = Integer.MIN_VALUE, maxItems = Integer.MAX_VALUE) -public class InvestigationResponse extends QualityNotificationResponse { - -}