aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java27
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java21
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java48
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionNcmpOutEventMapper.java96
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/executor/TaskExecutor.java47
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java33
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/AlternateIdChecker.java34
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmResourceAddress.java25
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java5
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java4
-rw-r--r--cps-ncmp-service/src/main/resources/models/dmi-registry@2024-02-23.yang (renamed from cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang)8
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy27
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy52
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy12
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy4
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionNcmpOutEventMapperSpec.groovy55
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy24
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy6
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy39
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy4
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/AlternateIdCheckerSpec.groovy3
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy4
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy9
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy6
28 files changed, 407 insertions, 206 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
index 4230140d26..20545d711d 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
@@ -29,6 +29,7 @@ import org.onap.cps.ncmp.api.impl.inventory.CompositeState;
import org.onap.cps.ncmp.api.impl.operations.OperationType;
import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters;
import org.onap.cps.ncmp.api.models.CmHandleQueryServiceParameters;
+import org.onap.cps.ncmp.api.models.CmResourceAddress;
import org.onap.cps.ncmp.api.models.DataOperationRequest;
import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse;
@@ -53,18 +54,14 @@ public interface NetworkCmProxyDataService {
/**
* Get resource data for given data store using dmi.
*
- * @param datastoreName datastore name
- * @param cmHandleId cm handle identifier
- * @param resourceIdentifier resource identifier
+ * @param cmResourceAddress target datastore, cm handle and resource identifier
* @param optionsParamInQuery options query
* @param topicParamInQuery topic name for (triggering) async responses
* @param requestId unique requestId for async request
* @param authorization contents of Authorization header, or null if not present
* @return {@code Object} resource data
*/
- Object getResourceDataForCmHandle(String datastoreName,
- String cmHandleId,
- String resourceIdentifier,
+ Object getResourceDataForCmHandle(CmResourceAddress cmResourceAddress,
String optionsParamInQuery,
String topicParamInQuery,
String requestId,
@@ -73,15 +70,11 @@ public interface NetworkCmProxyDataService {
/**
* Get resource data for operational.
*
- * @param datastoreName datastore name
- * @param cmHandleId cm handle identifier
- * @param resourceIdentifier resource identifier
+ * @param cmResourceAddress target datastore, cm handle and resource identifier
* @Link FetchDescendantsOption fetch descendants option
* @return {@code Object} resource data
*/
- Object getResourceDataForCmHandle(String datastoreName,
- String cmHandleId,
- String resourceIdentifier,
+ Object getResourceDataForCmHandle(CmResourceAddress cmResourceAddress,
FetchDescendantsOption fetchDescendantsOption);
/**
@@ -110,11 +103,11 @@ public interface NetworkCmProxyDataService {
* @return {@code Object} return data
*/
Object writeResourceDataPassThroughRunningForCmHandle(String cmHandleId,
- String resourceIdentifier,
- OperationType operationType,
- String requestBody,
- String contentType,
- String authorization);
+ String resourceIdentifier,
+ OperationType operationType,
+ String requestBody,
+ String contentType,
+ String authorization);
/**
* Retrieve module references for the given cm handle.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index 4c905bf90f..c15df9c869 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -72,6 +72,7 @@ import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters;
import org.onap.cps.ncmp.api.models.CmHandleQueryServiceParameters;
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse;
+import org.onap.cps.ncmp.api.models.CmResourceAddress;
import org.onap.cps.ncmp.api.models.DataOperationRequest;
import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse;
@@ -127,15 +128,12 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
}
@Override
- public Object getResourceDataForCmHandle(final String datastoreName,
- final String cmHandleId,
- final String resourceIdentifier,
+ public Object getResourceDataForCmHandle(final CmResourceAddress cmResourceAddress,
final String optionsParamInQuery,
final String topicParamInQuery,
final String requestId,
final String authorization) {
- final ResponseEntity<?> responseEntity = dmiDataOperations.getResourceDataFromDmi(datastoreName, cmHandleId,
- resourceIdentifier,
+ final ResponseEntity<?> responseEntity = dmiDataOperations.getResourceDataFromDmi(cmResourceAddress,
optionsParamInQuery,
topicParamInQuery,
requestId,
@@ -144,12 +142,12 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
}
@Override
- public Object getResourceDataForCmHandle(final String datastoreName,
- final String cmHandleId,
- final String resourceIdentifier,
+ public Object getResourceDataForCmHandle(final CmResourceAddress cmResourceAddress,
final FetchDescendantsOption fetchDescendantsOption) {
- return cpsDataService.getDataNodes(datastoreName, cmHandleId, resourceIdentifier,
- fetchDescendantsOption).iterator().next();
+ return cpsDataService.getDataNodes(cmResourceAddress.datastoreName(),
+ cmResourceAddress.cmHandleId(),
+ cmResourceAddress.resourceIdentifier(),
+ fetchDescendantsOption).iterator().next();
}
@Override
@@ -459,7 +457,8 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
dmiPluginRegistration.getDmiModelPlugin(),
ncmpServiceCmHandle,
ncmpServiceCmHandle.getModuleSetTag(),
- ncmpServiceCmHandle.getAlternateId());
+ ncmpServiceCmHandle.getAlternateId(),
+ ncmpServiceCmHandle.getDataProducerIdentifier());
}
private void processTrustLevels(final Collection<NcmpServiceCmHandle> cmHandlesToBeCreated,
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
index 3d15291633..f861910024 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
@@ -47,6 +47,8 @@ import lombok.extern.slf4j.Slf4j;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence;
import org.onap.cps.ncmp.api.impl.utils.AlternateIdChecker;
+import org.onap.cps.ncmp.api.impl.utils.YangDataConverter;
+import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
@@ -55,6 +57,7 @@ import org.onap.cps.spi.model.DataNode;
import org.onap.cps.spi.model.DataNodeBuilder;
import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
@Slf4j
@Service
@@ -110,7 +113,9 @@ public class NetworkCmProxyDataServicePropertyHandler {
private void processUpdates(final DataNode existingCmHandleDataNode,
final NcmpServiceCmHandle updatedNcmpServiceCmHandle) {
- updateAlternateId(updatedNcmpServiceCmHandle);
+ setAndUpdateCmHandleField(
+ updatedNcmpServiceCmHandle.getCmHandleId(), "alternate-id", updatedNcmpServiceCmHandle.getAlternateId());
+ updateDataProducerIdentifier(existingCmHandleDataNode, updatedNcmpServiceCmHandle);
if (!updatedNcmpServiceCmHandle.getPublicProperties().isEmpty()) {
updateProperties(existingCmHandleDataNode, PUBLIC_PROPERTY,
updatedNcmpServiceCmHandle.getPublicProperties());
@@ -120,17 +125,24 @@ public class NetworkCmProxyDataServicePropertyHandler {
}
}
- private void updateAlternateId(final NcmpServiceCmHandle updatedNcmpServiceCmHandle) {
- final String updatedAlternateId = updatedNcmpServiceCmHandle.getAlternateId();
- final String cmHandleId = updatedNcmpServiceCmHandle.getCmHandleId();
- final Map<String, String> cmHandleProperties = new HashMap<>(2);
- cmHandleProperties.put("id", cmHandleId);
- cmHandleProperties.put("alternate-id", updatedAlternateId);
- final Map<String, Map<String, String>> dmiRegistryProperties = new HashMap<>(1);
- dmiRegistryProperties.put("cm-handles", cmHandleProperties);
- cpsDataService.updateNodeLeaves(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT,
- jsonObjectMapper.asJsonString(dmiRegistryProperties), OffsetDateTime.now());
- log.debug("Updating alternateId for cmHandle {} with value : {})", cmHandleId, updatedAlternateId);
+ private void updateDataProducerIdentifier(final DataNode cmHandleDataNode,
+ final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ final String newDataProducerIdentifier = ncmpServiceCmHandle.getDataProducerIdentifier();
+ if (StringUtils.hasText(newDataProducerIdentifier)) {
+ final YangModelCmHandle yangModelCmHandle =
+ YangDataConverter.convertCmHandleToYangModel(cmHandleDataNode);
+ final String existingDataProducerIdentifier = yangModelCmHandle.getDataProducerIdentifier();
+ if (StringUtils.hasText(existingDataProducerIdentifier)) {
+ if (!existingDataProducerIdentifier.equals(newDataProducerIdentifier)) {
+ log.warn("Unable to update dataProducerIdentifier for cmHandle {}. "
+ + "Value for dataProducerIdentifier has been set previously.",
+ ncmpServiceCmHandle.getCmHandleId());
+ }
+ } else {
+ setAndUpdateCmHandleField(
+ yangModelCmHandle.getId(), "data-producer-identifier", newDataProducerIdentifier);
+ }
+ }
}
private void updateProperties(final DataNode existingCmHandleDataNode, final PropertyType propertyType,
@@ -202,6 +214,18 @@ public class NetworkCmProxyDataServicePropertyHandler {
return new DataNodeBuilder().withXpath(xpath).withLeaves(ImmutableMap.copyOf(updatedLeaves)).build();
}
+ private void setAndUpdateCmHandleField(final String cmHandleIdToUpdate, final String fieldName,
+ final String newFieldValue) {
+ final Map<String, Map<String, String>> dmiRegistryData = new HashMap<>(1);
+ final Map<String, String> cmHandleData = new HashMap<>(2);
+ cmHandleData.put("id", cmHandleIdToUpdate);
+ cmHandleData.put(fieldName, newFieldValue);
+ dmiRegistryData.put("cm-handles", cmHandleData);
+ cpsDataService.updateNodeLeaves(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT,
+ jsonObjectMapper.asJsonString(dmiRegistryData), OffsetDateTime.now());
+ log.debug("Updating {} for cmHandle {} with value : {})", fieldName, cmHandleIdToUpdate, newFieldValue);
+ }
+
enum PropertyType {
DMI_PROPERTY("additional-properties"), PUBLIC_PROPERTY("public-properties");
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionNcmpOutEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionNcmpOutEventMapper.java
new file mode 100644
index 0000000000..668f4517e8
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionNcmpOutEventMapper.java
@@ -0,0 +1,96 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.api.impl.events.cmsubscription.mapper;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import lombok.RequiredArgsConstructor;
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.CmNotificationSubscriptionStatus;
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionDetails;
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionPredicate;
+import org.onap.cps.ncmp.events.cmsubscription_merge1_0_0.ncmp_to_client.CmNotificationSubscriptionNcmpOutEvent;
+import org.onap.cps.ncmp.events.cmsubscription_merge1_0_0.ncmp_to_client.Data;
+import org.springframework.stereotype.Component;
+
+@Component
+@RequiredArgsConstructor
+public class CmNotificationSubscriptionNcmpOutEventMapper {
+
+ /**
+ * Mapper to form a response for the client for the Cm Notification Subscription.
+ *
+ * @param subscriptionId Cm Notification Subscription Id
+ * @param dmiCmNotificationSubscriptionDetailsMap contains CmNotificationSubscriptionDetails per dmi plugin
+ * @return CmNotificationSubscriptionNcmpOutEvent to sent back to the client
+ */
+ public CmNotificationSubscriptionNcmpOutEvent toCmNotificationSubscriptionNcmpOutEvent(final String subscriptionId,
+ final Map<String, DmiCmNotificationSubscriptionDetails> dmiCmNotificationSubscriptionDetailsMap) {
+
+ final CmNotificationSubscriptionNcmpOutEvent cmNotificationSubscriptionNcmpOutEvent =
+ new CmNotificationSubscriptionNcmpOutEvent();
+ final Data cmSubscriptionData = new Data();
+ cmSubscriptionData.setSubscriptionId(subscriptionId);
+ populateCmNotificationSubscriptionNcmpOutEventWithCmHandleIds(dmiCmNotificationSubscriptionDetailsMap,
+ cmSubscriptionData);
+ cmNotificationSubscriptionNcmpOutEvent.setData(cmSubscriptionData);
+
+ return cmNotificationSubscriptionNcmpOutEvent;
+ }
+
+ private void populateCmNotificationSubscriptionNcmpOutEventWithCmHandleIds(
+ final Map<String, DmiCmNotificationSubscriptionDetails> dmiCmNotificationSubscriptionDetailsMap,
+ final Data cmSubscriptionData) {
+
+ final List<String> acceptedCmHandleIds = new ArrayList<>();
+ final List<String> pendingCmHandleIds = new ArrayList<>();
+ final List<String> rejectedCmHandleIds = new ArrayList<>();
+
+ dmiCmNotificationSubscriptionDetailsMap.forEach((dmiPluginName, dmiCmNotificationSubscriptionDetails) -> {
+ final CmNotificationSubscriptionStatus cmNotificationSubscriptionStatus =
+ dmiCmNotificationSubscriptionDetails.getCmNotificationSubscriptionStatus();
+ final List<DmiCmNotificationSubscriptionPredicate> dmiCmNotificationSubscriptionPredicates =
+ dmiCmNotificationSubscriptionDetails.getDmiCmNotificationSubscriptionPredicates();
+
+ switch (cmNotificationSubscriptionStatus) {
+ case ACCEPTED -> acceptedCmHandleIds.addAll(
+ extractCmHandleIds(dmiCmNotificationSubscriptionPredicates));
+ case PENDING -> pendingCmHandleIds.addAll(extractCmHandleIds(dmiCmNotificationSubscriptionPredicates));
+ default -> rejectedCmHandleIds.addAll(extractCmHandleIds(dmiCmNotificationSubscriptionPredicates));
+ }
+ });
+
+ cmSubscriptionData.setAcceptedTargets(acceptedCmHandleIds);
+ cmSubscriptionData.setPendingTargets(pendingCmHandleIds);
+ cmSubscriptionData.setRejectedTargets(rejectedCmHandleIds);
+
+ }
+
+ private List<String> extractCmHandleIds(
+ final List<DmiCmNotificationSubscriptionPredicate> dmiCmNotificationSubscriptionPredicates) {
+ final List<String> cmHandleIds = new ArrayList<>();
+ dmiCmNotificationSubscriptionPredicates.forEach(dmiCmNotificationSubscriptionPredicate -> cmHandleIds.addAll(
+ dmiCmNotificationSubscriptionPredicate.getTargetCmHandleIds()));
+
+ return cmHandleIds;
+ }
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java
index 23d508b07b..fa27be158a 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java
@@ -96,6 +96,8 @@ public class LcmEventsCreator {
final Event event = new Event();
event.setCmHandleId(eventCorrelationId);
event.setAlternateId(targetNcmpServiceCmHandle.getAlternateId());
+ event.setModuleSetTag(targetNcmpServiceCmHandle.getModuleSetTag());
+ event.setDataProducerIdentifier(targetNcmpServiceCmHandle.getDataProducerIdentifier());
final CmHandleValuesHolder cmHandleValuesHolder =
LcmEventsCreatorHelper.determineEventValues(targetNcmpServiceCmHandle, existingNcmpServiceCmHandle,
lcmEventType);
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/executor/TaskExecutor.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/executor/TaskExecutor.java
deleted file mode 100644
index 192062fde5..0000000000
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/executor/TaskExecutor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.cps.ncmp.api.impl.executor;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-
-import java.util.concurrent.CompletableFuture;
-import java.util.function.Supplier;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class TaskExecutor {
-
- /**
- * Execute task asynchronously.
- *
- * @param taskSupplier functional method is get() task need to executed asynchronously
- * @param timeOutInMillis the timeout value in milliseconds
- */
- public static CompletableFuture<Object> executeTask(final Supplier<Object> taskSupplier,
- final long timeOutInMillis) {
- return CompletableFuture.supplyAsync(taskSupplier::get)
- .orTimeout(timeOutInMillis, MILLISECONDS);
- }
-}
-
-
-
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
index a77e78a2e2..a9ec1241bc 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation
+ * Copyright (C) 2021-2024 Nordix Foundation
* Modifications Copyright (C) 2022 Bell Canada
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,12 +37,12 @@ import org.onap.cps.ncmp.api.NcmpResponseStatus;
import org.onap.cps.ncmp.api.impl.client.DmiRestClient;
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration;
import org.onap.cps.ncmp.api.impl.exception.HttpClientRequestException;
-import org.onap.cps.ncmp.api.impl.executor.TaskExecutor;
import org.onap.cps.ncmp.api.impl.inventory.CmHandleState;
import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence;
import org.onap.cps.ncmp.api.impl.utils.DmiServiceUrlBuilder;
import org.onap.cps.ncmp.api.impl.utils.data.operation.ResourceDataOperationRequestUtils;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
+import org.onap.cps.ncmp.api.models.CmResourceAddress;
import org.onap.cps.ncmp.api.models.DataOperationRequest;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.utils.JsonObjectMapper;
@@ -59,8 +59,6 @@ import org.springframework.web.util.UriComponentsBuilder;
@Slf4j
public class DmiDataOperations extends DmiOperations {
- private static final long DEFAULT_ASYNC_TASK_EXECUTOR_TIMEOUT_IN_MILLISECONDS = 30000L;
-
public DmiDataOperations(final InventoryPersistence inventoryPersistence,
final JsonObjectMapper jsonObjectMapper,
final NcmpConfiguration.DmiProperties dmiProperties,
@@ -73,9 +71,7 @@ public class DmiDataOperations extends DmiOperations {
* This method fetches the resource data from operational data store for given cm handle
* identifier on given resource using dmi client.
*
- * @param dataStoreName name of data store
- * @param cmHandleId network resource identifier
- * @param resourceId resource identifier
+ * @param cmResourceAddress target datastore, cm handle and resource identifier
* @param optionsParamInQuery options query
* @param topicParamInQuery topic name for (triggering) async responses
* @param requestId requestId for async responses
@@ -85,19 +81,17 @@ public class DmiDataOperations extends DmiOperations {
@Timed(value = "cps.ncmp.dmi.get",
description = "Time taken to fetch the resource data from operational data store for given cm handle "
+ "identifier on given resource using dmi client")
- public ResponseEntity<Object> getResourceDataFromDmi(final String dataStoreName,
- final String cmHandleId,
- final String resourceId,
+ public ResponseEntity<Object> getResourceDataFromDmi(final CmResourceAddress cmResourceAddress,
final String optionsParamInQuery,
final String topicParamInQuery,
final String requestId,
final String authorization) {
- final YangModelCmHandle yangModelCmHandle = getYangModelCmHandle(cmHandleId);
+ final YangModelCmHandle yangModelCmHandle = getYangModelCmHandle(cmResourceAddress.cmHandleId());
final CmHandleState cmHandleState = yangModelCmHandle.getCompositeState().getCmHandleState();
validateIfCmHandleStateReady(yangModelCmHandle, cmHandleState);
- final String jsonRequestBody = getDmiRequestBody(READ, requestId, null, null,
- yangModelCmHandle);
- final String dmiResourceDataUrl = getDmiRequestUrl(dataStoreName, cmHandleId, resourceId, optionsParamInQuery,
+ final String jsonRequestBody = getDmiRequestBody(READ, requestId, null, null, yangModelCmHandle);
+ final String dmiResourceDataUrl = getDmiRequestUrl(cmResourceAddress.datastoreName(),
+ cmResourceAddress.cmHandleId(), cmResourceAddress.resourceIdentifier(), optionsParamInQuery,
topicParamInQuery, yangModelCmHandle.resolveDmiServiceName(RequiredDmiService.DATA));
return dmiRestClient.postOperationWithJsonData(dmiResourceDataUrl, jsonRequestBody, READ, authorization);
}
@@ -259,11 +253,12 @@ public class DmiDataOperations extends DmiOperations {
.operations(dmiDataOperationRequestBodies).build();
final String dmiDataOperationRequestAsJsonString =
jsonObjectMapper.asJsonString(dmiDataOperationRequest);
- TaskExecutor.executeTask(() -> dmiRestClient.postOperationWithJsonData(dataOperationResourceUrl,
- dmiDataOperationRequestAsJsonString, READ, authorization),
- DEFAULT_ASYNC_TASK_EXECUTOR_TIMEOUT_IN_MILLISECONDS)
- .whenCompleteAsync((response, throwable) -> handleTaskCompletionException(throwable,
- dataOperationResourceUrl, dmiDataOperationRequestBodies));
+ try {
+ dmiRestClient.postOperationWithJsonData(dataOperationResourceUrl, dmiDataOperationRequestAsJsonString, READ,
+ authorization);
+ } catch (final Exception exception) {
+ handleTaskCompletionException(exception, dataOperationResourceUrl, dmiDataOperationRequestBodies);
+ }
}
private void handleTaskCompletionException(final Throwable throwable,
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/AlternateIdChecker.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/AlternateIdChecker.java
index f14439f690..60f39fcea0 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/AlternateIdChecker.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/AlternateIdChecker.java
@@ -115,23 +115,7 @@ public class AlternateIdChecker {
for (final NcmpServiceCmHandle ncmpServiceCmHandle : newNcmpServiceCmHandles) {
final String cmHandleId = ncmpServiceCmHandle.getCmHandleId();
final String proposedAlternateId = ncmpServiceCmHandle.getAlternateId();
- final boolean isAcceptable;
- if (StringUtils.isEmpty(proposedAlternateId)) {
- isAcceptable = true;
- } else {
- if (acceptedAlternateIds.contains(proposedAlternateId)) {
- isAcceptable = false;
- log.warn("Alternate id update ignored, cannot update cm handle {}, alternate id is already "
- + "assigned to a different cm handle (in this batch)", cmHandleId);
- } else {
- if (Operation.CREATE.equals(operation)) {
- isAcceptable = canApplyAlternateId(cmHandleId, NO_CURRENT_ALTERNATE_ID, proposedAlternateId);
- } else {
- isAcceptable = canApplyAlternateId(cmHandleId, proposedAlternateId);
- }
- }
- }
- if (isAcceptable) {
+ if (isProposedAlternateIdAcceptable(proposedAlternateId, operation, acceptedAlternateIds, cmHandleId)) {
acceptedAlternateIds.add(proposedAlternateId);
} else {
rejectedCmHandleIds.add(cmHandleId);
@@ -140,6 +124,22 @@ public class AlternateIdChecker {
return rejectedCmHandleIds;
}
+ private boolean isProposedAlternateIdAcceptable(final String proposedAlternateId, final Operation operation,
+ final Set<String> acceptedAlternateIds, final String cmHandleId) {
+ if (StringUtils.isEmpty(proposedAlternateId)) {
+ return true;
+ }
+ if (acceptedAlternateIds.contains(proposedAlternateId)) {
+ log.warn("Alternate id update ignored, cannot update cm handle {}, alternate id is already "
+ + "assigned to a different cm handle (in this batch)", cmHandleId);
+ return false;
+ }
+ if (Operation.CREATE.equals(operation)) {
+ return canApplyAlternateId(cmHandleId, NO_CURRENT_ALTERNATE_ID, proposedAlternateId);
+ }
+ return canApplyAlternateId(cmHandleId, proposedAlternateId);
+ }
+
private boolean alternateIdAlreadyInDb(final String alternateId) {
try {
inventoryPersistence.getCmHandleDataNodeByAlternateId(alternateId);
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java
index 3954142976..07b92892a9 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java
@@ -56,6 +56,7 @@ public class YangDataConverter {
ncmpServiceCmHandle.setCompositeState(yangModelCmHandle.getCompositeState());
ncmpServiceCmHandle.setModuleSetTag(yangModelCmHandle.getModuleSetTag());
ncmpServiceCmHandle.setAlternateId(yangModelCmHandle.getAlternateId());
+ ncmpServiceCmHandle.setDataProducerIdentifier(yangModelCmHandle.getDataProducerIdentifier());
setDmiProperties(dmiProperties, ncmpServiceCmHandle);
setPublicProperties(publicProperties, ncmpServiceCmHandle);
return ncmpServiceCmHandle;
@@ -89,7 +90,8 @@ public class YangDataConverter {
(String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"),
ncmpServiceCmHandle,
(String) cmHandleDataNode.getLeaves().get("module-set-tag"),
- (String) cmHandleDataNode.getLeaves().get("alternate-id")
+ (String) cmHandleDataNode.getLeaves().get("alternate-id"),
+ (String) cmHandleDataNode.getLeaves().get("data-producer-identifier")
);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java
index f13c842b25..a8b4e286b6 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java
@@ -45,7 +45,6 @@ import org.onap.cps.ncmp.api.impl.utils.context.CpsApplicationContext;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.models.DataOperationDefinition;
import org.onap.cps.ncmp.api.models.DataOperationRequest;
-import org.springframework.scheduling.annotation.Async;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -123,7 +122,6 @@ public class ResourceDataOperationRequestUtils {
* @param requestId unique identifier per request
* @param cmHandleIdsPerResponseCodesPerOperation list of cm handle ids per operation with response code
*/
- @Async
public static void publishErrorMessageToClientTopic(final String clientTopic,
final String requestId,
final MultiValueMap<DmiDataOperation,
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
index b2758d9d5f..2ca2b2eb0d 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
@@ -70,6 +70,9 @@ public class YangModelCmHandle {
@JsonProperty("alternate-id")
private String alternateId;
+ @JsonProperty("data-producer-identifier")
+ private String dataProducerIdentifier;
+
@JsonProperty("additional-properties")
private List<Property> dmiProperties;
@@ -95,6 +98,7 @@ public class YangModelCmHandle {
original.getPublicProperties() == null ? null : new ArrayList<>(original.getPublicProperties());
copy.moduleSetTag = original.getModuleSetTag();
copy.alternateId = original.getAlternateId();
+ copy.dataProducerIdentifier = original.getDataProducerIdentifier();
return copy;
}
@@ -105,6 +109,9 @@ public class YangModelCmHandle {
* @param dmiDataServiceName dmi data service name
* @param dmiModelServiceName dmi model service name
* @param ncmpServiceCmHandle the cm handle
+ * @param moduleSetTag moduleSetTag
+ * @param alternateId alternateId
+ * @param dataProducerIdentifier dataProducerIdentifier
* @return instance of yangModelCmHandle
*/
public static YangModelCmHandle toYangModelCmHandle(final String dmiServiceName,
@@ -112,7 +119,8 @@ public class YangModelCmHandle {
final String dmiModelServiceName,
final NcmpServiceCmHandle ncmpServiceCmHandle,
final String moduleSetTag,
- final String alternateId) {
+ final String alternateId,
+ final String dataProducerIdentifier) {
final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle();
yangModelCmHandle.setId(ncmpServiceCmHandle.getCmHandleId());
yangModelCmHandle.setDmiServiceName(dmiServiceName);
@@ -120,6 +128,8 @@ public class YangModelCmHandle {
yangModelCmHandle.setDmiModelServiceName(dmiModelServiceName);
yangModelCmHandle.setModuleSetTag(moduleSetTag == null ? StringUtils.EMPTY : moduleSetTag);
yangModelCmHandle.setAlternateId(alternateId == null ? StringUtils.EMPTY : alternateId);
+ yangModelCmHandle.setDataProducerIdentifier(
+ dataProducerIdentifier == null ? StringUtils.EMPTY : dataProducerIdentifier);
yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getDmiProperties()));
yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(
ncmpServiceCmHandle.getPublicProperties()));
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmResourceAddress.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmResourceAddress.java
new file mode 100644
index 0000000000..21d82fcf56
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmResourceAddress.java
@@ -0,0 +1,25 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.api.models;
+
+public record CmResourceAddress(String datastoreName, String cmHandleId, String resourceIdentifier) {
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java
index 4989878975..676eebc4d6 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation
+ * Copyright (C) 2021-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,4 +60,7 @@ public class NcmpServiceCmHandle {
@JsonSetter(nulls = Nulls.AS_EMPTY)
private String alternateId;
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private String dataProducerIdentifier;
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
index 01bfc2b5d4..d0d63ab8eb 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
@@ -34,8 +34,8 @@ import org.springframework.stereotype.Service;
@Service
public class InventoryModelLoader extends AbstractModelLoader {
- private static final String NEW_MODEL_FILE_NAME = "dmi-registry@2023-11-27.yang";
- private static final String NEW_SCHEMA_SET_NAME = "dmi-registry-2023-11-27";
+ private static final String NEW_MODEL_FILE_NAME = "dmi-registry@2024-02-23.yang";
+ private static final String NEW_SCHEMA_SET_NAME = "dmi-registry-2024-02-23";
public InventoryModelLoader(final CpsDataspaceService cpsDataspaceService,
final CpsModuleService cpsModuleService,
diff --git a/cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang b/cps-ncmp-service/src/main/resources/models/dmi-registry@2024-02-23.yang
index 808bbdd1bc..8daf82f336 100644
--- a/cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang
+++ b/cps-ncmp-service/src/main/resources/models/dmi-registry@2024-02-23.yang
@@ -8,6 +8,11 @@ module dmi-registry {
contact "toine.siebelink@est.tech";
+ revision "2024-02-23" {
+ description
+ "Added data-producer-identifier";
+ }
+
revision "2023-11-27" {
description
"Added alternate-id";
@@ -91,6 +96,9 @@ module dmi-registry {
leaf alternate-id {
type string;
}
+ leaf data-producer-identifier {
+ type string;
+ }
list additional-properties {
key "name";
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
index 74016e4c0c..d47be6cd5c 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
@@ -24,6 +24,7 @@
package org.onap.cps.ncmp.api.impl
import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse
+import org.onap.cps.ncmp.api.models.CmResourceAddress
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
@@ -121,35 +122,27 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
>> { new ResponseEntity<>(HttpStatus.CREATED) }
}
- def 'Get resource data for pass-through operational from DMI.'() {
+ def 'Get resource data for from DMI.'() {
given: 'cpsDataService returns valid data node'
mockDataNode()
+ and: 'some cm resource address'
+ def cmResourceAddress = new CmResourceAddress('some datastore','some CM Handle', 'some resource Id')
and: 'get resource data from DMI is called'
- mockDmiDataOperations.getResourceDataFromDmi(PASSTHROUGH_OPERATIONAL.datastoreName,'testCmHandle', 'testResourceId', OPTIONS_PARAM, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER) >>
+ mockDmiDataOperations.getResourceDataFromDmi(cmResourceAddress, OPTIONS_PARAM, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER) >>
new ResponseEntity<>('dmi-response', HttpStatus.OK)
- when: 'get resource data operational for cm-handle is called'
- def response = objectUnderTest.getResourceDataForCmHandle(PASSTHROUGH_OPERATIONAL.datastoreName, 'testCmHandle', 'testResourceId', OPTIONS_PARAM, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER)
+ when: 'get resource data operational for the given cm resource address is called'
+ def response = objectUnderTest.getResourceDataForCmHandle(cmResourceAddress, OPTIONS_PARAM, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER)
then: 'DMI returns a json response'
assert response == 'dmi-response'
}
- def 'Get resource data for pass-through running from DMI.'() {
- given: 'cpsDataService returns valid data node'
- mockDataNode()
- and: 'DMI returns valid response and data'
- mockDmiDataOperations.getResourceDataFromDmi(PASSTHROUGH_RUNNING.datastoreName, 'testCmHandle', 'testResourceId', OPTIONS_PARAM, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER) >>
- new ResponseEntity<>('{dmi-response}', HttpStatus.OK)
- when: 'get resource data is called'
- def response = objectUnderTest.getResourceDataForCmHandle(PASSTHROUGH_RUNNING.datastoreName, 'testCmHandle', 'testResourceId', OPTIONS_PARAM, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER)
- then: 'get resource data returns expected response'
- assert response == '{dmi-response}'
- }
-
def 'Get resource data for operational (cached) data.'() {
given: 'CPS Data service returns some object(s)'
mockCpsDataService.getDataNodes(OPERATIONAL.datastoreName, 'testCmHandle', 'testResourceId', FetchDescendantsOption.OMIT_DESCENDANTS) >> ['First Object', 'other Object']
+ and: 'a cm resource address for the same datastore, cm handle and resource id'
+ def cmResourceAddress = new CmResourceAddress(OPERATIONAL.datastoreName, 'testCmHandle', 'testResourceId')
when: 'get resource data is called'
- def response = objectUnderTest.getResourceDataForCmHandle(OPERATIONAL.datastoreName, 'testCmHandle', 'testResourceId', FetchDescendantsOption.OMIT_DESCENDANTS)
+ def response = objectUnderTest.getResourceDataForCmHandle(cmResourceAddress, FetchDescendantsOption.OMIT_DESCENDANTS)
then: 'get resource data returns teh first object from the data service'
assert response == 'First Object'
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
index cbed4177bd..260772714a 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
@@ -22,6 +22,10 @@
package org.onap.cps.ncmp.api.impl
+import ch.qos.logback.classic.Level
+import ch.qos.logback.classic.Logger
+import ch.qos.logback.classic.spi.ILoggingEvent
+import ch.qos.logback.core.read.ListAppender
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.api.CpsDataService
import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence
@@ -32,6 +36,7 @@ import org.onap.cps.spi.exceptions.DataValidationException
import org.onap.cps.spi.model.DataNode
import org.onap.cps.spi.model.DataNodeBuilder
import org.onap.cps.utils.JsonObjectMapper
+import org.slf4j.LoggerFactory
import spock.lang.Specification
import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND
@@ -49,12 +54,21 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
def mockAlternateIdChecker = Mock(AlternateIdChecker)
def objectUnderTest = new NetworkCmProxyDataServicePropertyHandler(mockInventoryPersistence, mockCpsDataService, jsonObjectMapper, mockAlternateIdChecker)
+ def logger = Spy(ListAppender<ILoggingEvent>)
- def setup() {
+ void setup() {
+ def setupLogger = ((Logger) LoggerFactory.getLogger(NetworkCmProxyDataServicePropertyHandler.class))
+ setupLogger.addAppender(logger)
+ setupLogger.setLevel(Level.DEBUG)
+ logger.start()
// Always accept all alternate IDs
mockAlternateIdChecker.getIdsOfCmHandlesWithRejectedAlternateId(*_) >> []
}
+ void cleanup() {
+ ((Logger) LoggerFactory.getLogger(NetworkCmProxyDataServicePropertyHandler.class)).detachAndStopAllAppenders()
+ }
+
def static cmHandleId = 'myHandle1'
def static cmHandleXpath = "/dmi-registry/cm-handles[@id='${cmHandleId}']"
@@ -223,6 +237,42 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
assert response[0].cmHandle == cmHandleId
}
+ def 'Update CM Handle data producer identifier from #scenario'() {
+ given: 'an existing cm handle with no data producer identifier'
+ DataNode existingCmHandleDataNode = new DataNode(xpath: cmHandleXpath, leaves: ['id': 'cmHandleId','data-producer-identifier': oldDataProducerIdentifier])
+ and: 'an update request with a new data producer identifier'
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dataProducerIdentifier: 'someDataProducerIdentifier')
+ when: 'data producer identifier updated'
+ objectUnderTest.updateDataProducerIdentifier(existingCmHandleDataNode, ncmpServiceCmHandle)
+ then: 'the update node leaves method is invoked once'
+ 1 * mockCpsDataService.updateNodeLeaves('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', _, _) >> { args ->
+ assert args[3].contains('someDataProducerIdentifier')
+ }
+ and: 'correct information is logged'
+ def lastLoggingEvent = logger.list[0]
+ assert lastLoggingEvent.level == Level.DEBUG
+ assert lastLoggingEvent.formattedMessage.contains('Updating data-producer-identifier')
+ where: 'the following scenarios are attempted'
+ scenario | oldDataProducerIdentifier
+ 'null to something' | null
+ 'blank to something' | ''
+ }
+
+ def 'Update CM Handle data producer identifier from some data producer identifier to another data producer identifier'() {
+ given: 'an existing cm handle with a data producer identifier'
+ DataNode existingCmHandleDataNode = new DataNode(xpath: cmHandleXpath, leaves: ['id': 'cmHandleId', 'data-producer-identifier': 'someDataProducerIdentifier'])
+ and: 'an update request with a new data producer identifier'
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dataProducerIdentifier: 'someNewDataProducerIdentifier')
+ when: 'update data producer identifier is called with the update request'
+ objectUnderTest.updateDataProducerIdentifier(existingCmHandleDataNode, ncmpServiceCmHandle)
+ then: 'the update node leaves method is not invoked'
+ 0 * mockCpsDataService.updateNodeLeaves(*_)
+ and: 'correct information is logged'
+ def lastLoggingEvent = logger.list[0]
+ assert lastLoggingEvent.level == Level.WARN
+ assert lastLoggingEvent.formattedMessage.contains('Unable to update dataProducerIdentifier')
+ }
+
def convertToProperties(expectedPropertiesAfterUpdateAsMap) {
def properties = [].withDefault { [:] }
expectedPropertiesAfterUpdateAsMap.forEach(property ->
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy
index 3b1709d802..6d09df0d44 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy
@@ -69,14 +69,14 @@ class SynchronizationCacheConfigSpec extends Specification {
def dataSyncSemaphoresConfig = Hazelcast.getHazelcastInstanceByName('dataSyncSemaphores').config
def dataSyncSemaphoresMapConfig = dataSyncSemaphoresConfig.mapConfigs.get('dataSyncSemaphoresConfig')
expect: 'system created instance with correct config of Module Sync Work Queue'
- assert moduleSyncDefaultWorkQueueConfig.backupCount == 3
- assert moduleSyncDefaultWorkQueueConfig.asyncBackupCount == 3
+ assert moduleSyncDefaultWorkQueueConfig.backupCount == 1
+ assert moduleSyncDefaultWorkQueueConfig.asyncBackupCount == 0
and: 'Module Sync Started Cm Handle Map has the correct settings'
- assert moduleSyncStartedOnCmHandlesMapConfig.backupCount == 3
- assert moduleSyncStartedOnCmHandlesMapConfig.asyncBackupCount == 3
+ assert moduleSyncStartedOnCmHandlesMapConfig.backupCount == 1
+ assert moduleSyncStartedOnCmHandlesMapConfig.asyncBackupCount == 0
and: 'Data Sync Semaphore Map has the correct settings'
- assert dataSyncSemaphoresMapConfig.backupCount == 3
- assert dataSyncSemaphoresMapConfig.asyncBackupCount == 3
+ assert dataSyncSemaphoresMapConfig.backupCount == 1
+ assert dataSyncSemaphoresMapConfig.asyncBackupCount == 0
and: 'all instances are part of same cluster'
def testClusterName = 'cps-and-ncmp-test-caches'
assert moduleSyncWorkQueueConfig.clusterName == testClusterName
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy
index 3eff96d79a..c213ab626e 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfigSpec.groovy
@@ -62,8 +62,8 @@ class TrustLevelCacheConfigSpec extends Specification {
when: 'retrieving the map config for trustLevel'
def mapConfig = cacheConfig.mapConfigs.get(hazelcastMapConfigName)
then: 'the map config has the correct backup counts'
- assert mapConfig.backupCount == 3
- assert mapConfig.asyncBackupCount == 3
+ assert mapConfig.backupCount == 1
+ assert mapConfig.asyncBackupCount == 0
where: 'the following caches are used'
scenario | hazelcastInstanceName | hazelcastMapConfigName
'cmhandle map' | 'hazelcastInstanceTrustLevelPerCmHandleMap' | 'trustLevelPerCmHandleCacheConfig'
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionNcmpOutEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionNcmpOutEventMapperSpec.groovy
new file mode 100644
index 0000000000..93bb480b45
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionNcmpOutEventMapperSpec.groovy
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.api.impl.events.cmsubscription.mapper
+
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.CmNotificationSubscriptionStatus
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionDetails
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionPredicate
+import org.onap.cps.ncmp.api.impl.operations.DatastoreType
+import spock.lang.Specification
+
+class CmNotificationSubscriptionNcmpOutEventMapperSpec extends Specification {
+
+ static Map<String, DmiCmNotificationSubscriptionDetails> dmiCmNotificationSubscriptionDetailsMap
+
+ def objectUnderTest = new CmNotificationSubscriptionNcmpOutEventMapper()
+
+ def setup() {
+ def dmiCmNotificationSubscriptionPredicateA = new DmiCmNotificationSubscriptionPredicate(['ch-A'] as Set, DatastoreType.PASSTHROUGH_RUNNING, ['/a'] as Set)
+ def dmiCmNotificationSubscriptionPredicateB = new DmiCmNotificationSubscriptionPredicate(['ch-B'] as Set, DatastoreType.PASSTHROUGH_OPERATIONAL, ['/b'] as Set)
+ def dmiCmNotificationSubscriptionPredicateC = new DmiCmNotificationSubscriptionPredicate(['ch-C'] as Set, DatastoreType.PASSTHROUGH_OPERATIONAL, ['/c'] as Set)
+ dmiCmNotificationSubscriptionDetailsMap = ['dmi-1': new DmiCmNotificationSubscriptionDetails([dmiCmNotificationSubscriptionPredicateA], CmNotificationSubscriptionStatus.PENDING),
+ 'dmi-2': new DmiCmNotificationSubscriptionDetails([dmiCmNotificationSubscriptionPredicateB], CmNotificationSubscriptionStatus.ACCEPTED),
+ 'dmi-3': new DmiCmNotificationSubscriptionDetails([dmiCmNotificationSubscriptionPredicateC], CmNotificationSubscriptionStatus.REJECTED)
+ ]
+ }
+
+ def 'Check for Cm Notification Subscription Outgoing event mapping'() {
+ when: 'we try to map the event to send it to client'
+ def result = objectUnderTest.toCmNotificationSubscriptionNcmpOutEvent('test-subscription', dmiCmNotificationSubscriptionDetailsMap)
+ then: 'event is mapped correctly for the subscription'
+ result.data.subscriptionId == 'test-subscription'
+ and: 'the cm handle ids are part of correct list'
+ result.data.pendingTargets == ['ch-A']
+ result.data.acceptedTargets == ['ch-B']
+ result.data.rejectedTargets == ['ch-C']
+ }
+}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy
index b7c3b873fc..bef2963cff 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy
@@ -174,18 +174,20 @@ class LcmEventsCreatorSpec extends Specification {
assert result.eventId != null
}
- def 'Map the LcmEvent for alternate IDs when #scenario'() {
- given: 'NCMP cm handle details with current and old alternate IDs'
- def existingNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: existingAlternateId, compositeState: new CompositeState(dataSyncEnabled: false))
- def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: targetAlternateId, compositeState: new CompositeState(dataSyncEnabled: false))
+ def 'Map the LcmEvent for alternate ID, data producer identifier, and module set tag when they contain #scenario'() {
+ given: 'NCMP cm handle details with current and old values for alternate ID, module set tag, and data producer identifier'
+ def existingNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: existingAlternateId, moduleSetTag: existingModuleSetTag, dataProducerIdentifier: existingDataProducerIdentifier, compositeState: new CompositeState(dataSyncEnabled: false))
+ def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: targetAlternateId, moduleSetTag: targetModuleSetTag, dataProducerIdentifier: targetDataProducerIdentifier, compositeState: new CompositeState(dataSyncEnabled: false))
when: 'the event is populated'
def result = objectUnderTest.populateLcmEvent(cmHandleId, targetNcmpServiceCmHandle, existingNcmpServiceCmHandle)
- then: 'the alternate ID is present or is an empty string in the payload'
- assert result.event.alternateId == expectedEventAlternateId
- where: 'the following alternate IDs are provided'
- scenario | existingAlternateId | targetAlternateId || expectedEventAlternateId
- 'same new and old alternate ID' | 'someAlternateId' | 'someAlternateId' || 'someAlternateId'
- 'blank new and old alternate ID' | '' | '' || ''
- 'new alternate id and blank old alternate ID' | '' | 'someAlternateId' || 'someAlternateId'
+ then: 'the alternate ID, module set tag, and data producer identifier are present or are an empty string in the payload'
+ assert result.event.alternateId == targetAlternateId
+ assert result.event.moduleSetTag == targetModuleSetTag
+ assert result.event.dataProducerIdentifier == targetDataProducerIdentifier
+ where: 'the following values are provided for the alternate ID, module set tag, and data producer identifier'
+ scenario | existingAlternateId | targetAlternateId | existingModuleSetTag | targetModuleSetTag | existingDataProducerIdentifier | targetDataProducerIdentifier
+ 'same target and existing values' | 'someAlternateId' | 'someAlternateId' | 'someModuleSetTag' | 'someModuleSetTag' | 'someDataProducerIdentifier' | 'someDataProducerIdentifier'
+ 'blank target and existing values' | '' | '' | '' | '' | '' | ''
+ 'new target value and blank existing values' | '' | 'someAlternateId' | '' | 'someAlternateId' | '' | 'someDataProducerIdentifier'
}
} \ No newline at end of file
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
index 0c60e88772..cb933fafbe 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
@@ -64,7 +64,7 @@ class ModuleSyncServiceSpec extends Specification {
def ncmpServiceCmHandle = new NcmpServiceCmHandle()
ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withCmHandleState(CmHandleState.ADVISED).build())
ncmpServiceCmHandle.cmHandleId = 'ch-1'
- def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, moduleSetTag, '')
+ def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, moduleSetTag, '', '')
and: 'DMI operations returns some module references'
def moduleReferences = [ new ModuleReference('module1','1'), new ModuleReference('module2','2') ]
mockDmiModelOperations.getModuleReferences(yangModelCmHandle) >> moduleReferences
@@ -93,7 +93,7 @@ class ModuleSyncServiceSpec extends Specification {
ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withLockReason(MODULE_UPGRADE, 'Upgrade to ModuleSetTag: tag-1').build())
def dmiServiceName = 'some service name'
ncmpServiceCmHandle.cmHandleId = 'upgraded-ch'
- def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle,'tag-1', '')
+ def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle,'tag-1', '', '')
and: 'some module references'
def moduleReferences = [ new ModuleReference('module1','1') ]
and: 'DMI operations returns some module references for upgraded cm handle'
@@ -127,7 +127,7 @@ class ModuleSyncServiceSpec extends Specification {
ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder()
.withLockReason(MODULE_UPGRADE, 'Upgrade to ModuleSetTag: targetModuleSetTag').build())
ncmpServiceCmHandle.setCmHandleId('cmHandleId-1')
- def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, 'targetModuleSetTag', '')
+ def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, 'targetModuleSetTag', '', '')
mockCmHandleQueries.cmHandleHasState('cmHandleId-1', CmHandleState.READY) >> true
and: 'the module service returns some module references'
def moduleReferences = [new ModuleReference('module1', '1'), new ModuleReference('module2', '2')]
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
index 7d8ac7485b..eb6c7a0f48 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
@@ -21,15 +21,6 @@
package org.onap.cps.ncmp.api.impl.operations
-import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent
-import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_OPERATIONAL
-import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING
-import static org.onap.cps.ncmp.api.impl.operations.OperationType.CREATE
-import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ
-import static org.onap.cps.ncmp.api.impl.operations.OperationType.UPDATE
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNABLE_TO_READ_RESOURCE_DATA
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.DMI_SERVICE_NOT_RESPONDING
-
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.events.EventsPublisher
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration
@@ -37,19 +28,29 @@ import org.onap.cps.ncmp.api.impl.exception.HttpClientRequestException
import org.onap.cps.ncmp.api.impl.utils.DmiServiceUrlBuilder
import org.onap.cps.ncmp.api.impl.utils.context.CpsApplicationContext
import org.onap.cps.ncmp.api.models.DataOperationRequest
+import org.onap.cps.ncmp.api.models.CmResourceAddress
import org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.test.context.ContextConfiguration
-import org.springframework.http.HttpStatus
import spock.lang.Shared
-import spock.util.concurrent.PollingConditions
+
import java.util.concurrent.TimeoutException
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.DMI_SERVICE_NOT_RESPONDING
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNABLE_TO_READ_RESOURCE_DATA
+import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent
+import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_OPERATIONAL
+import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING
+import static org.onap.cps.ncmp.api.impl.operations.OperationType.CREATE
+import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ
+import static org.onap.cps.ncmp.api.impl.operations.OperationType.UPDATE
+
@SpringBootTest
@ContextConfiguration(classes = [EventsPublisher, CpsApplicationContext, NcmpConfiguration.DmiProperties, DmiDataOperations])
class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
@@ -81,8 +82,8 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
mockDmiRestClient.postOperationWithJsonData(expectedUrl, expectedJson, READ, NO_AUTH_HEADER) >> responseFromDmi
dmiServiceUrlBuilder.getDmiDatastoreUrl(_, _) >> expectedUrl
when: 'get resource data is invoked'
- def result = objectUnderTest.getResourceDataFromDmi(dataStore.datastoreName, cmHandleId, resourceIdentifier,
- options, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER)
+ def cmResourceAddress = new CmResourceAddress(dataStore.datastoreName, cmHandleId, resourceIdentifier)
+ def result = objectUnderTest.getResourceDataFromDmi(cmResourceAddress, options, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER)
then: 'the result is the response from the DMI service'
assert result == responseFromDmi
where: 'the following parameters are used'
@@ -107,18 +108,10 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
def expectedBatchRequestAsJson = '{"operations":[{"operation":"read","operationId":"operational-14","datastore":"ncmp-datastore:passthrough-operational","options":"some option","resourceIdentifier":"some resource identifier","cmHandles":[{"id":"some-cm-handle","cmHandleProperties":{"prop1":"val1"}}]}]}'
mockDmiRestClient.postOperationWithJsonData(expectedDmiBatchResourceDataUrl, _, READ.operationName, NO_AUTH_HEADER) >> responseFromDmi
dmiServiceUrlBuilder.getDataOperationRequestUrl(_, _) >> expectedDmiBatchResourceDataUrl
- and: ' a flag to track the post operation call'
- def postOperationWithJsonDataMethodCalled = false
- and: 'the (mocked) dmi rest client will use the flag to indicate it is called and capture the request body'
- mockDmiRestClient.postOperationWithJsonData(expectedDmiBatchResourceDataUrl, expectedBatchRequestAsJson, READ, null) >> {
- postOperationWithJsonDataMethodCalled = true
- }
when: 'get resource data for group of cm handles are invoked'
objectUnderTest.requestResourceDataFromDmi('my-topic-name', dataOperationRequest, 'requestId', NO_AUTH_HEADER)
- then: 'validate the post operation was called and ncmp generated dmi request body json args'
- new PollingConditions().within(1) {
- assert postOperationWithJsonDataMethodCalled == true
- }
+ then: 'the post operation was called and ncmp generated dmi request body json args'
+ 1 * mockDmiRestClient.postOperationWithJsonData(expectedDmiBatchResourceDataUrl, expectedBatchRequestAsJson, READ, NO_AUTH_HEADER)
}
def 'Execute (async) data operation from DMI service for #scenario.'() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy
index ae17c56ef3..56485fbf94 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy
@@ -24,8 +24,6 @@ package org.onap.cps.ncmp.api.impl.operations
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration
-import org.onap.cps.ncmp.api.impl.executor.TaskExecutor
-import org.onap.cps.ncmp.api.impl.utils.DmiServiceNameOrganizer
import org.onap.cps.spi.model.ModuleReference
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
@@ -36,7 +34,7 @@ import org.springframework.http.ResponseEntity
import org.springframework.test.context.ContextConfiguration
import spock.lang.Shared
-import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ
+import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ
@SpringBootTest
@ContextConfiguration(classes = [NcmpConfiguration.DmiProperties, DmiModelOperations])
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/AlternateIdCheckerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/AlternateIdCheckerSpec.groovy
index 0eabaa1d28..1e843676be 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/AlternateIdCheckerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/AlternateIdCheckerSpec.groovy
@@ -80,7 +80,8 @@ class AlternateIdCheckerSpec extends Specification {
assert result == expectedRejectedCmHandleIds
where: 'the following alternate ids are used'
scenario | alt1 | alt2 | altAlreadyInDb || expectedRejectedCmHandleIds
- 'no alternate ids' | '' | '' | ['dont matter'] || []
+ 'blank alternate ids' | '' | '' | ['dont matter'] || []
+ 'null alternate ids' | null | null | ['dont matter'] || []
'new alternate ids' | 'fdn1' | 'fdn2' | ['other fdn'] || []
'one already used alternate id' | 'fdn1' | 'fdn2' | ['fdn1'] || ['ch-1']
'duplicate alternate id in batch' | 'fdn1' | 'fdn1' | ['dont matter'] || ['ch-2']
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
index c83a540a37..fbf2c3d78d 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation
+ * Copyright (C) 2022-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import spock.lang.Specification
class DmiServiceUrlBuilderSpec extends Specification {
static YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('dmiServiceName',
- 'dmiDataServiceName', 'dmiModuleServiceName', new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id'),'my-module-set-tag', 'my-alternate-id')
+ 'dmiDataServiceName', 'dmiModuleServiceName', new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id'),'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier')
NcmpConfiguration.DmiProperties dmiProperties = new NcmpConfiguration.DmiProperties()
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy
index 493db8c160..cfc6ffda19 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation
+ * Copyright (C) 2021-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,12 +47,13 @@ class YangModelCmHandleSpec extends Specification {
.withOperationalDataStores(DataStoreSyncState.SYNCHRONIZED, 'some-sync-time').build()
ncmpServiceCmHandle.setCompositeState(compositeState)
when: 'it is converted to a yang model cm handle'
- def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id')
+ def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier')
then: 'the result has the right size'
assert objectUnderTest.dmiProperties.size() == 1
- and: 'the result has the correct values for module set tag and alternate ID'
+ and: 'the result has the correct values for module set tag, alternate ID, and data producer identifier'
assert objectUnderTest.moduleSetTag == 'my-module-set-tag'
assert objectUnderTest.alternateId == 'my-alternate-id'
+ assert objectUnderTest.dataProducerIdentifier == 'my-data-producer-identifier'
and: 'the DMI property in the result has the correct name and value'
assert objectUnderTest.dmiProperties[0].name == 'myDmiProperty'
assert objectUnderTest.dmiProperties[0].value == 'value1'
@@ -67,7 +68,7 @@ class YangModelCmHandleSpec extends Specification {
def 'Resolve DMI service name: #scenario and #requiredService service require.'() {
given: 'a yang model cm handle'
def objectUnderTest = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, dmiDataServiceName,
- dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1'),'', '')
+ dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1'),'', '', '')
expect:
assert objectUnderTest.resolveDmiServiceName(requiredService) == expectedService
where:
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
index a36532761c..cd659bb528 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
@@ -52,7 +52,7 @@ class InventoryModelLoaderSpec extends Specification {
def loggingListAppender
void setup() {
- expectedYangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('dmi-registry@2023-11-27.yang')
+ expectedYangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('dmi-registry@2024-02-23.yang')
logger.setLevel(Level.DEBUG)
loggingListAppender = new ListAppender()
logger.addAppender(loggingListAppender)
@@ -71,9 +71,9 @@ class InventoryModelLoaderSpec extends Specification {
when: 'the application is ready'
objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
then: 'the module service is used to create the new schema set from the correct resource'
- 1 * mockCpsModuleService.createSchemaSet(NCMP_DATASPACE_NAME, 'dmi-registry-2023-11-27', expectedYangResourceToContentMap)
+ 1 * mockCpsModuleService.createSchemaSet(NCMP_DATASPACE_NAME, 'dmi-registry-2024-02-23', expectedYangResourceToContentMap)
and: 'the admin service is used to update the anchor'
- 1 * mockCpsAnchorService.updateAnchorSchemaSet(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'dmi-registry-2023-11-27')
+ 1 * mockCpsAnchorService.updateAnchorSchemaSet(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'dmi-registry-2024-02-23')
and: 'No schema sets are being removed by the module service (yet)'
0 * mockCpsModuleService.deleteSchemaSet(NCMP_DATASPACE_NAME, _, _)
}