diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.eline.add.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.eline.add.yaml index 560183a8..37871ac8 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.eline.add.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.eline.add.yaml @@ -21,25 +21,25 @@ spec: request: - name: mapper.order.eline.add.buyerId title: The unique identifier of the organization that is acting as the a Buyer. - source: "@{{buyerId}}" - target: "@{{username}}" description: + source: "@{{buyerId}}" replaceStar: true sourceLocation: QUERY + target: "@{{username}}" targetLocation: PATH customizedField: false requiredMapping: false - name: mapper.order.eline.add.duration title: "order item Term duration" source: "@{{productOrderItem[0].requestedItemTerm.duration.amount}}" - target: "@{{duration}}" sourceLocation: BODY + sourceType: constantNumber + target: "@{{duration}}" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.duration.unit title: "order item Term unit" source: "@{{productOrderItem[0].requestedItemTerm.duration.units}}" - target: "@{{durationUnit}}" sourceType: enum sourceValues: - calendarMonths @@ -49,6 +49,7 @@ spec: - businessDays - businessHours sourceLocation: BODY + target: "@{{durationUnit}}" targetLocation: BODY valueMapping: calendarMonths: m @@ -57,22 +58,38 @@ spec: - name: mapper.order.eline.add.endOfTermAction title: "MEFEndOfTermAction" source: "@{{productOrderItem[0].requestedItemTerm.endOfTermAction}}" - target: "roll" sourceLocation: BODY + sourceType: enum + sourceValues: + - roll + - autoDisconnect + - autoRenew + target: "roll" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.rollInterval.amount title: " quote item Term roll duration" source: "@{{productOrderItem[0].requestedItemTerm.rollInterval.amount}}" - target: "" sourceLocation: BODY + sourceType: constantNumber + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.rollInterval.units title: " quote item Term roll unit" source: "@{{productOrderItem[0].requestedItemTerm.rollInterval.units}}" - target: "" sourceLocation: BODY + sourceType: enum + sourceValues: + - calendarYears + - calendarMonths + - calendarDays + - calendarHours + - calendarMinutes + - businessDays + - businessHours + - businessMinutes + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.bandwidthUnit @@ -82,83 +99,92 @@ spec: sourceValues: - MBPS - GBPS - target: "MBPS" sourceLocation: BODY + target: "MBPS" targetLocation: BODY valueMapping: {} requiredMapping: true - name: mapper.order.eline.add.bandwidth title: "Bandwidth of the ELINE" source: "@{{productOrderItem[0].product.productConfiguration.bandwidth}}" - target: "@{{speed}}" sourceLocation: BODY sourceType: discreteInt sourceValues: - 1000 - 10000 + target: "@{{speed}}" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.name title: "The name of the ELINE" source: "@{{productOrderItem[0].product.productConfiguration.name}}" - target: "@{{name}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{name}}" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.paymentType title: "The payment type of the ELINE" source: "@{{productOrderItem[0].product.productConfiguration.paymentType}}" - target: "@{{paymentType}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{paymentType}}" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.classOfService title: "The class of Service of the Eline" source: "@{{productOrderItem[0].product.productConfiguration.classOfService}}" - target: "@{{classOfService}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{classOfService}}" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.srcUNI title: "source UNI or ENNI id" source: "@{{productOrderItem[0].product.productRelationship[0].id}}" - target: "@{{portId}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{portId}}" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.destUNI title: "destination UNI id" source: "@{{productOrderItem[0].product.productRelationship[1].id}}" - target: "@{{destPortId}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{destPortId}}" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.productOffering.id title: "id of a Product Offering" source: "@{{productOrderItem[0].product.productOffering.id}}" - target: "ACCESS_E_LINE" sourceLocation: BODY + sourceType: discreteStr + target: "ACCESS_E_LINE" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.product.productConfiguration.type - title: "connection type" + title: "customized product type" source: "@{{productOrderItem[0].product.productConfiguration.type}}" - target: "@{{type}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{type}}" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.product.productConfiguration.destUNIMetroId - title: "connection destUNIMetroId" + title: "The metro id of the destination UNI" source: "@{{productOrderItem[0].product.productConfiguration.destUNIMetroId}}" - target: "@{{destMetroId}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{destMetroId}}" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.product.productConfiguration.buyerCompanyId - title: "connection buyerCompanyId" + title: "The Id of buyer Company" source: "@{{productOrderItem[0].product.productConfiguration.buyerCompanyId}}" - target: "@{{destCompany}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{destCompany}}" targetLocation: BODY requiredMapping: false response: diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.uni.add.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.uni.add.yaml index fefd8b85..7861f77f 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.uni.add.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.order.uni.add.yaml @@ -23,12 +23,20 @@ spec: title: >- The unique identifier of the organization that is acting as the a Buyer. - source: '@{{buyerId}}' - target: "@{{companyName}}" description: "" + source: '@{{buyerId}}' sourceLocation: QUERY + target: "@{{companyName}}" targetLocation: PATH requiredMapping: false + - name: mapper.order.uni.add.duration + title: "order item Term duration" + source: "@{{productOrderItem[0].requestedItemTerm.duration.amount}}" + sourceLocation: BODY + sourceType: constantNumber + target: "1" + targetLocation: BODY + requiredMapping: true - name: mapper.order.uni.add.duration.units title: "order item Term unit" source: "@{{productOrderItem[0].requestedItemTerm.duration.units}}" @@ -49,82 +57,89 @@ spec: - name: mapper.order.eline.add.endOfTermAction title: "MEFEndOfTermAction" source: "@{{productOrderItem[0].requestedItemTerm.endOfTermAction}}" - target: "roll" sourceLocation: BODY + sourceType: discreteStr + target: "roll" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.rollInterval.amount title: " quote item Term roll duration" source: "@{{productOrderItem[0].requestedItemTerm.rollInterval.amount}}" - target: "" sourceLocation: BODY + sourceType: constantNumber + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.rollInterval.units title: " quote item Term roll unit" source: "@{{productOrderItem[0].requestedItemTerm.rollInterval.units}}" - target: "" sourceLocation: BODY + sourceType: discreteStr + target: "calendarMonths" targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.place.id title: >- the id of the place where the products' installation must be done. - source: '@{{productOrderItem[0].product.place[0].id}}' - target: '@{{dataCenterFacilityId}}' description: '' + source: '@{{productOrderItem[0].product.place[0].id}}' sourceLocation: BODY + sourceType: discreteStr + target: '@{{dataCenterFacilityId}}' targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.place.name title: the keyName of the place where the products' installation must be done. - source: '@{{productOrderItem[0].product.place[0].keyName}}' - target: '@{{dataCenterFacility}}' description: '' + source: '@{{productOrderItem[0].product.place[0].keyName}}' sourceLocation: BODY + sourceType: discreteStr + target: '@{{dataCenterFacility}}' targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.bandwidthUnit title: "The unit of bandwidth" source: "@{{productOrderItem[0].product.productConfiguration.bandwidthUnit}}" + sourceLocation: BODY sourceType: enum sourceValues: - MBPS - GBPS target: "MBPS" - sourceLocation: BODY targetLocation: BODY requiredMapping: true - name: mapper.order.uni.add.bandwidth title: "Bandwidth of the UNI" source: "@{{productOrderItem[0].product.productConfiguration.bandwidth}}" + sourceLocation: BODY sourceType: discreteInt sourceValues: - 1000 - 10000 target: "@{{speed}}" - sourceLocation: BODY targetLocation: BODY requiredMapping: true - name: mapper.order.uni.add.name title: "The name of the UNI" source: "@{{productOrderItem[0].product.productConfiguration.name}}" - target: "@{{portName}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{portName}}" targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.paymentType title: "The payment type of the UNI" source: "@{{productOrderItem[0].product.productConfiguration.paymentType}}" - target: "@{{paymentType}}" sourceLocation: BODY + sourceType: discreteStr + target: "@{{paymentType}}" targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.productOffering.id title: "id of a Product Offering" source: "@{{productOrderItem[0].product.productOffering.id}}" - target: "UNI" sourceLocation: BODY + target: "UNI" targetLocation: BODY requiredMapping: true response: diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.quote.eline.add.sync.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.quote.eline.add.sync.yaml index a7dbd121..0636415f 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.quote.eline.add.sync.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.quote.eline.add.sync.yaml @@ -94,7 +94,10 @@ spec: - name: mapper.quote.uni.add.sync.productConfiguration.bandwidth source: "@{{quoteItem[0].product.productConfiguration.bandwidth}}" sourceLocation: BODY - sourceType: constantNumber + sourceType: discreteInt + sourceValues: + - 1000 + - 10000 target: "@{{connections[*].bandwidth}}" targetLocation: BODY requiredMapping: true diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.quote.uni.add.sync.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.quote.uni.add.sync.yaml index b7a6d5a5..10f42c95 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.quote.uni.add.sync.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/api-targets-mappers/api-target-mapper.quote.uni.add.sync.yaml @@ -94,7 +94,10 @@ spec: - name: mapper.quote.uni.add.sync.productConfiguration.bandwidth source: "@{{quoteItem[0].product.productConfiguration.bandwidth}}" sourceLocation: BODY - sourceType: constantNumber + sourceType: discreteInt + sourceValues: + - 1000 + - 10000 target: "@{{ports[*].speed}}" targetLocation: BODY requiredMapping: true diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.eline.add.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.eline.add.yaml index abdc5926..42515c1b 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.eline.add.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.eline.add.yaml @@ -22,32 +22,32 @@ 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 - name: productOrderItem_requestedItemTerm_name path: "$.body.productOrderItem[0].requestedItemTerm.name" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true - errorMsg: "requestedItemTerm.name should exist in request" + code: 422 - name: productOrderItem[0].product.productRelationship[0].relationshipType path: "$.body.productOrderItem[0].product.productRelationship[0].relationshipType" expectType: EXPECTED diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.uni.add.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.uni.add.yaml index ae0d6f09..9011c1aa 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.uni.add.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/mapping-matrix/mapping.matrix.order.uni.add.yaml @@ -32,28 +32,28 @@ spec: expectType: EXPECTED_TRUE value: ${param.emailAddress} expectedValueType: String - errorMsg: "missingProperty, @{{relatedContactInformation.emailAddress}} should exist in request" - name: relatedContactInformation_name path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.name} - errorMsg: "missingProperty, @{{relatedContactInformation.name}} should exist in request" + expectedValueType: String - name: relatedContactInformation_number path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.number} - errorMsg: "missingProperty, @{{relatedContactInformation.number}} should exist in request" + expectedValueType: String - name: relatedContactInformation_role path: "$.body.relatedContactInformation[*]" expectType: EXPECTED_TRUE value: ${param.role} - errorMsg: "missingProperty, @{{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: "missingProperty, @{{productOrderItem.id}} should exist in request" + code: 422 - name: productOrderItem_requestedItemTerm_name path: "$.body.productOrderItem[0].requestedItemTerm.name" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true + code: 422 \ No newline at end of file diff --git a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/dto/PathCheck.java b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/dto/PathCheck.java index f5e67bb8..67f8bb14 100644 --- a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/dto/PathCheck.java +++ b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/dto/PathCheck.java @@ -8,4 +8,5 @@ public record PathCheck( ExpectTypeEnum expectType, String value, String errorMsg, - Integer code) {} + Integer code, + String expectedValueType) {} 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 9ccf2876..99649af4 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 @@ -4,6 +4,7 @@ import com.consoleconnect.kraken.operator.core.exception.ErrorResponse; import com.consoleconnect.kraken.operator.core.exception.KrakenException; import com.consoleconnect.kraken.operator.core.model.facet.ComponentAPITargetFacets; +import com.consoleconnect.kraken.operator.core.toolkit.ConstructExpressionUtil; import com.consoleconnect.kraken.operator.gateway.dto.PathCheck; import com.jayway.jsonpath.DocumentContext; import java.util.*; @@ -29,6 +30,7 @@ public interface DataTypeChecker { String SHOULD_BE_INTERVAL = "invalidValue, can not process @{{%s}} = %s, value should be in closed interval[%s, %s]"; String JSON_PATH_READ_ERR = "read json path error!"; + String ARRAY_PARAM_PATTERN = "\\$\\{param\\.([^}]+)\\}"; @Slf4j final class LogHolder {} @@ -163,6 +165,30 @@ default void validateDiscreteString(Object evaluateValue, String paramName, Stri } } + default String rewriteCheckingPath(PathCheck pathCheck) { + String checkingPath = extractCheckingPath(pathCheck.path()); + if (checkingPath.contains("[*]")) { + List params = + ConstructExpressionUtil.extractParam(pathCheck.value(), ARRAY_PARAM_PATTERN); + if (CollectionUtils.isNotEmpty(params)) { + checkingPath = checkingPath + "." + params.get(0); + } + } + return checkingPath; + } + + default boolean checkExpectDataType(PathCheck pathCheck, Object variable) { + String dataType = whichDataType(variable); + if (Objects.isNull(variable) || !pathCheck.expectedValueType().equals(dataType)) { + String checkingPath = rewriteCheckingPath(pathCheck); + throwException( + pathCheck, + String.format( + EXPECT_INT_MSG, checkingPath, variable, dataType, pathCheck.expectedValueType())); + } + return true; + } + default void validateEnumOrDiscreteString( Object evaluateValue, String paramName, List valueList, String sourceType) { validateDiscreteString(evaluateValue, paramName, sourceType); diff --git a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunner.java b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunner.java index b0eae518..06b093d5 100644 --- a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunner.java +++ b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunner.java @@ -192,13 +192,19 @@ public boolean checkExpect(PathCheck pathCheck, Object value) { return true; } case EXPECTED_TRUE -> { + Object obj = null; try { - SpELEngine.evaluateWithoutSuppressException( - pathCheck.value(), Map.of(PARAM_NAME, value), Object.class); - return true; + obj = + SpELEngine.evaluateWithoutSuppressException( + pathCheck.value(), Map.of(PARAM_NAME, value), Object.class); } catch (Exception e) { - throwException(pathCheck, null); + String checkingPath = rewriteCheckingPath(pathCheck); + throwException(pathCheck, String.format(PARAM_NOT_EXIST_MSG, checkingPath)); + } + if (StringUtils.isNotBlank(pathCheck.expectedValueType())) { + return checkExpectDataType(pathCheck, obj); } + return true; } case EXPECTED_STR -> { return checkExpectString(pathCheck, value); diff --git a/kraken-java-sdk/kraken-java-sdk-gateway/src/test/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunnerTest.java b/kraken-java-sdk/kraken-java-sdk-gateway/src/test/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunnerTest.java index 7e1b68b0..2d5ecb81 100644 --- a/kraken-java-sdk/kraken-java-sdk-gateway/src/test/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunnerTest.java +++ b/kraken-java-sdk/kraken-java-sdk-gateway/src/test/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunnerTest.java @@ -201,17 +201,40 @@ private void validateQuoteRequest(String request, String matchedMsg) throws IOEx public static List> buildIllegalPathCheckList() { PathCheck pathCheck1 = - new PathCheck("expect1", "user", ExpectTypeEnum.EXPECTED_EXIST, "user", "error", null); + new PathCheck( + "expect1", "user", ExpectTypeEnum.EXPECTED_EXIST, "user", "error", null, null); PathCheck pathCheck2 = - new PathCheck("expect2", "user", ExpectTypeEnum.EXPECTED_TRUE, "${param.id}", "error", 400); + new PathCheck( + "expect2", "user", ExpectTypeEnum.EXPECTED_TRUE, "${param.id}", "error", 400, null); PathCheck pathCheck3 = - new PathCheck("expect3", "user", ExpectTypeEnum.EXPECTED_STR, null, "error", 422); + new PathCheck("expect3", "user", ExpectTypeEnum.EXPECTED_STR, null, "error", 422, null); PathCheck pathCheck4 = - new PathCheck("expect4", "user", ExpectTypeEnum.EXPECTED_INT, null, "error", 422); + new PathCheck("expect4", "user", ExpectTypeEnum.EXPECTED_INT, null, "error", 422, null); PathCheck pathCheck5 = - new PathCheck("expect5", "user", ExpectTypeEnum.EXPECTED_NUMERIC, null, "error", 422); + new PathCheck("expect5", "user", ExpectTypeEnum.EXPECTED_NUMERIC, null, "error", 422, null); PathCheck pathCheck6 = - new PathCheck("expect6", "user", ExpectTypeEnum.EXPECTED_NOT_BLANK, null, "error", 422); + new PathCheck( + "expect6", "user", ExpectTypeEnum.EXPECTED_NOT_BLANK, null, "error", 422, null); + + PathCheck pathCheck7 = + new PathCheck( + "expect7", + "$.body.relatedContactInformation[*]", + ExpectTypeEnum.EXPECTED_TRUE, + "${param.emailAddress}", + "error", + 400, + "String"); + + PathCheck pathCheck8 = + new PathCheck( + "expect7", + "$.body.relatedContactInformation[*]", + ExpectTypeEnum.EXPECTED_TRUE, + "${param.emailAddress}", + "error", + 400, + "String"); Pair pair1 = Pair.of(pathCheck1, "user1"); Pair pair2 = Pair.of(pathCheck2, "user1"); @@ -220,8 +243,10 @@ public static List> buildIllegalPathCheckList() { Pair pair4 = Pair.of(pathCheck4, "123"); Pair pair5 = Pair.of(pathCheck5, "123"); Pair pair6 = Pair.of(pathCheck6, ""); + Pair pair7 = Pair.of(pathCheck7, Map.of("emailAddress", 123)); + Pair pair8 = Pair.of(pathCheck8, Map.of("emailAddress1", "")); - return List.of(pair1, pair2, pair3A, pair3B, pair4, pair5, pair6); + return List.of(pair1, pair2, pair3A, pair3B, pair4, pair5, pair6, pair7, pair8); } @ParameterizedTest @@ -234,9 +259,10 @@ void givenCheckPath_whenCheckExpect_thenReturnException(Pair public static List> buildLegalPathCheckList() { PathCheck pathCheck1 = - new PathCheck("EXPECTED", "user", ExpectTypeEnum.EXPECTED, "true", "", null); + new PathCheck("EXPECTED", "user", ExpectTypeEnum.EXPECTED, "true", "", null, null); PathCheck pathCheck2 = - new PathCheck("EXPECTED_EXIST", "user", ExpectTypeEnum.EXPECTED_EXIST, "true", "", null); + new PathCheck( + "EXPECTED_EXIST", "user", ExpectTypeEnum.EXPECTED_EXIST, "true", "", null, null); PathCheck pathCheck3 = new PathCheck( "EXPECTED_TRUE", @@ -244,15 +270,17 @@ public static List> buildLegalPathCheckList() { ExpectTypeEnum.EXPECTED_TRUE, "${param}", "", - 422); + 422, + null); PathCheck pathCheck4 = - new PathCheck("EXPECTED_STR", "", ExpectTypeEnum.EXPECTED_STR, "", "", 422); + new PathCheck("EXPECTED_STR", "", ExpectTypeEnum.EXPECTED_STR, "", "", 422, null); PathCheck pathCheck5 = - new PathCheck("EXPECTED_INT", "", ExpectTypeEnum.EXPECTED_INT, "", "", 422); + new PathCheck("EXPECTED_INT", "", ExpectTypeEnum.EXPECTED_INT, "", "", 422, null); PathCheck pathCheck6 = - new PathCheck("EXPECTED_NUMERIC", "", ExpectTypeEnum.EXPECTED_NUMERIC, "", "", 422); + new PathCheck("EXPECTED_NUMERIC", "", ExpectTypeEnum.EXPECTED_NUMERIC, "", "", 422, null); PathCheck pathCheck7 = - new PathCheck("EXPECTED_NOT_BLANK", "", ExpectTypeEnum.EXPECTED_NOT_BLANK, "", "", 422); + new PathCheck( + "EXPECTED_NOT_BLANK", "", ExpectTypeEnum.EXPECTED_NOT_BLANK, "", "", 422, null); Pair pair1 = Pair.of(pathCheck1, "true"); Pair pair2 = Pair.of(pathCheck2, null); @@ -276,7 +304,7 @@ void givenCheckPath_whenCheckExpect_thenReturnTrue(Pair pair) @Order(5) void givenCheckPath_whenCheckExpect_thenReturnFalse() { PathCheck pathCheck = - new PathCheck("expect", "user", ExpectTypeEnum.EXPECTED, "user", "error", null); + new PathCheck("expect", "user", ExpectTypeEnum.EXPECTED, "user", "error", null, null); Assertions.assertFalse(mappingMatrixCheckerActionRunner.checkExpect(pathCheck, "user1")); } diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.eline.add.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.eline.add.yaml index 07bac924..9d916078 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.eline.add.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.eline.add.yaml @@ -21,25 +21,25 @@ spec: request: - name: mapper.order.eline.add.buyerId title: The unique identifier of the organization that is acting as the a Buyer. - source: "@{{buyerId}}" - target: "" description: - replaceStar: true + target: "" + source: "@{{buyerId}}" sourceLocation: QUERY targetLocation: "" customizedField: false requiredMapping: false + replaceStar: true - name: mapper.order.eline.add.duration title: "order item Term duration" source: "@{{productOrderItem[0].requestedItemTerm.duration.amount}}" - target: "" sourceLocation: BODY + sourceType: constantNumber + target: "" targetLocation: "" requiredMapping: true - name: mapper.order.eline.add.duration.unit title: "order item Term unit" source: "@{{productOrderItem[0].requestedItemTerm.duration.units}}" - target: "" sourceType: enum sourceValues: - calendarYears @@ -51,28 +51,45 @@ spec: - businessHours - businessMinutes sourceLocation: BODY + target: "" targetLocation: "" valueMapping: {} requiredMapping: true - name: mapper.order.eline.add.endOfTermAction title: "MEFEndOfTermAction" source: "@{{productOrderItem[0].requestedItemTerm.endOfTermAction}}" - target: "" sourceLocation: BODY + sourceType: enum + sourceValues: + - roll + - autoDisconnect + - autoRenew + target: "" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.rollInterval.amount title: " quote item Term roll duration" source: "@{{productOrderItem[0].requestedItemTerm.rollInterval.amount}}" - target: "" sourceLocation: BODY + sourceType: constantNumber + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.rollInterval.units title: " quote item Term roll unit" source: "@{{productOrderItem[0].requestedItemTerm.rollInterval.units}}" - target: "" sourceLocation: BODY + sourceType: enum + sourceValues: + - calendarYears + - calendarMonths + - calendarDays + - calendarHours + - calendarMinutes + - businessDays + - businessHours + - businessMinutes + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.bandwidthUnit @@ -82,62 +99,90 @@ spec: sourceValues: - MBPS - GBPS - target: "" sourceLocation: BODY + target: "" targetLocation: BODY valueMapping: {} requiredMapping: true - name: mapper.order.eline.add.bandwidth title: "Bandwidth of the ELINE" source: "@{{productOrderItem[0].product.productConfiguration.bandwidth}}" - target: "" sourceLocation: BODY sourceType: discreteInt sourceValues: - - 1000 - - 10000 + target: "" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.name title: "The name of the ELINE" source: "@{{productOrderItem[0].product.productConfiguration.name}}" - target: "" sourceLocation: BODY + sourceType: discreteStr + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.paymentType title: "The payment type of the ELINE" source: "@{{productOrderItem[0].product.productConfiguration.paymentType}}" - target: "" + sourceType: discreteStr sourceLocation: BODY + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.classOfService title: "The class of Service of the Eline" source: "@{{productOrderItem[0].product.productConfiguration.classOfService}}" + sourceLocation: BODY + sourceType: discreteStr target: "" + targetLocation: BODY + requiredMapping: false + - name: mapper.order.eline.add.product.productConfiguration.buyerCompanyId + title: "The Id of buyer Company" + source: "@{{productOrderItem[0].product.productConfiguration.buyerCompanyId}}" sourceLocation: BODY + sourceType: discreteStr + target: "" + targetLocation: BODY + requiredMapping: false + - name: mapper.order.eline.add.product.productConfiguration.destUNIMetroId + title: "The metro id of the destination UNI" + source: "@{{productOrderItem[0].product.productConfiguration.destUNIMetroId}}" + sourceLocation: BODY + sourceType: discreteStr + target: "" + targetLocation: BODY + requiredMapping: false + - name: mapper.order.eline.add.product.productConfiguration.type + title: "customized product type" + source: "@{{productOrderItem[0].product.productConfiguration.type}}" + sourceLocation: BODY + sourceType: discreteStr + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.srcUNI title: "source UNI or ENNI id" source: "@{{productOrderItem[0].product.productRelationship[0].id}}" - target: "" sourceLocation: BODY + sourceType: discreteStr + target: "" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.destUNI title: "destination UNI id" source: "@{{productOrderItem[0].product.productRelationship[1].id}}" - target: "" sourceLocation: BODY + sourceType: discreteStr + target: "" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.productOffering.id title: "id of a Product Offering" source: "@{{productOrderItem[0].product.productOffering.id}}" - target: "" sourceLocation: BODY + sourceType: discreteStr + target: "" targetLocation: BODY requiredMapping: true response: diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.uni.add.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.uni.add.yaml index 191b40f7..0d6ce525 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.uni.add.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.order.uni.add.yaml @@ -24,23 +24,23 @@ spec: title: >- The unique identifier of the organization that is acting as the a Buyer. - source: '@{{buyerId}}' - target: "" description: "" + source: '@{{buyerId}}' sourceLocation: QUERY + target: "" targetLocation: "" requiredMapping: false - name: mapper.order.uni.add.duration title: "order item Term duration" source: "@{{productOrderItem[0].requestedItemTerm.duration.amount}}" - target: "" sourceLocation: BODY + sourceType: constantNumber + target: "" targetLocation: "" requiredMapping: true - name: mapper.order.uni.add.duration.units title: "order item Term unit" source: "@{{productOrderItem[0].requestedItemTerm.duration.units}}" - target: "" sourceType: enum sourceValues: - calendarYears @@ -52,80 +52,103 @@ spec: - businessHours - businessMinutes sourceLocation: BODY + target: "" targetLocation: BODY valueMapping: {} requiredMapping: true - name: mapper.order.eline.add.endOfTermAction title: "MEFEndOfTermAction" source: "@{{productOrderItem[0].requestedItemTerm.endOfTermAction}}" - target: "" sourceLocation: BODY + sourceType: discreteStr + target: "" targetLocation: BODY requiredMapping: true - name: mapper.order.eline.add.rollInterval.amount title: " quote item Term roll duration" source: "@{{productOrderItem[0].requestedItemTerm.rollInterval.amount}}" - target: "" sourceLocation: BODY + sourceType: constantNumber + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.eline.add.rollInterval.units title: " quote item Term roll unit" source: "@{{productOrderItem[0].requestedItemTerm.rollInterval.units}}" - target: "" sourceLocation: BODY + sourceType: enum + sourceValues: + - calendarYears + - calendarMonths + - calendarDays + - calendarHours + - calendarMinutes + - businessDays + - businessHours + - businessMinutes + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.place.id title: >- the id of the place where the products' installation must be done. source: '@{{productOrderItem[0].product.place[0].id}}' + description: '' + sourceLocation: BODY + sourceType: discreteStr target: '' + targetLocation: BODY + requiredMapping: false + - name: mapper.order.uni.add.place.name + title: the keyName of the place where the products' installation must be done. description: '' + source: '@{{productOrderItem[0].product.place[0].keyName}}' sourceLocation: BODY + sourceType: discreteStr + target: '' targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.bandwidthUnit title: "The unit of bandwidth" source: "@{{productOrderItem[0].product.productConfiguration.bandwidthUnit}}" sourceType: enum + sourceLocation: BODY sourceValues: - MBPS - GBPS target: "" - sourceLocation: BODY targetLocation: BODY requiredMapping: true - name: mapper.order.uni.add.bandwidth title: "Bandwidth of the UNI" source: "@{{productOrderItem[0].product.productConfiguration.bandwidth}}" - target: "" sourceLocation: BODY sourceType: discreteInt sourceValues: - - 1000 - - 10000 + target: "" targetLocation: BODY requiredMapping: true - name: mapper.order.uni.add.name title: "The name of the UNI" source: "@{{productOrderItem[0].product.productConfiguration.name}}" - target: "" sourceLocation: BODY + sourceType: discreteStr + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.paymentType title: "The payment type of the UNI" source: "@{{productOrderItem[0].product.productConfiguration.paymentType}}" - target: "" sourceLocation: BODY + sourceType: discreteStr + target: "" targetLocation: BODY requiredMapping: false - name: mapper.order.uni.add.productOffering.id title: "id of a Product Offering" source: "@{{productOrderItem[0].product.productOffering.id}}" - target: "" sourceLocation: BODY + target: "" targetLocation: BODY requiredMapping: true response: diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.quote.eline.add.sync.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.quote.eline.add.sync.yaml index 16fc2828..85312974 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.quote.eline.add.sync.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.quote.eline.add.sync.yaml @@ -106,7 +106,8 @@ spec: title: "Bandwidth of the Eline" source: "@{{quoteItem[0].product.productConfiguration.bandwidth}}" sourceLocation: BODY - sourceType: constantNumber + sourceType: discreteInt + sourceValues: target: "" targetLocation: BODY requiredMapping: true diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.quote.uni.add.sync.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.quote.uni.add.sync.yaml index d6d7d290..2bcfb180 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.quote.uni.add.sync.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/api-targets-mappers/api-target-mapper.quote.uni.add.sync.yaml @@ -105,7 +105,8 @@ spec: title: "Bandwidth of the UNI" source: "@{{quoteItem[0].product.productConfiguration.bandwidth}}" sourceLocation: BODY - sourceType: constantNumber + sourceType: discreteInt + sourceValues: target: "" targetLocation: BODY requiredMapping: true diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.eline.add.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.eline.add.yaml index abdc5926..42515c1b 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.eline.add.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.eline.add.yaml @@ -22,32 +22,32 @@ 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 - name: productOrderItem_requestedItemTerm_name path: "$.body.productOrderItem[0].requestedItemTerm.name" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true - errorMsg: "requestedItemTerm.name should exist in request" + code: 422 - name: productOrderItem[0].product.productRelationship[0].relationshipType path: "$.body.productOrderItem[0].product.productRelationship[0].relationshipType" expectType: EXPECTED diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.uni.add.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.uni.add.yaml index ccdf6763..39a748b4 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.uni.add.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/mapping-matrix/mapping.matrix.order.uni.add.yaml @@ -24,34 +24,36 @@ spec: value: "INSTALL_LOCATION" - name: productOrderItem[0].product.place[0].@type path: "$.body.productOrderItem[0].product.place[0].@type" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true + code: 422 - name: relatedContactInformation_emailAddress 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 - name: productOrderItem_requestedItemTerm_name path: "$.body.productOrderItem[0].requestedItemTerm.name" - expectType: EXPECTED_EXIST + expectType: EXPECTED_STR value: true + 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 18599be8..57812870 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.2.yaml + - classpath:/mef-sonata/template-upgrade/release.1.6.3.yaml templateUpgradePaths: diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.6.3.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.6.3.yaml new file mode 100644 index 00000000..0786a144 --- /dev/null +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.6.3.yaml @@ -0,0 +1,15 @@ +--- +kind: kraken.product.template-upgrade +apiVersion: v1 +metadata: + key: kraken.product.template-upgrade.1.6.3 + name: V1.6.3 + labels: + productSpec: grace + productVersion: V1.6.3 + publishDate: 2024-12-17 + description: | + Add data type validation for the following use cases: + - UNI order creating + - Eline order creating + version: 1 \ No newline at end of file