Skip to content

Commit

Permalink
added datatype validation for order deleting (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuelianhan007 authored Dec 17, 2024
1 parent ea4beb2 commit d514e92
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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



Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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



Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d514e92

Please sign in to comment.