From daf8243dd052a382e6dd7b84169f9f9b7408d510 Mon Sep 17 00:00:00 2001 From: xuelianhan007 Date: Tue, 17 Dec 2024 17:18:43 +0800 Subject: [PATCH] added datatype validation for order deleting --- .../api-target-mapper.order.eline.delete.yaml | 12 +++++++++++- .../api-target-mapper.order.uni.delete.yaml | 18 ++++++++++++++---- .../test/resources/mock/apis/api.order.yaml | 6 +++--- .../mapping.matrix.address.validation.yaml | 6 +++--- .../mapping.matrix.order.eline.delete.yaml | 12 ++++++------ .../mapping.matrix.order.uni.delete.yaml | 12 ++++++------ .../gateway/runner/DataTypeChecker.java | 7 ++++--- .../api-target-mapper.order.eline.delete.yaml | 4 +++- .../api-target-mapper.order.uni.delete.yaml | 4 +++- .../mapping.matrix.address.validation.yaml | 6 +++--- .../mapping.matrix.order.eline.delete.yaml | 12 ++++++------ .../mapping.matrix.order.uni.delete.yaml | 12 ++++++------ .../src/main/resources/mef-sonata/product.yaml | 2 +- .../template-upgrade/release.1.6.4.yaml | 15 +++++++++++++++ 14 files changed, 84 insertions(+), 44 deletions(-) create mode 100644 kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.6.4.yaml diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.eline.delete.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.eline.delete.yaml index 6ce4c986..9af506de 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.eline.delete.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.eline.delete.yaml @@ -32,9 +32,19 @@ spec: description: "" source: "@{{productOrderItem[*].product.id}}" sourceLocation: "BODY" - target: "" + sourceType: discreteStr + target: "@{{connectionId}}" targetLocation: "" requiredMapping: false + - name: mapper.order.uni.delete.productOffering.id + title: "id of a Product Offering" + description: "" + source: "@{{productOrderItem[0].product.productOffering.id}}" + sourceLocation: "BODY" + sourceType: discreteStr + target: "ACCESS_E_LINE" + targetLocation: "" + requiredMapping: true response: - name: mapper.order.eline.delete.state title: Order State Mapping diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.uni.delete.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.uni.delete.yaml index fdd0d670..0d37019a 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.uni.delete.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.uni.delete.yaml @@ -23,17 +23,27 @@ spec: description: "" source: "@{{buyerId}}" sourceLocation: "QUERY" - target: "" - targetLocation: "" + target: "@{{companyName}}" + targetLocation: PATH requiredMapping: false - name: mapper.order.uni.delete.productId title: "The unique identifier of an in-service Product that is the ordering subject" description: "" source: "@{{productOrderItem[*].product.id}}" sourceLocation: "BODY" - target: "" - targetLocation: "" + sourceType: discreteStr + target: "@{{portId}}" + targetLocation: PATH requiredMapping: false + - name: mapper.order.uni.delete.productOffering.id + title: "id of a Product Offering" + description: "" + source: "@{{productOrderItem[0].product.productOffering.id}}" + sourceLocation: "BODY" + sourceType: discreteStr + target: "UNI" + targetLocation: "" + requiredMapping: true response: - name: mapper.order.uni.delete.state title: Order State Mapping diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/apis/api.order.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/apis/api.order.yaml index b54a0208..819c4057 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/apis/api.order.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/apis/api.order.yaml @@ -315,6 +315,9 @@ links: - targetAssetKey: mef.sonata.api.matrix.order.eline.add relationship: implementation.matrix group: mef.sonata.api-target.order.eline.add + - targetAssetKey: mef.sonata.api.matrix.order.uni.delete + relationship: implementation.matrix + group: mef.sonata.api-target.order.uni.delete - targetAssetKey: mef.sonata.api-target-mapper.order.uni.read relationship: implementation.target-mapper group: mef.sonata.api-target.order.uni.read @@ -330,9 +333,6 @@ links: - targetAssetKey: mef.sonata.api-target-mapper.order.uni.delete relationship: implementation.target-mapper group: mef.sonata.api-target.order.uni.delete - - targetAssetKey: mef.sonata.api.matrix.order.uni.delete - relationship: implementation.matrix - group: mef.sonata.api-target.order.uni.delete - targetAssetKey: mef.sonata.api-target-mapper.order.eline.delete relationship: implementation.target-mapper group: mef.sonata.api-target.order.eline.delete diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.address.validation.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.address.validation.yaml index 74509eaa..6c23b28d 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.address.validation.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.address.validation.yaml @@ -23,17 +23,17 @@ spec: path: "$.body.submittedGeographicAddress.['country']" expectType: EXPECTED_TRUE value: "${param}" - code: 422 + expectedValueType: String - name: address_submittedGeographicAddress_city path: "$.body.submittedGeographicAddress.['city']" expectType: EXPECTED_TRUE value: "${param}" - code: 422 + expectedValueType: String - name: address_submittedGeographicAddress_streetName path: "$.body.submittedGeographicAddress.['streetName']" expectType: EXPECTED_TRUE value: "${param}" - code: 422 + expectedValueType: String diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.eline.delete.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.eline.delete.yaml index b81b7775..5ae326da 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.eline.delete.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.eline.delete.yaml @@ -22,24 +22,24 @@ spec: path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.emailAddress} - errorMsg: "relatedContactInformation.emailAddress should exist in request" + expectedValueType: String - name: relatedContactInformation_name path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.name} - errorMsg: "relatedContactInformation.name should exist in request" + expectedValueType: String - name: relatedContactInformation_number path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.number} - errorMsg: "relatedContactInformation.number should exist in request" + expectedValueType: String - name: relatedContactInformation_role path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.role} - errorMsg: "relatedContactInformation.role should exist in request" + expectedValueType: String - name: productOrderItem_id path: "$.body.productOrderItem[0].id" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true - errorMsg: "productOrderItem.id should exist in request" + code: 422 \ No newline at end of file diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.uni.delete.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.uni.delete.yaml index c57218d4..ce633bc3 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.uni.delete.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.uni.delete.yaml @@ -22,24 +22,24 @@ spec: path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.emailAddress} - errorMsg: "relatedContactInformation.emailAddress should exist in request" + expectedValueType: String - name: relatedContactInformation_name path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.name} - errorMsg: "relatedContactInformation.name should exist in request" + expectedValueType: String - name: relatedContactInformation_number path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.number} - errorMsg: "relatedContactInformation.number should exist in request" + expectedValueType: String - name: relatedContactInformation_role path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.role} - errorMsg: "relatedContactInformation.role should exist in request" + expectedValueType: String - name: productOrderItem_id path: "$.body.productOrderItem[0].id" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true - errorMsg: "productOrderItem.id should exist in request" + code: 422 diff --git a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/DataTypeChecker.java b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/DataTypeChecker.java index 99649af4..bd6bbeed 100644 --- a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/DataTypeChecker.java +++ b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/DataTypeChecker.java @@ -19,6 +19,7 @@ public interface DataTypeChecker { String API_CASE_NOT_SUPPORTED = "api use case is not supported: %s"; String EXPECT_INT_MSG = "invalidValue, can not process @{{%s}} = %s, %s found, %s expected"; + String EXPECT_INF_MSG = "invalidFormat, can not process @{{%s}} = %s, %s found, %s expected"; String PARAM_NOT_EXIST_MSG = "missingProperty, the parameter @{{%s}} does not exist in the request"; String SHOULD_BE_MSG = "invalidValue, can not process @{{%s}} = %s, value should be %s"; @@ -154,9 +155,9 @@ default void validateDiscreteString(Object evaluateValue, String paramName, Stri if (MappingTypeEnum.DISCRETE_STR.getKind().equals(sourceType)) { Class dataType = whichDataTypeClass(evaluateValue); if (!String.class.equals(dataType)) { - throw KrakenException.unProcessableEntityInvalidValue( + throw KrakenException.unProcessableEntityInvalidFormat( String.format( - EXPECT_INT_MSG, + EXPECT_INF_MSG, paramName, evaluateValue, (dataType == null ? null : dataType.getSimpleName()), @@ -184,7 +185,7 @@ default boolean checkExpectDataType(PathCheck pathCheck, Object variable) { throwException( pathCheck, String.format( - EXPECT_INT_MSG, checkingPath, variable, dataType, pathCheck.expectedValueType())); + EXPECT_INF_MSG, checkingPath, variable, dataType, pathCheck.expectedValueType())); } return true; } diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.eline.delete.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.eline.delete.yaml index c9df1f99..7de848d0 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.eline.delete.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.eline.delete.yaml @@ -33,14 +33,16 @@ spec: description: "" source: "@{{productOrderItem[*].product.id}}" sourceLocation: "BODY" + sourceType: discreteStr target: "" targetLocation: "" requiredMapping: true - name: mapper.order.uni.delete.productOffering.id - title: " id of a Product Offering" + title: "id of a Product Offering" description: "" source: "@{{productOrderItem[0].product.productOffering.id}}" sourceLocation: "BODY" + sourceType: discreteStr target: "" targetLocation: "" requiredMapping: true diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.uni.delete.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.uni.delete.yaml index 7d3e2ea5..a066753a 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.uni.delete.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.uni.delete.yaml @@ -32,14 +32,16 @@ spec: description: "" source: "@{{productOrderItem[*].product.id}}" sourceLocation: "BODY" + sourceType: discreteStr target: "" targetLocation: "" requiredMapping: true - name: mapper.order.uni.delete.productOffering.id - title: " id of a Product Offering" + title: "id of a Product Offering" description: "" source: "@{{productOrderItem[0].product.productOffering.id}}" sourceLocation: "BODY" + sourceType: discreteStr target: "" targetLocation: "" requiredMapping: true diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.address.validation.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.address.validation.yaml index 74509eaa..6c23b28d 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.address.validation.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.address.validation.yaml @@ -23,17 +23,17 @@ spec: path: "$.body.submittedGeographicAddress.['country']" expectType: EXPECTED_TRUE value: "${param}" - code: 422 + expectedValueType: String - name: address_submittedGeographicAddress_city path: "$.body.submittedGeographicAddress.['city']" expectType: EXPECTED_TRUE value: "${param}" - code: 422 + expectedValueType: String - name: address_submittedGeographicAddress_streetName path: "$.body.submittedGeographicAddress.['streetName']" expectType: EXPECTED_TRUE value: "${param}" - code: 422 + expectedValueType: String diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.eline.delete.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.eline.delete.yaml index b81b7775..5ae326da 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.eline.delete.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.eline.delete.yaml @@ -22,24 +22,24 @@ spec: path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.emailAddress} - errorMsg: "relatedContactInformation.emailAddress should exist in request" + expectedValueType: String - name: relatedContactInformation_name path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.name} - errorMsg: "relatedContactInformation.name should exist in request" + expectedValueType: String - name: relatedContactInformation_number path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.number} - errorMsg: "relatedContactInformation.number should exist in request" + expectedValueType: String - name: relatedContactInformation_role path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.role} - errorMsg: "relatedContactInformation.role should exist in request" + expectedValueType: String - name: productOrderItem_id path: "$.body.productOrderItem[0].id" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true - errorMsg: "productOrderItem.id should exist in request" + code: 422 \ No newline at end of file diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.uni.delete.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.uni.delete.yaml index c57218d4..ce633bc3 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.uni.delete.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.uni.delete.yaml @@ -22,24 +22,24 @@ spec: path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.emailAddress} - errorMsg: "relatedContactInformation.emailAddress should exist in request" + expectedValueType: String - name: relatedContactInformation_name path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.name} - errorMsg: "relatedContactInformation.name should exist in request" + expectedValueType: String - name: relatedContactInformation_number path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.number} - errorMsg: "relatedContactInformation.number should exist in request" + expectedValueType: String - name: relatedContactInformation_role path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.role} - errorMsg: "relatedContactInformation.role should exist in request" + expectedValueType: String - name: productOrderItem_id path: "$.body.productOrderItem[0].id" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true - errorMsg: "productOrderItem.id should exist in request" + code: 422 diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/product.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/product.yaml index 57812870..986da1b2 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/product.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/product.yaml @@ -103,7 +103,7 @@ spec: - classpath:/mef-sonata/mapping-matrix/mapping.matrix.inventory.eline.read.yaml - classpath:/mef-sonata/mapping-matrix/mapping.matrix.inventory.uni.list.yaml - classpath:/mef-sonata/mapping-matrix/mapping.matrix.inventory.eline.list.yaml - - classpath:/mef-sonata/template-upgrade/release.1.6.3.yaml + - classpath:/mef-sonata/template-upgrade/release.1.6.4.yaml templateUpgradePaths: diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.6.4.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.6.4.yaml new file mode 100644 index 00000000..c6e71bc0 --- /dev/null +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.6.4.yaml @@ -0,0 +1,15 @@ +--- +kind: kraken.product.template-upgrade +apiVersion: v1 +metadata: + key: kraken.product.template-upgrade.1.6.4 + name: V1.6.4 + labels: + productSpec: grace + productVersion: V1.6.4 + publishDate: 2024-12-17 + description: | + Add data type validation for the following use cases: + - UNI order deleting + - Eline order deleting + version: 1 \ No newline at end of file