Skip to content

Commit

Permalink
fix(sdk): add empty matrix (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyaoPCCW authored Dec 4, 2024
1 parent 906a817 commit 77959a2
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ protected void onCheck(Map<String, Object> inputs) {
Assert.notNull(inputs.get(TARGET_KEY), "targetKey must not be null");
String componentKey = inputs.get(MAPPING_MATRIX_KEY).toString();
String targetKey = inputs.get(TARGET_KEY).toString();
if (unifiedAssetRepository.findOneByKey(targetKey).isEmpty()) {
throw KrakenException.badRequest(MESSAGE_ALERT.formatted(":not deployed"));
}
if (StringUtils.isNotBlank(componentKey)
&& componentKey.endsWith(NOT_FOUND)
&& componentKey.contains(COLON)) {
Expand Down Expand Up @@ -107,9 +110,6 @@ protected void onCheck(Map<String, Object> inputs) {
throw KrakenException.badRequest(
MESSAGE_ALERT.formatted(":lack in check rules for target key: " + targetKey));
}
if (unifiedAssetRepository.findOneByKey(targetKey).isEmpty()) {
throw KrakenException.badRequest(MESSAGE_ALERT.formatted(":not deployed"));
}
// check enable/disable
enableChecking(facets, targetKey);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void givenTargetKeyNotFound_whenOnCheck_thenReturnException() {
Assertions.assertThrowsExactly(
KrakenException.class, () -> mappingMatrixCheckerActionRunner.onCheck(inputs));
MatcherAssert.assertThat(
krakenException.getMessage(), Matchers.containsString("possibly product not supported"));
krakenException.getMessage(),
Matchers.containsString("api use case is not supported :not deployed"));
}

@Test
Expand All @@ -49,7 +50,7 @@ void givenTargetKeyNotDeployed_whenOnCheck_thenReturnException() {
MatcherAssert.assertThat(
krakenException.getMessage(),
Matchers.containsString("""
lack in check rules for target key"""));
api use case is not supported :not deployed"""));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ spec:
env:
input: ${path}
pattern: /mefApi/sonata/geographicAddressManagement/v7/geographicAddress/(?<segment>.*)

- id: mapping_matrix_check_retrieve_address
actionType: buildin@mapping-matrix-checker
env:
mappingMatrixKey: mef.sonata.api.matrix.address.retrieve
targetKey: mef.sonata.api-target.address.retrieve
- id: load-downstream-api-config
actionType: buildin@load-target-api-config
env:
Expand Down Expand Up @@ -134,6 +138,9 @@ links:
- targetAssetKey: mef.sonata.api-target.address.retrieve
relationship: implementation.target
group: mef.sonata.api-target.address.retrieve
- targetAssetKey: mef.sonata.api.matrix.address.retrieve
relationship: implementation.matrix
group: mef.sonata.api-target.address.retrieve
- targetAssetKey: mef.sonata.api-target.address.validate
relationship: implementation.target
group: mef.sonata.api-target.address.validate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,35 @@ spec:
console.log("input: " + jsonStr);
let input = JSON.parse(jsonStr);
let targetAPIConfigKey = '';
let matrixConfigKey = '';
if (input.bizType == 'UNI' && input.bizAction == 'add') {
targetAPIConfigKey = 'mef.sonata.api-target.order.uni.read';
matrixConfigKey = 'mef.sonata.api.matrix.order.uni.read';
} else if(input.bizType == 'ACCESS_E_LINE' && input.bizAction == 'add') {
targetAPIConfigKey = 'mef.sonata.api-target.order.eline.read';
matrixConfigKey = 'mef.sonata.api.matrix.order.eline.read';
} else if (input.bizType == 'UNI' && input.bizAction == 'delete') {
targetAPIConfigKey = 'mef.sonata.api-target.order.uni.read.delete';
matrixConfigKey = 'mef.sonata.api.matrix.order.uni.read.delete';
} else if(input.bizType == 'ACCESS_E_LINE' && input.bizAction == 'delete') {
targetAPIConfigKey = 'mef.sonata.api-target.order.eline.read.delete';
matrixConfigKey = 'mef.sonata.api.matrix.order.eline.read.delete';
} else {
targetAPIConfigKey = 'targetKey:notFound';
}
let ret = {
orderType: input.bizType,
targetAPIConfigKey: targetAPIConfigKey
targetAPIConfigKey: targetAPIConfigKey,
matrixConfigKey: matrixConfigKey
};
return JSON.stringify(ret);
}
outputKey: order
- id: mapping_matrix_check_read_order
actionType: buildin@mapping-matrix-checker
env:
mappingMatrixKey: ${order.matrixConfigKey}
targetKey: ${order.targetAPIConfigKey}
- id: load-downstream-api-config
actionType: buildin@load-target-api-config
env:
Expand Down Expand Up @@ -338,4 +349,17 @@ links:
group: mef.sonata.api-target.order.eline.delete
- targetAssetKey: mef.sonata.api.matrix.order.eline.delete
relationship: implementation.matrix
group: mef.sonata.api-target.order.eline.delete
group: mef.sonata.api-target.order.eline.delete

- targetAssetKey: mef.sonata.api.matrix.order.uni.read
relationship: implementation.matrix
group: mef.sonata.api-target.order.uni.read
- targetAssetKey: mef.sonata.api.matrix.order.uni.read.delete
relationship: implementation.matrix
group: mef.sonata.api-target.order.uni.read.delete
- targetAssetKey: mef.sonata.api.matrix.order.eline.read
relationship: implementation.matrix
group: mef.sonata.api-target.order.eline.read
- targetAssetKey: mef.sonata.api.matrix.order.eline.read.delete
relationship: implementation.matrix
group: mef.sonata.api-target.order.eline.read.delete
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
kind: kraken.product.mapping.matrix
apiVersion: v1
metadata:
key: mef.sonata.api.matrix.address.retrieve
name: MEF Sonata API
labels:
mef-api-release: grace
version: 10
spec:
matrix:
mef.sonata.api-target.address.retrieve:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
kind: kraken.product.mapping.matrix
apiVersion: v1
metadata:
key: mef.sonata.api.matrix.order.eline.read.delete
name: MEF Sonata API
labels:
mef-api-release: grace
version: 1
spec:
matrix:
mef.sonata.api-target.order.eline.read.delete:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
kind: kraken.product.mapping.matrix
apiVersion: v1
metadata:
key: mef.sonata.api.matrix.order.eline.read
name: MEF Sonata API
labels:
mef-api-release: grace
version: 1
spec:
matrix:
mef.sonata.api-target.order.eline.read:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
kind: kraken.product.mapping.matrix
apiVersion: v1
metadata:
key: mef.sonata.api.matrix.order.uni.read.delete
name: MEF Sonata API
labels:
mef-api-release: grace
version: 1
spec:
matrix:
mef.sonata.api-target.order.uni.read.delete:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
kind: kraken.product.mapping.matrix
apiVersion: v1
metadata:
key: mef.sonata.api.matrix.order.uni.read
name: MEF Sonata API
labels:
mef-api-release: grace
version: 1
spec:
matrix:
mef.sonata.api-target.order.uni.read:
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ spec:
- classpath:/mef-sonata/api-targets-mappers/api-target-mapper.inventory.eline.read.yaml
- classpath:/mef-sonata/api-targets-mappers/api-target-mapper.inventory.uni.read.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.address.validation.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.address.retrieve.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.uni.add.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.uni.delete.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.uni.read.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.uni.read.delete.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.eline.delete.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.eline.add.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.eline.read.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.eline.read.delete.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.quote.uni.add.sync.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.quote.uni.add.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.quote.eline.add.sync.yaml
Expand All @@ -98,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.0.yaml
- classpath:/mef-sonata/template-upgrade/release.1.6.1.yaml


templateUpgradePaths:
Expand Down Expand Up @@ -141,10 +146,15 @@ spec:
- classpath:/mef-sonata/api-targets-mappers/api-target-mapper.quote.uni.read.sync.yaml
- classpath:/mef-sonata/api-targets/api-target.quote.uni.read.sync.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.address.validation.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.address.retrieve.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.uni.add.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.uni.delete.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.uni.read.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.uni.read.delete.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.eline.delete.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.eline.add.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.eline.read.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.order.eline.read.delete.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.quote.uni.add.sync.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.quote.uni.add.yaml
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.quote.eline.add.sync.yaml
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
kind: kraken.product.template-upgrade
apiVersion: v1
metadata:
key: kraken.product.template-upgrade.1.6.1
name: V1.6.1
labels:
productSpec: grace
productVersion: V1.6.1
publishDate: 2024-12-03
description: |
Add empty matrix files for below use cases:
- get UNI ADD order by id
- get Eline ADD order by id
- get UNI DELETE order by id
- get Eline DELETE order by id
- retrieve address
version: 1

0 comments on commit 77959a2

Please sign in to comment.