From 063cf3d70776070930d69807f7d3f845ea7f44f1 Mon Sep 17 00:00:00 2001 From: xuelianhan007 <148412906+xuelianhan007@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:25:13 +0800 Subject: [PATCH] added javascript error message for quote (#99) --- .../src/test/resources/mock/apis/api.quote.yaml | 16 +++++++++++++--- .../resources/mef-sonata/apis/api.quote.yaml | 16 +++++++++++++--- .../src/main/resources/mef-sonata/product.yaml | 1 + .../template-upgrade/release.1.5.8.yaml | 13 +++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.5.8.yaml diff --git a/kraken-app/kraken-app-hub/src/test/resources/mock/apis/api.quote.yaml b/kraken-app/kraken-app-hub/src/test/resources/mock/apis/api.quote.yaml index e0bc525f..3e86b697 100644 --- a/kraken-app/kraken-app-hub/src/test/resources/mock/apis/api.quote.yaml +++ b/kraken-app/kraken-app-hub/src/test/resources/mock/apis/api.quote.yaml @@ -40,9 +40,13 @@ spec: (jsonStr) => { console.log("input: " + jsonStr); let input = JSON.parse(jsonStr); + let errorMsg = ''; let targetAPIConfigKey = ''; + let matrixConfigKey = ''; let forwardDownstream = true; - if(input.quoteItem['product']['productConfiguration']['@type'] == 'UNI') { + let typeArr = ['UNI', 'ACCESS_E_LINE']; + let typeVal = input.quoteItem['product']['productConfiguration']['@type']; + if(typeVal == 'UNI') { if(input.instantSyncQuote === true) { targetAPIConfigKey = 'mef.sonata.api-target.quote.uni.add.sync'; matrixConfigKey = 'mef.sonata.api.matrix.quote.uni.add.sync' @@ -50,7 +54,7 @@ spec: targetAPIConfigKey = 'mef.sonata.api-target.quote.uni.add'; matrixConfigKey = 'mef.sonata.api.matrix.quote.uni.add' } - } else if(input.quoteItem['product']['productConfiguration']['@type'] == 'ACCESS_E_LINE') { + } else if(typeVal == 'ACCESS_E_LINE') { if(input.instantSyncQuote === true) { targetAPIConfigKey = 'mef.sonata.api-target.quote.eline.add.sync'; matrixConfigKey = 'mef.sonata.api.matrix.quote.eline.add.sync' @@ -59,6 +63,11 @@ spec: matrixConfigKey = 'mef.sonata.api.matrix.quote.eline.add' } } else { + errorArr = ['api use case is not supported :']; + if (!typeArr.includes(typeVal)){ + errorArr.push(`expect quoteItem[0].product.productConfiguration.@type in [ ${typeArr} ], but ${typeVal}.`); + } + errorMsg = errorArr.join(' '); targetAPIConfigKey = 'targetKey:notFound'; } let ret = { @@ -66,7 +75,8 @@ spec: instantSyncQuote: input.instantSyncQuote, forwardDownstream: forwardDownstream, targetAPIConfigKey: targetAPIConfigKey, - matrixConfigKey: matrixConfigKey + matrixConfigKey: matrixConfigKey, + errorMsg: errorMsg }; return JSON.stringify(ret); } diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/apis/api.quote.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/apis/api.quote.yaml index e0bc525f..3e86b697 100644 --- a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/apis/api.quote.yaml +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/apis/api.quote.yaml @@ -40,9 +40,13 @@ spec: (jsonStr) => { console.log("input: " + jsonStr); let input = JSON.parse(jsonStr); + let errorMsg = ''; let targetAPIConfigKey = ''; + let matrixConfigKey = ''; let forwardDownstream = true; - if(input.quoteItem['product']['productConfiguration']['@type'] == 'UNI') { + let typeArr = ['UNI', 'ACCESS_E_LINE']; + let typeVal = input.quoteItem['product']['productConfiguration']['@type']; + if(typeVal == 'UNI') { if(input.instantSyncQuote === true) { targetAPIConfigKey = 'mef.sonata.api-target.quote.uni.add.sync'; matrixConfigKey = 'mef.sonata.api.matrix.quote.uni.add.sync' @@ -50,7 +54,7 @@ spec: targetAPIConfigKey = 'mef.sonata.api-target.quote.uni.add'; matrixConfigKey = 'mef.sonata.api.matrix.quote.uni.add' } - } else if(input.quoteItem['product']['productConfiguration']['@type'] == 'ACCESS_E_LINE') { + } else if(typeVal == 'ACCESS_E_LINE') { if(input.instantSyncQuote === true) { targetAPIConfigKey = 'mef.sonata.api-target.quote.eline.add.sync'; matrixConfigKey = 'mef.sonata.api.matrix.quote.eline.add.sync' @@ -59,6 +63,11 @@ spec: matrixConfigKey = 'mef.sonata.api.matrix.quote.eline.add' } } else { + errorArr = ['api use case is not supported :']; + if (!typeArr.includes(typeVal)){ + errorArr.push(`expect quoteItem[0].product.productConfiguration.@type in [ ${typeArr} ], but ${typeVal}.`); + } + errorMsg = errorArr.join(' '); targetAPIConfigKey = 'targetKey:notFound'; } let ret = { @@ -66,7 +75,8 @@ spec: instantSyncQuote: input.instantSyncQuote, forwardDownstream: forwardDownstream, targetAPIConfigKey: targetAPIConfigKey, - matrixConfigKey: matrixConfigKey + matrixConfigKey: matrixConfigKey, + errorMsg: errorMsg }; return JSON.stringify(ret); } 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 dedff744..085b194d 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 @@ -102,6 +102,7 @@ spec: - classpath:/mef-sonata/mapping-matrix/mapping.matrix.inventory.eline.list.yaml - classpath:/mef-sonata/template-upgrade/release.1.5.6.yaml - classpath:/mef-sonata/template-upgrade/release.1.5.7.yaml + - classpath:/mef-sonata/template-upgrade/release.1.5.8.yaml templateUpgradePaths: diff --git a/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.5.8.yaml b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.5.8.yaml new file mode 100644 index 00000000..10d1493b --- /dev/null +++ b/kraken-java-sdk/kraken-java-sdk-mef/src/main/resources/mef-sonata/template-upgrade/release.1.5.8.yaml @@ -0,0 +1,13 @@ +--- +kind: kraken.product.template-upgrade +apiVersion: v1 +metadata: + key: kraken.product.template-upgrade.1.5.8 + name: V1.5.8 + labels: + productSpec: grace + productVersion: V1.5.8 + publishDate: 2024-11-08 18:18 + description: | + Added error message in javascript for quote + version: 2 \ No newline at end of file