From d500420179b5b28e92c6fa0a6f828ccd82005d85 Mon Sep 17 00:00:00 2001 From: xuelianhan007 Date: Thu, 21 Nov 2024 14:35:14 +0800 Subject: [PATCH 1/4] added support of discrete point feature --- .../api-target-mapper.order.uni.add.yaml | 4 ++++ .../kraken/operator/core/enums/MappingTypeEnum.java | 12 ++++++++++++ .../runner/MappingMatrixCheckerActionRunner.java | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java 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 1015ba6b..b5882caf 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 @@ -98,6 +98,10 @@ spec: - name: mapper.order.uni.add.bandwidth title: "Bandwidth of the UNI" source: "@{{productOrderItem[0].product.productConfiguration.bandwidth}}" + sourceType: discrete + sourceValues: + - 1000 + - 10000 target: "@{{speed}}" sourceLocation: BODY targetLocation: BODY diff --git a/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java b/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java new file mode 100644 index 00000000..0b9c6788 --- /dev/null +++ b/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java @@ -0,0 +1,12 @@ +package com.consoleconnect.kraken.operator.core.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum MappingTypeEnum { + ENUM("enum"), + DISCRETE("discrete"); + private final String name; +} 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 26e6fdba..420a47f8 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 @@ -7,6 +7,7 @@ import com.consoleconnect.kraken.operator.core.dto.UnifiedAssetDto; import com.consoleconnect.kraken.operator.core.enums.ActionTypeEnum; import com.consoleconnect.kraken.operator.core.enums.ExpectTypeEnum; +import com.consoleconnect.kraken.operator.core.enums.MappingTypeEnum; import com.consoleconnect.kraken.operator.core.enums.ParamLocationEnum; import com.consoleconnect.kraken.operator.core.exception.KrakenException; import com.consoleconnect.kraken.operator.core.model.AppProperty; @@ -41,7 +42,6 @@ public class MappingMatrixCheckerActionRunner extends AbstractActionRunner { public static final String MESSAGE_ALERT = "api use case is not supported %s"; public static final String CHECK_NAME_ENABLED = "enabled"; public static final String PARAM_NAME = "param"; - public static final String ENUM = "enum"; public static final String NOT_FOUND = "notFound"; public static final String COLON = ":"; private final UnifiedAssetService unifiedAssetService; @@ -217,7 +217,8 @@ public void checkRequestConstraints(String targetKey, Map inputs || ParamLocationEnum.HYBRID.name().equals(mapper.getTargetLocation())) { continue; } - if (Objects.equals(mapper.getSourceType(), ENUM)) { + if (MappingTypeEnum.ENUM.getName().equals(mapper.getSourceType()) + || MappingTypeEnum.DISCRETE.getName().equals(mapper.getSourceType())) { checkEnumValue(mapper.getSource(), mapper.getTarget(), inputs, mapper.getSourceValues()); } else if (mapper.getTarget() != null && !mapper.getTarget().contains("@{{")) { checkConstantValue(mapper.getSource(), mapper.getTarget(), inputs); From 93a010b52b71ade3ff04a65fdfd9b31cfe1a4e0f Mon Sep 17 00:00:00 2001 From: xuelianhan007 Date: Thu, 21 Nov 2024 15:03:59 +0800 Subject: [PATCH 2/4] added support of discrete values validation --- .../api-target-mapper.order.eline.add.yaml | 24 +++++++------- .../api-target-mapper.order.uni.add.yaml | 32 +++++++++---------- .../operator/core/enums/MappingTypeEnum.java | 2 +- .../LoadTargetAPIConfigActionRunner.java | 1 - .../MappingMatrixCheckerActionRunner.java | 2 +- 5 files changed, 30 insertions(+), 31 deletions(-) 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 d883359e..8a657720 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 @@ -178,18 +178,18 @@ spec: - rejected valueMapping: CREATING: acknowledged, - ACTIVATING: inProgress, - ACCEPTED: inProgress, - MANUAL: inProgress, - DELETING: inProgress, - DISABLING: inProgress, - DENIED: rejected, - ERROR: failed, - ACTIVE: completed, - DISABLED: disabled, - CANCELLED: disabled, - PENDING: pending, - PENDING_ACCEPTANCE: pending, + ACTIVATING: inProgress + ACCEPTED: inProgress + MANUAL: inProgress + DELETING: inProgress + DISABLING: inProgress + DENIED: rejected + ERROR: failed + ACTIVE: completed + DISABLED: disabled + CANCELLED: disabled + PENDING: pending + PENDING_ACCEPTANCE: pending DELETED: completed source: "@{{responseBody.status}}" sourceLocation: BODY 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 b5882caf..fb3fbb0a 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 @@ -98,7 +98,7 @@ spec: - name: mapper.order.uni.add.bandwidth title: "Bandwidth of the UNI" source: "@{{productOrderItem[0].product.productConfiguration.bandwidth}}" - sourceType: discrete + sourceType: customized_enum sourceValues: - 1000 - 10000 @@ -147,21 +147,21 @@ spec: - partial - rejected valueMapping: - progressing: inProgress, - created: acknowledged, - CREATING: acknowledged, - ACTIVATING: inProgress, - ACCEPTED: inProgress, - MANUAL: inProgress, - DELETING: inProgress, - DISABLING: inProgress, - DENIED: rejected, - ERROR: failed, - ACTIVE: completed, - DISABLED: disabled, - CANCELLED: disabled, - PENDING: pending, - PENDING_ACCEPTANCE: pending, + progressing: inProgress + created: acknowledged + CREATING: acknowledged + ACTIVATING: inProgress + ACCEPTED: inProgress + MANUAL: inProgress + DELETING: inProgress + DISABLING: inProgress + DENIED: rejected + ERROR: failed + ACTIVE: completed + DISABLED: disabled + CANCELLED: disabled + PENDING: pending + PENDING_ACCEPTANCE: pending DELETED: completed source: "@{{responseBody.status}}" sourceLocation: BODY diff --git a/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java b/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java index 0b9c6788..8a8eda84 100644 --- a/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java +++ b/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java @@ -7,6 +7,6 @@ @AllArgsConstructor public enum MappingTypeEnum { ENUM("enum"), - DISCRETE("discrete"); + CUSTOMIZED_ENUM("customized_enum"); private final String name; } diff --git a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/LoadTargetAPIConfigActionRunner.java b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/LoadTargetAPIConfigActionRunner.java index d1157d54..71b0fa98 100644 --- a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/LoadTargetAPIConfigActionRunner.java +++ b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/LoadTargetAPIConfigActionRunner.java @@ -76,7 +76,6 @@ public Optional runIt( String serverUrl = getServerUrl(serverKey); outputs.put("url", serverUrl); } - StateValueMappingDto stateValueMappingDto = new StateValueMappingDto(); renderRequestService.parseRequest(facets, stateValueMappingDto); 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 420a47f8..bf617158 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 @@ -218,7 +218,7 @@ public void checkRequestConstraints(String targetKey, Map inputs continue; } if (MappingTypeEnum.ENUM.getName().equals(mapper.getSourceType()) - || MappingTypeEnum.DISCRETE.getName().equals(mapper.getSourceType())) { + || MappingTypeEnum.CUSTOMIZED_ENUM.getName().equals(mapper.getSourceType())) { checkEnumValue(mapper.getSource(), mapper.getTarget(), inputs, mapper.getSourceValues()); } else if (mapper.getTarget() != null && !mapper.getTarget().contains("@{{")) { checkConstantValue(mapper.getSource(), mapper.getTarget(), inputs); From e19cc4071b75b09bc65df5163c5ba3f17a4aa53f Mon Sep 17 00:00:00 2001 From: xuelianhan007 Date: Thu, 21 Nov 2024 15:06:40 +0800 Subject: [PATCH 3/4] recover empty line --- .../operator/gateway/runner/LoadTargetAPIConfigActionRunner.java | 1 + 1 file changed, 1 insertion(+) diff --git a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/LoadTargetAPIConfigActionRunner.java b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/LoadTargetAPIConfigActionRunner.java index 71b0fa98..d1157d54 100644 --- a/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/LoadTargetAPIConfigActionRunner.java +++ b/kraken-java-sdk/kraken-java-sdk-gateway/src/main/java/com/consoleconnect/kraken/operator/gateway/runner/LoadTargetAPIConfigActionRunner.java @@ -76,6 +76,7 @@ public Optional runIt( String serverUrl = getServerUrl(serverKey); outputs.put("url", serverUrl); } + StateValueMappingDto stateValueMappingDto = new StateValueMappingDto(); renderRequestService.parseRequest(facets, stateValueMappingDto); From 2e8a3f5836b5c60fc982d87691bd49b57b158ec8 Mon Sep 17 00:00:00 2001 From: xuelianhan007 Date: Thu, 21 Nov 2024 15:20:30 +0800 Subject: [PATCH 4/4] rename from name to kind in MappingTypeEnum --- .../kraken/operator/core/enums/MappingTypeEnum.java | 2 +- .../gateway/runner/MappingMatrixCheckerActionRunner.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java b/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java index 8a8eda84..9432347a 100644 --- a/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java +++ b/kraken-java-sdk/kraken-java-sdk-core/src/main/java/com/consoleconnect/kraken/operator/core/enums/MappingTypeEnum.java @@ -8,5 +8,5 @@ public enum MappingTypeEnum { ENUM("enum"), CUSTOMIZED_ENUM("customized_enum"); - private final String name; + private final String kind; } 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 bf617158..7c210a1d 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 @@ -217,8 +217,8 @@ public void checkRequestConstraints(String targetKey, Map inputs || ParamLocationEnum.HYBRID.name().equals(mapper.getTargetLocation())) { continue; } - if (MappingTypeEnum.ENUM.getName().equals(mapper.getSourceType()) - || MappingTypeEnum.CUSTOMIZED_ENUM.getName().equals(mapper.getSourceType())) { + if (MappingTypeEnum.ENUM.getKind().equals(mapper.getSourceType()) + || MappingTypeEnum.CUSTOMIZED_ENUM.getKind().equals(mapper.getSourceType())) { checkEnumValue(mapper.getSource(), mapper.getTarget(), inputs, mapper.getSourceValues()); } else if (mapper.getTarget() != null && !mapper.getTarget().contains("@{{")) { checkConstantValue(mapper.getSource(), mapper.getTarget(), inputs);