From: Toine Siebelink Date: Wed, 11 Oct 2023 08:54:57 +0000 (+0000) Subject: Merge "Conflicting Error code" X-Git-Tag: 3.3.9~21 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=4bc19fe118ca7d81891c12d40719a569bc528a21;hp=6c338a5655f569adff88d9317e7482f1482b455d;p=cps.git Merge "Conflicting Error code" --- diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java index 7db87e87e..1d68450f8 100755 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java @@ -31,6 +31,7 @@ import static org.onap.cps.notification.Operation.UPDATE; import io.micrometer.core.annotation.Timed; import java.io.Serializable; import java.time.OffsetDateTime; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -321,28 +322,12 @@ public class CpsDataServiceImpl implements CpsDataService { processDataUpdatedEventAsync(anchor, listNodeXpath, DELETE, observedTimestamp); } - private DataNode buildDataNode(final Anchor anchor, final String parentNodeXpath, final String nodeData, - final ContentType contentType) { - final SchemaContext schemaContext = getSchemaContext(anchor); - - if (ROOT_NODE_XPATH.equals(parentNodeXpath)) { - final ContainerNode containerNode = timedYangParser.parseData(contentType, nodeData, schemaContext); - return new DataNodeBuilder().withContainerNode(containerNode).build(); - } - - final ContainerNode containerNode = - timedYangParser.parseData(contentType, nodeData, schemaContext, parentNodeXpath); - - return new DataNodeBuilder() - .withParentNodeXpath(parentNodeXpath) - .withContainerNode(containerNode) - .build(); - } - private Collection buildDataNodes(final Anchor anchor, final Map nodesJsonData) { - return nodesJsonData.entrySet().stream().map(nodeJsonData -> - buildDataNode(anchor, nodeJsonData.getKey(), - nodeJsonData.getValue(), ContentType.JSON)).collect(Collectors.toList()); + final Collection dataNodes = new ArrayList<>(); + for (final Map.Entry nodeJsonData : nodesJsonData.entrySet()) { + dataNodes.addAll(buildDataNodes(anchor, nodeJsonData.getKey(), nodeJsonData.getValue(), ContentType.JSON)); + } + return dataNodes; } private Collection buildDataNodes(final Anchor anchor, final String parentNodeXpath, diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy index b4ac7a68f..e1d15d68a 100644 --- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy @@ -307,15 +307,16 @@ class CpsDataServiceImplSpec extends Specification { objectUnderTest.updateDataNodeAndDescendants(dataspaceName, anchorName, parentNodeXpath, jsonData, observedTimestamp) then: 'the persistence service method is invoked with correct parameters' 1 * mockCpsDataPersistenceService.updateDataNodesAndDescendants(dataspaceName, anchorName, - { dataNode -> dataNode.xpath[0] == expectedNodeXpath }) + { dataNode -> dataNode.xpath == expectedNodeXpath}) and: 'data updated event is sent to notification service' 1 * mockNotificationService.processDataUpdatedEvent(anchor, parentNodeXpath, Operation.UPDATE, observedTimestamp) and: 'the CpsValidator is called on the dataspaceName and AnchorName' 1 * mockCpsValidator.validateNameCharacters(dataspaceName, anchorName) where: 'following parameters were used' - scenario | parentNodeXpath | jsonData || expectedNodeXpath - 'top level node' | '/' | '{"test-tree": {"branch": []}}' || '/test-tree' - 'level 2 node' | '/test-tree' | '{"branch": [{"name":"Name"}]}' || '/test-tree/branch[@name=\'Name\']' + scenario | parentNodeXpath | jsonData || expectedNodeXpath + 'top level node' | '/' | '{"test-tree": {"branch": []}}' || ['/test-tree'] + 'level 2 node' | '/test-tree' | '{"branch": [{"name":"Name"}]}' || ['/test-tree/branch[@name=\'Name\']'] + 'json list' | '/test-tree' | '{"branch": [{"name":"Name1"}, {"name":"Name2"}]}' || ["/test-tree/branch[@name='Name1']", "/test-tree/branch[@name='Name2']"] } def 'Replace data node using multiple data nodes: #scenario.'() { @@ -327,14 +328,16 @@ class CpsDataServiceImplSpec extends Specification { 1 * mockCpsDataPersistenceService.updateDataNodesAndDescendants(dataspaceName, anchorName, { dataNode -> dataNode.xpath == expectedNodeXpath}) and: 'data updated event is sent to notification service' - 1 * mockNotificationService.processDataUpdatedEvent(anchor, nodesJsonData.keySet()[0], Operation.UPDATE, observedTimestamp) - 1 * mockNotificationService.processDataUpdatedEvent(anchor, nodesJsonData.keySet()[1], Operation.UPDATE, observedTimestamp) + nodesJsonData.keySet().each { + 1 * mockNotificationService.processDataUpdatedEvent(anchor, it, Operation.UPDATE, observedTimestamp) + } and: 'the CpsValidator is called on the dataspaceName and AnchorName' 1 * mockCpsValidator.validateNameCharacters(dataspaceName, anchorName) where: 'following parameters were used' scenario | nodesJsonData || expectedNodeXpath 'top level node' | ['/' : '{"test-tree": {"branch": []}}', '/test-tree' : '{"branch": [{"name":"Name"}]}'] || ["/test-tree", "/test-tree/branch[@name='Name']"] 'level 2 node' | ['/test-tree' : '{"branch": [{"name":"Name"}]}', '/test-tree/branch[@name=\'Name\']':'{"nest":{"name":"nestName"}}'] || ["/test-tree/branch[@name='Name']", "/test-tree/branch[@name='Name']/nest"] + 'json list' | ['/test-tree' : '{"branch": [{"name":"Name1"}, {"name":"Name2"}]}'] || ["/test-tree/branch[@name='Name1']", "/test-tree/branch[@name='Name2']"] } def 'Replace data node with concurrency exception in persistence layer.'() { diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index bb286fde2..2607385de 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -38,6 +38,7 @@ services: ports: - ${CPS_CORE_PORT:-8883}:8080 - ${CPS_CORE_MANAGEMENT_PORT:-8887}:8081 + - ${CPS_CORE_DEBUG_PORT:-5005}:5005 environment: CPS_USERNAME: ${CPS_CORE_USERNAME:-cpsuser} CPS_PASSWORD: ${CPS_CORE_PASSWORD:-cpsr0cks!} @@ -52,6 +53,7 @@ services: NOTIFICATION_DATASPACE_FILTER_PATTERNS: '.*' NCMP_TIMERS_ADVISED-MODULES-SYNC_SLEEP-TIME-MS: ${ADVISED_MODULES_SYNC_SLEEP_TIME_MS:-30000} NCMP_TIMERS_CM-HANDLE-DATA-SYNC_SLEEP-TIME-MS: ${CMHANDLE_DATA_SYNC_SLEEP_TIME_MS:-30000} + JAVA_TOOL_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 restart: unless-stopped depends_on: - dbpostgresql