summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacade.java65
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacade.java77
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumer.java17
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImpl.java24
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducer.java5
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventPublishingTask.java5
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java5
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacadeSpec.groovy58
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacadeSpec.groovy65
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumerSpec.groovy14
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImplSpec.groovy41
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducerSpec.groovy10
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy7
-rw-r--r--docs/release-notes.rst1
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy6
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy39
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpBearerTokenPassthroughSpec.groovy27
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy41
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleUpgradeSpec.groovy25
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpRestApiSpec.groovy8
-rw-r--r--integration-test/src/test/resources/application.yml4
21 files changed, 124 insertions, 420 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacade.java
deleted file mode 100644
index fbe21267d9..0000000000
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacade.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ============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.impl.cmnotificationsubscription;
-
-import lombok.RequiredArgsConstructor;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventProducer;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventProducer;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_client.NcmpOutEvent;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_dmi.DmiInEvent;
-import org.springframework.stereotype.Component;
-
-@Component
-@RequiredArgsConstructor
-public class EventsFacade {
- private final NcmpOutEventProducer ncmpOutEventProducer;
- private final DmiInEventProducer dmiInEventProducer;
-
- /**
- * Publish the event to the client who requested the subscription with key as subscription id and event is Cloud
- * Event compliant.
- *
- * @param subscriptionId Cm Subscription id
- * @param eventType Type of event
- * @param ncmpOutEvent Cm Notification Subscription Event for the
- * client
- * @param isScheduledEvent Determines if the event is to be scheduled
- * or published now
- */
- public void publishNcmpOutEvent(final String subscriptionId, final String eventType,
- final NcmpOutEvent ncmpOutEvent, final boolean isScheduledEvent) {
- ncmpOutEventProducer.publishNcmpOutEvent(subscriptionId, eventType, ncmpOutEvent, isScheduledEvent);
- }
-
- /**
- * Publish the event to the provided dmi plugin with key as subscription id and the event is in Cloud Event format.
- *
- * @param subscriptionId Cm Subscription id
- * @param dmiPluginName Dmi Plugin Name
- * @param eventType Type of event
- * @param dmiInEvent Cm Notification Subscription event for Dmi
- */
- public void publishDmiInEvent(final String subscriptionId, final String dmiPluginName,
- final String eventType, final DmiInEvent dmiInEvent) {
- dmiInEventProducer.publishDmiInEvent(subscriptionId,
- dmiPluginName, eventType, dmiInEvent);
- }
-}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacade.java
deleted file mode 100644
index e79b4e6441..0000000000
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacade.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ============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.impl.cmnotificationsubscription;
-
-import java.util.List;
-import java.util.Map;
-import lombok.RequiredArgsConstructor;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventMapper;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionDetails;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionPredicate;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventMapper;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_client.NcmpOutEvent;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_dmi.DmiInEvent;
-import org.springframework.stereotype.Component;
-
-@Component
-@RequiredArgsConstructor
-public class MappersFacade {
-
- private final DmiInEventMapper dmiInEventMapper;
- private final NcmpOutEventMapper ncmpOutEventMapper;
-
- /**
- * Mapper to form a request for the DMI Plugin for the Cm Notification Subscription.
- *
- * @param dmiCmSubscriptionPredicates Collection of Cm Notification Subscription predicates
- * @return cm notification subscription dmi in event
- */
- public DmiInEvent toDmiInEvent(
- final List<DmiCmSubscriptionPredicate> dmiCmSubscriptionPredicates) {
- return dmiInEventMapper.toDmiInEvent(dmiCmSubscriptionPredicates);
- }
-
- /**
- * Mapper to form a response for the client for the Cm Notification Subscription.
- *
- * @param subscriptionId Cm Notification Subscription id
- * @param dmiSubscriptionsPerDmi contains CmNotificationSubscriptionDetails per dmi plugin
- * @return CmNotificationSubscriptionNcmpOutEvent to sent back to the client
- */
- public NcmpOutEvent toNcmpOutEvent(final String subscriptionId,
- final Map<String, DmiCmSubscriptionDetails> dmiSubscriptionsPerDmi) {
- return ncmpOutEventMapper.toNcmpOutEvent(subscriptionId,
- dmiSubscriptionsPerDmi);
- }
-
- /**
- * Mapper to form a rejected response for the client for the Cm Notification Subscription Request.
- *
- * @param subscriptionId subscription id
- * @param rejectedTargetFilters list of rejected target filters for the subscription request
- * @return to sent back to the client
- */
- public NcmpOutEvent toNcmpOutEventForRejectedRequest(
- final String subscriptionId, final List<String> rejectedTargetFilters) {
- return ncmpOutEventMapper.toNcmpOutEventForRejectedRequest(
- subscriptionId, rejectedTargetFilters);
- }
-}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumer.java
index 2a45818624..20ccf528ed 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumer.java
@@ -30,11 +30,11 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.onap.cps.ncmp.api.NcmpResponseStatus;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.EventsFacade;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.MappersFacade;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.cache.DmiCacheHandler;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.CmSubscriptionStatus;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionDetails;
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventMapper;
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventProducer;
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.Data;
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.DmiOutEvent;
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_client.NcmpOutEvent;
@@ -47,8 +47,8 @@ import org.springframework.stereotype.Component;
public class DmiOutEventConsumer {
private final DmiCacheHandler dmiCacheHandler;
- private final EventsFacade eventsFacade;
- private final MappersFacade mappersFacade;
+ private final NcmpOutEventProducer ncmpOutEventProducer;
+ private final NcmpOutEventMapper ncmpOutEventMapper;
private static final String CM_SUBSCRIPTION_CORRELATION_ID_SEPARATOR = "#";
@@ -101,12 +101,9 @@ public class DmiOutEventConsumer {
}
private void handleEventsStatusPerDmi(final String subscriptionId, final String eventType) {
- final Map<String, DmiCmSubscriptionDetails> dmiSubscriptionsPerDmi =
- dmiCacheHandler.get(subscriptionId);
- final NcmpOutEvent ncmpOutEvent = mappersFacade.toNcmpOutEvent(subscriptionId,
- dmiSubscriptionsPerDmi);
- eventsFacade.publishNcmpOutEvent(subscriptionId, eventType,
- ncmpOutEvent, false);
+ final Map<String, DmiCmSubscriptionDetails> dmiSubscriptionsPerDmi = dmiCacheHandler.get(subscriptionId);
+ final NcmpOutEvent ncmpOutEvent = ncmpOutEventMapper.toNcmpOutEvent(subscriptionId, dmiSubscriptionsPerDmi);
+ ncmpOutEventProducer.publishNcmpOutEvent(subscriptionId, eventType, ncmpOutEvent, false);
}
private boolean checkStatusCodeAndMessage(final NcmpResponseStatus ncmpResponseStatus,
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImpl.java
index e225b705d7..9d33d25816 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImpl.java
@@ -26,9 +26,9 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.EventsFacade;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.MappersFacade;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.cache.DmiCacheHandler;
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventMapper;
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventProducer;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.CmSubscriptionStatus;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionDetails;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionPredicate;
@@ -44,8 +44,10 @@ public class CmSubscriptionHandlerImpl implements CmSubscriptionHandler {
private final CmSubscriptionPersistenceService cmSubscriptionPersistenceService;
private final CmSubscriptionComparator cmSubscriptionComparator;
- private final MappersFacade mappersFacade;
- private final EventsFacade eventsFacade;
+ private final NcmpOutEventMapper ncmpOutEventMapper;
+ private final DmiInEventMapper dmiInEventMapper;
+ private final NcmpOutEventProducer ncmpOutEventProducer;
+ private final DmiInEventProducer dmiInEventProducer;
private final DmiCacheHandler dmiCacheHandler;
@Override
@@ -67,16 +69,16 @@ public class CmSubscriptionHandlerImpl implements CmSubscriptionHandler {
}
private void scheduleNcmpOutEventResponse(final String subscriptionId, final String eventType) {
- eventsFacade.publishNcmpOutEvent(subscriptionId, eventType, null, true);
+ ncmpOutEventProducer.publishNcmpOutEvent(subscriptionId, eventType, null, true);
}
private void rejectAndPublishCreateRequest(final String subscriptionId, final List<Predicate> predicates) {
final Set<String> subscriptionTargetFilters =
predicates.stream().flatMap(predicate -> predicate.getTargetFilter().stream())
.collect(Collectors.toSet());
- final NcmpOutEvent ncmpOutEvent = mappersFacade.toNcmpOutEventForRejectedRequest(subscriptionId,
+ final NcmpOutEvent ncmpOutEvent = ncmpOutEventMapper.toNcmpOutEventForRejectedRequest(subscriptionId,
new ArrayList<>(subscriptionTargetFilters));
- eventsFacade.publishNcmpOutEvent(subscriptionId, "subscriptionCreateResponse", ncmpOutEvent, false);
+ ncmpOutEventProducer.publishNcmpOutEvent(subscriptionId, "subscriptionCreateResponse", ncmpOutEvent, false);
}
private void handleNewCmSubscription(final String subscriptionId) {
@@ -97,8 +99,8 @@ public class CmSubscriptionHandlerImpl implements CmSubscriptionHandler {
private void publishDmiInEventPerDmi(final String subscriptionId, final String dmiPluginName,
final List<DmiCmSubscriptionPredicate> dmiCmSubscriptionPredicates) {
- final DmiInEvent dmiInEvent = mappersFacade.toDmiInEvent(dmiCmSubscriptionPredicates);
- eventsFacade.publishDmiInEvent(subscriptionId, dmiPluginName,
+ final DmiInEvent dmiInEvent = dmiInEventMapper.toDmiInEvent(dmiCmSubscriptionPredicates);
+ dmiInEventProducer.publishDmiInEvent(subscriptionId, dmiPluginName,
"subscriptionCreateRequest", dmiInEvent);
}
@@ -112,9 +114,9 @@ public class CmSubscriptionHandlerImpl implements CmSubscriptionHandler {
final Map<String, DmiCmSubscriptionDetails> dmiSubscriptionsPerDmi =
dmiCacheHandler.get(subscriptionId);
dmiSubscriptionsPerDmi.forEach((dmiPluginName, dmiSubscriptionDetails) -> {
- final DmiInEvent dmiInEvent = mappersFacade.toDmiInEvent(
+ final DmiInEvent dmiInEvent = dmiInEventMapper.toDmiInEvent(
dmiSubscriptionDetails.getDmiCmSubscriptionPredicates());
- eventsFacade.publishDmiInEvent(subscriptionId, dmiPluginName,
+ dmiInEventProducer.publishDmiInEvent(subscriptionId, dmiPluginName,
"subscriptionDeleteRequest", dmiInEvent);
});
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducer.java
index 92800f4af1..01d720937f 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducer.java
@@ -33,7 +33,6 @@ import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.events.EventsPublisher;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.MappersFacade;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.cache.DmiCacheHandler;
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_client.NcmpOutEvent;
import org.onap.cps.utils.JsonObjectMapper;
@@ -55,7 +54,7 @@ public class NcmpOutEventProducer {
private final EventsPublisher<CloudEvent> eventsPublisher;
private final JsonObjectMapper jsonObjectMapper;
- private final MappersFacade mappersFacade;
+ private final NcmpOutEventMapper ncmpOutEventMapper;
private final DmiCacheHandler dmiCacheHandler;
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
private static final Map<String, ScheduledFuture<?>> scheduledTasksPerSubscriptionId = new ConcurrentHashMap<>();
@@ -88,7 +87,7 @@ public class NcmpOutEventProducer {
private ScheduledFuture<?> scheduleAndPublishNcmpOutEvent(final String subscriptionId, final String eventType) {
final NcmpOutEventPublishingTask ncmpOutEventPublishingTask =
new NcmpOutEventPublishingTask(ncmpOutEventTopic, subscriptionId, eventType, eventsPublisher,
- jsonObjectMapper, mappersFacade, dmiCacheHandler);
+ jsonObjectMapper, ncmpOutEventMapper, dmiCacheHandler);
return scheduledExecutorService.schedule(ncmpOutEventPublishingTask, dmiOutEventTimeoutInMs,
TimeUnit.MILLISECONDS);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventPublishingTask.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventPublishingTask.java
index 5636237566..f8f253d275 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventPublishingTask.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventPublishingTask.java
@@ -27,7 +27,6 @@ import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.events.EventsPublisher;
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.MappersFacade;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.cache.DmiCacheHandler;
import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionDetails;
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_client.NcmpOutEvent;
@@ -42,7 +41,7 @@ public class NcmpOutEventPublishingTask implements Runnable {
private final String eventType;
private final EventsPublisher<CloudEvent> eventsPublisher;
private final JsonObjectMapper jsonObjectMapper;
- private final MappersFacade mappersFacade;
+ private final NcmpOutEventMapper ncmpOutEventMapper;
private final DmiCacheHandler dmiCacheHandler;
/**
@@ -53,7 +52,7 @@ public class NcmpOutEventPublishingTask implements Runnable {
public void run() {
final Map<String, DmiCmSubscriptionDetails> dmiSubscriptionsPerDmi =
dmiCacheHandler.get(subscriptionId);
- final NcmpOutEvent ncmpOutEvent = mappersFacade.toNcmpOutEvent(subscriptionId,
+ final NcmpOutEvent ncmpOutEvent = ncmpOutEventMapper.toNcmpOutEvent(subscriptionId,
dmiSubscriptionsPerDmi);
eventsPublisher.publishCloudEvent(topicName, subscriptionId,
buildAndGetNcmpOutEventAsCloudEvent(jsonObjectMapper, subscriptionId, eventType,
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java
index 7d6677ca38..c1f89b3440 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperations.java
@@ -25,9 +25,7 @@ import static org.onap.cps.ncmp.api.data.models.OperationType.READ;
import static org.onap.cps.ncmp.impl.models.RequiredDmiService.MODEL;
import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -126,8 +124,7 @@ public class DmiModelOperations {
data.add("modules", moduleReferencesAsJson);
final JsonObject jsonRequestObject = new JsonObject();
if (!moduleSetTag.isEmpty()) {
- final JsonElement moduleSetTagAsJson = JsonParser.parseString(moduleSetTag);
- jsonRequestObject.add("moduleSetTag", moduleSetTagAsJson);
+ jsonRequestObject.addProperty("moduleSetTag", moduleSetTag);
}
jsonRequestObject.add("data", data);
jsonRequestObject.add("cmHandleProperties", toJsonObject(dmiProperties));
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacadeSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacadeSpec.groovy
deleted file mode 100644
index bc2df10ce3..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacadeSpec.groovy
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * ============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.impl.cmnotificationsubscription
-
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventProducer
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventProducer
-import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_client.NcmpOutEvent
-import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_dmi.DmiInEvent
-import spock.lang.Specification
-
-class EventsFacadeSpec extends Specification {
-
- def mockCmNotificationSubscriptionNcmpOutEventProducer = Mock(NcmpOutEventProducer)
- def mockCmNotificationSubscriptionDmiInEventProducer = Mock(DmiInEventProducer)
-
- def objectUnderTest = new EventsFacade(mockCmNotificationSubscriptionNcmpOutEventProducer,
- mockCmNotificationSubscriptionDmiInEventProducer)
-
- def 'Publish cm notification subscription ncmp out event'() {
- given: 'an ncmp out event'
- def ncmpOutEvent = new NcmpOutEvent()
- when: 'the method to publish cm notification subscription ncmp out event is called'
- objectUnderTest.publishNcmpOutEvent("some-id",
- "some-event", ncmpOutEvent, true)
- then: 'the parameters is delegated to the correct method once'
- 1 * mockCmNotificationSubscriptionNcmpOutEventProducer.publishNcmpOutEvent(
- "some-id", "some-event", ncmpOutEvent, true)
- }
-
- def 'Publish cm notification subscription dmi in event'() {
- given: 'a dmi in event'
- def dmiInEvent = new DmiInEvent()
- when: 'the method to publish cm notification subscription ncmp out event is called'
- objectUnderTest.publishDmiInEvent("some-id",
- "some-dmi", "some-event", dmiInEvent)
- then: 'the parameters is delegated to the correct method once'
- 1 * mockCmNotificationSubscriptionDmiInEventProducer.publishDmiInEvent("some-id",
- "some-dmi", "some-event", dmiInEvent)
- }
-} \ No newline at end of file
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacadeSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacadeSpec.groovy
deleted file mode 100644
index 79b9ad578f..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacadeSpec.groovy
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ============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.impl.cmnotificationsubscription
-
-
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventMapper
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventMapper
-import spock.lang.Specification
-
-class MappersFacadeSpec extends Specification{
-
- def mockCmNotificationDmiInEventMapper = Mock(DmiInEventMapper)
- def mockCmNotificationNcmpOutEventMapper = Mock(NcmpOutEventMapper)
-
- def objectUnderTest = new MappersFacade(mockCmNotificationDmiInEventMapper,
- mockCmNotificationNcmpOutEventMapper)
-
- def 'Get cm notification subscription DMI in event'() {
- given: 'a list of predicates'
- def testListOfPredicates = []
- when: 'method to create a cm notification subscription dmi in event is called with predicates'
- objectUnderTest.toDmiInEvent(testListOfPredicates)
- then: 'the parameters is delegated to the correct dmi in event mapper method'
- 1 * mockCmNotificationDmiInEventMapper.toDmiInEvent(testListOfPredicates)
- }
-
- def 'Get cm notification subscription ncmp out event'() {
- given: 'a subscription details map'
- def testSubscriptionDetailsMap = [:]
- when: 'method to create cm notification subscription ncmp out event is called with the following parameters'
- objectUnderTest.toNcmpOutEvent("test-id", testSubscriptionDetailsMap)
- then: 'the parameters is delegated to the correct ncmp out event mapper method'
- 1 * mockCmNotificationNcmpOutEventMapper.toNcmpOutEvent("test-id",
- testSubscriptionDetailsMap)
- }
-
- def 'Get cm notification subscription ncmp out event for a rejected request'() {
- given: 'a list of target filters'
- def testRejectedTargetFilters = []
- when: 'method to create cm notification subscription ncmp out event is called with the following parameters'
- objectUnderTest.toNcmpOutEventForRejectedRequest(
- "test-id", testRejectedTargetFilters)
- then: 'the parameters is delegated to the correct ncmp out event mapper method'
- 1 * mockCmNotificationNcmpOutEventMapper.toNcmpOutEventForRejectedRequest(
- "test-id", testRejectedTargetFilters)
- }
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumerSpec.groovy
index 44e24042a8..06003fdcb4 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumerSpec.groovy
@@ -29,9 +29,9 @@ import io.cloudevents.CloudEvent
import io.cloudevents.core.builder.CloudEventBuilder
import org.apache.kafka.clients.consumer.ConsumerRecord
import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.EventsFacade
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.MappersFacade
import org.onap.cps.ncmp.impl.cmnotificationsubscription.cache.DmiCacheHandler
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventMapper
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventProducer
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.Data
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.DmiOutEvent
import org.onap.cps.ncmp.utils.TestUtils
@@ -53,10 +53,10 @@ class DmiOutEventConsumerSpec extends MessagingBaseSpec {
ObjectMapper objectMapper
def mockDmiCacheHandler = Mock(DmiCacheHandler)
- def mockEventsHandler = Mock(EventsFacade)
- def mockMappersHandler = Mock(MappersFacade)
+ def mockNcmpOutEventProducer = Mock(NcmpOutEventProducer)
+ def mockNcmpOutEventMapper = Mock(NcmpOutEventMapper)
- def objectUnderTest = new DmiOutEventConsumer(mockDmiCacheHandler, mockEventsHandler, mockMappersHandler)
+ def objectUnderTest = new DmiOutEventConsumer(mockDmiCacheHandler, mockNcmpOutEventProducer, mockNcmpOutEventMapper)
def logger = Spy(ListAppender<ILoggingEvent>)
void setup() {
@@ -107,9 +107,9 @@ class DmiOutEventConsumerSpec extends MessagingBaseSpec {
and: 'correct number of calls to persist cache'
expectedPersistenceCalls * mockDmiCacheHandler.persistIntoDatabasePerDmi('sub-1','test-dmi-plugin-name')
and: 'correct number of calls to map the ncmp out event'
- 1 * mockMappersHandler.toNcmpOutEvent('sub-1', _)
+ 1 * mockNcmpOutEventMapper.toNcmpOutEvent('sub-1', _)
and: 'correct number of calls to publish the ncmp out event to client'
- 1 * mockEventsHandler.publishNcmpOutEvent('sub-1', 'subscriptionCreateResponse', _, false)
+ 1 * mockNcmpOutEventProducer.publishNcmpOutEvent('sub-1', 'subscriptionCreateResponse', _, false)
where: 'the following parameters are used'
scenario | subscriptionStatus | statusCode || expectedCacheCalls | expectedPersistenceCalls
'Accepted Status' | ACCEPTED | '1' || 1 | 1
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImplSpec.groovy
index caefdeea1d..3f6556d47e 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImplSpec.groovy
@@ -21,9 +21,9 @@
package org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp
import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.EventsFacade
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.MappersFacade
import org.onap.cps.ncmp.impl.cmnotificationsubscription.cache.DmiCacheHandler
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventMapper
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventProducer
import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionDetails
import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionPredicate
import org.onap.cps.ncmp.impl.cmnotificationsubscription.utils.CmSubscriptionPersistenceService
@@ -41,15 +41,17 @@ import static org.onap.cps.ncmp.impl.cmnotificationsubscription.models.CmSubscri
class CmSubscriptionHandlerImplSpec extends Specification {
def jsonObjectMapper = new JsonObjectMapper(new ObjectMapper())
- def mockCmSubscriptionPersistenceService = Mock(CmSubscriptionPersistenceService);
- def mockCmSubscriptionComparator = Mock(CmSubscriptionComparator);
- def mockMappersFacade = Mock(MappersFacade);
- def mockEventsFacade = Mock(EventsFacade);
- def mockDmiCacheHandler = Mock(DmiCacheHandler);
+ def mockCmSubscriptionPersistenceService = Mock(CmSubscriptionPersistenceService)
+ def mockCmSubscriptionComparator = Mock(CmSubscriptionComparator)
+ def mockNcmpOutEventMapper = Mock(NcmpOutEventMapper)
+ def mockDmiInEventMapper = Mock(DmiInEventMapper)
+ def mockNcmpOutEventProducer = Mock(NcmpOutEventProducer)
+ def mockDmiInEventProducer = Mock(DmiInEventProducer)
+ def mockDmiCacheHandler = Mock(DmiCacheHandler)
def objectUnderTest = new CmSubscriptionHandlerImpl(mockCmSubscriptionPersistenceService,
- mockCmSubscriptionComparator, mockMappersFacade,
- mockEventsFacade, mockDmiCacheHandler)
+ mockCmSubscriptionComparator, mockNcmpOutEventMapper, mockDmiInEventMapper,
+ mockNcmpOutEventProducer, mockDmiInEventProducer, mockDmiCacheHandler)
def testDmiSubscriptionsPerDmi = ["dmi-1": new DmiCmSubscriptionDetails([], PENDING)]
@@ -68,17 +70,16 @@ class CmSubscriptionHandlerImplSpec extends Specification {
1 * mockCmSubscriptionComparator.getNewDmiSubscriptionPredicates(_) >> testListOfDeltaPredicates
and: 'the DMI in event mapper returns cm notification subscription event'
def testDmiInEvent = new DmiInEvent()
- 1 * mockMappersFacade
- .toDmiInEvent(testListOfDeltaPredicates) >> testDmiInEvent
+ 1 * mockDmiInEventMapper.toDmiInEvent(testListOfDeltaPredicates) >> testDmiInEvent
when: 'the valid and unique event is consumed'
objectUnderTest.processSubscriptionCreateRequest(subscriptionId, predicates)
then: 'the subscription cache handler is called once'
1 * mockDmiCacheHandler.add('test-id', _)
and: 'the events handler method to publish DMI event is called correct number of times with the correct parameters'
- testDmiSubscriptionsPerDmi.size() * mockEventsFacade.publishDmiInEvent(
+ testDmiSubscriptionsPerDmi.size() * mockDmiInEventProducer.publishDmiInEvent(
"test-id", "dmi-1", "subscriptionCreateRequest", testDmiInEvent)
and: 'we schedule to send the response after configured time from the cache'
- 1 * mockEventsFacade.publishNcmpOutEvent('test-id', 'subscriptionCreateResponse', null, true)
+ 1 * mockNcmpOutEventProducer.publishNcmpOutEvent('test-id', 'subscriptionCreateResponse', null, true)
}
def 'Consume valid and Overlapping Cm Notification Subscription NcmpIn Event'() {
@@ -98,7 +99,7 @@ class CmSubscriptionHandlerImplSpec extends Specification {
and: 'the subscription details are updated in the cache'
1 * mockDmiCacheHandler.updateDmiSubscriptionStatusPerDmi('test-id', _, ACCEPTED)
and: 'we schedule to send the response after configured time from the cache'
- 1 * mockEventsFacade.publishNcmpOutEvent('test-id', 'subscriptionCreateResponse', null, true)
+ 1 * mockNcmpOutEventProducer.publishNcmpOutEvent('test-id', 'subscriptionCreateResponse', null, true)
}
def 'Consume valid and but non-unique CmNotificationSubscription create message'() {
@@ -111,14 +112,14 @@ class CmSubscriptionHandlerImplSpec extends Specification {
def predicates = testEventConsumed.getData().getPredicates()
and: 'the NCMP out in event mapper returns an event for rejected request'
def testNcmpOutEvent = new NcmpOutEvent()
- 1 * mockMappersFacade.toNcmpOutEventForRejectedRequest(
+ 1 * mockNcmpOutEventMapper.toNcmpOutEventForRejectedRequest(
"test-id", _) >> testNcmpOutEvent
when: 'the valid but non-unique event is consumed'
objectUnderTest.processSubscriptionCreateRequest(subscriptionId, predicates)
then: 'the events handler method to publish DMI event is never called'
- 0 * mockEventsFacade.publishDmiInEvent(_, _, _, _)
+ 0 * mockDmiInEventProducer.publishDmiInEvent(_, _, _, _)
and: 'the events handler method to publish NCMP out event is called once'
- 1 * mockEventsFacade.publishNcmpOutEvent('test-id', 'subscriptionCreateResponse', testNcmpOutEvent, false)
+ 1 * mockNcmpOutEventProducer.publishNcmpOutEvent('test-id', 'subscriptionCreateResponse', testNcmpOutEvent, false)
}
def 'Consume valid CmNotificationSubscriptionNcmpInEvent delete message'() {
@@ -135,11 +136,11 @@ class CmSubscriptionHandlerImplSpec extends Specification {
then: 'the subscription cache handler is called once'
1 * mockDmiCacheHandler.add('test-id', predicates)
and: 'the mapper handler to get DMI in event is called once'
- 1 * mockMappersFacade.toDmiInEvent(_)
+ 1 * mockDmiInEventMapper.toDmiInEvent(_)
and: 'the events handler method to publish DMI event is called correct number of times with the correct parameters'
- testDmiSubscriptionsPerDmi.size() * mockEventsFacade.publishDmiInEvent(
+ testDmiSubscriptionsPerDmi.size() * mockDmiInEventProducer.publishDmiInEvent(
'test-id', 'dmi-1', 'subscriptionDeleteRequest', _)
and: 'we schedule to send the response after configured time from the cache'
- 1 * mockEventsFacade.publishNcmpOutEvent('test-id', 'subscriptionDeleteResponse', null, true)
+ 1 * mockNcmpOutEventProducer.publishNcmpOutEvent('test-id', 'subscriptionDeleteResponse', null, true)
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducerSpec.groovy
index f96f3df786..e03682d8c9 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducerSpec.groovy
@@ -3,7 +3,6 @@ package org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.CloudEvent
import org.onap.cps.events.EventsPublisher
-import org.onap.cps.ncmp.impl.cmnotificationsubscription.MappersFacade
import org.onap.cps.ncmp.impl.cmnotificationsubscription.cache.DmiCacheHandler
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_client.Data
import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_client.NcmpOutEvent
@@ -15,11 +14,10 @@ class NcmpOutEventProducerSpec extends Specification {
def mockEventsPublisher = Mock(EventsPublisher)
def jsonObjectMapper = new JsonObjectMapper(new ObjectMapper())
- def mockCmNotificationSubscriptionMappersHandler = Mock(MappersFacade)
- def mockDmiCmNotificationSubscriptionCacheHandler = Mock(DmiCacheHandler)
+ def mockNcmpOutEventMapper = Mock(NcmpOutEventMapper)
+ def mockDmiCacheHandler = Mock(DmiCacheHandler)
- def objectUnderTest = new NcmpOutEventProducer(mockEventsPublisher, jsonObjectMapper,
- mockCmNotificationSubscriptionMappersHandler, mockDmiCmNotificationSubscriptionCacheHandler)
+ def objectUnderTest = new NcmpOutEventProducer(mockEventsPublisher, jsonObjectMapper, mockNcmpOutEventMapper, mockDmiCacheHandler)
def 'Create and #scenario Cm Notification Subscription NCMP out event'() {
given: 'a cm subscription response for the client'
@@ -82,7 +80,7 @@ class NcmpOutEventProducerSpec extends Specification {
}
}
then: 'the cache handler is called once to remove accepted and rejected entries in cache'
- 1 * mockDmiCmNotificationSubscriptionCacheHandler.removeAcceptedAndRejectedDmiSubscriptionEntries(subscriptionId)
+ 1 * mockDmiCacheHandler.removeAcceptedAndRejectedDmiSubscriptionEntries(subscriptionId)
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy
index 1268bc7683..17352977b8 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/DmiModelOperationsSpec.groovy
@@ -170,9 +170,10 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec {
then: 'the result is the response from DMI service'
assert result == [mod1:'some yang source']
where: 'the following Module Set Tags are used'
- scenario | moduleSetTag || expectedModuleSetTagInRequest
- 'Without module set tag' | '' || ''
- 'With module set tag' | 'moduleSetTag1' || '"moduleSetTag":"moduleSetTag1",'
+ scenario | moduleSetTag || expectedModuleSetTagInRequest
+ 'Without module set tag' | '' || ''
+ 'With module set tag' | 'moduleSetTag1' || '"moduleSetTag":"moduleSetTag1",'
+ 'Special characters in module set tag' | 'module:set#tag$2' || '"moduleSetTag":"module:set#tag$2",'
}
def 'Retrieving yang resources from DMI with no module references.'() {
diff --git a/docs/release-notes.rst b/docs/release-notes.rst
index 01735df61e..ce2c028076 100644
--- a/docs/release-notes.rst
+++ b/docs/release-notes.rst
@@ -39,6 +39,7 @@ Release Data
Bug Fixes
---------
3.5.1
+ - `CPS-2302 <https://jira.onap.org/browse/CPS-2302>`_ Fix handling of special characters in moduleSetTag.
Features
--------
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
index 0afdfa1066..6b38936200 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
@@ -133,8 +133,9 @@ abstract class CpsIntegrationSpecBase extends Specification {
static NO_MODULE_SET_TAG = ''
static GENERAL_TEST_DATASPACE = 'generalTestDataspace'
static BOOKSTORE_SCHEMA_SET = 'bookstoreSchemaSet'
+ static MODULE_SYNC_WAIT_TIME_IN_SECONDS = 2
- def static initialized = false
+ static initialized = false
def now = OffsetDateTime.now()
def setup() {
@@ -218,8 +219,7 @@ abstract class CpsIntegrationSpecBase extends Specification {
def registerCmHandle(dmiPlugin, cmHandleId, moduleSetTag) {
def cmHandleToCreate = new NcmpServiceCmHandle(cmHandleId: cmHandleId, moduleSetTag: moduleSetTag)
networkCmProxyInventoryFacade.updateDmiRegistrationAndSyncModule(new DmiPluginRegistration(dmiPlugin: dmiPlugin, createdCmHandles: [cmHandleToCreate]))
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
- new PollingConditions().within(3, () -> {
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
CmHandleState.READY == networkCmProxyInventoryFacade.getCmHandleCompositeState(cmHandleId).cmHandleState
})
}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy
index 6676cb74c2..e77815f5ec 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/DmiDispatcher.groovy
@@ -22,11 +22,11 @@ package org.onap.cps.integration.base
import static org.onap.cps.integration.base.CpsIntegrationSpecBase.readResourceDataFile
-import org.springframework.http.HttpHeaders
import java.util.regex.Matcher
import okhttp3.mockwebserver.Dispatcher
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.RecordedRequest
+import org.springframework.http.HttpHeaders
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
@@ -53,25 +53,40 @@ class DmiDispatcher extends Dispatcher {
static final MODULE_RESOURCES_RESPONSE_TEMPLATE = readResourceDataFile('mock-dmi-responses/moduleResourcesTemplate.json')
def isAvailable = true
-
Map<String, List<String>> moduleNamesPerCmHandleId = [:]
+ def lastAuthHeaderReceived
@Override
MockResponse dispatch(RecordedRequest request) {
if (!isAvailable) {
- return new MockResponse().setResponseCode(HttpStatus.SERVICE_UNAVAILABLE.value())
+ return mockResponse(HttpStatus.SERVICE_UNAVAILABLE)
}
+ if (request.path == '/actuator/health') {
+ return mockResponseWithBody(HttpStatus.OK, '{"status":"UP"}')
+ }
+
+ lastAuthHeaderReceived = request.getHeader('Authorization')
switch (request.path) {
- case ~/^\/dmi\/v1\/ch\/(.*)\/modules$/:
+ // get module references for a CM-handle
+ case ~'^/dmi/v1/ch/(.*)/modules$':
def cmHandleId = Matcher.lastMatcher[0][1]
return getModuleReferencesResponse(cmHandleId)
- case ~/^\/dmi\/v1\/ch\/(.*)\/moduleResources$/:
+ // get module resources for a CM-handle
+ case ~'^/dmi/v1/ch/(.*)/moduleResources$':
def cmHandleId = Matcher.lastMatcher[0][1]
return getModuleResourcesResponse(cmHandleId)
+ // pass-through data operation for a CM-handle
+ case ~'^/dmi/v1/ch/(.*)/data/ds/(.*)$':
+ return mockResponseWithBody(HttpStatus.OK, '{}')
+
+ // legacy pass-through batch data operation
+ case ~'^/dmi/v1/data$':
+ return mockResponseWithBody(HttpStatus.ACCEPTED, '{}')
+
default:
- throw new IllegalArgumentException('Mock DMI does not handle path ' + request.path)
+ throw new IllegalArgumentException('Mock DMI does not implement endpoint ' + request.path)
}
}
@@ -79,14 +94,14 @@ class DmiDispatcher extends Dispatcher {
def moduleReferences = '{"schemas":[' + getModuleNamesForCmHandle(cmHandleId).collect {
MODULE_REFERENCES_RESPONSE_TEMPLATE.replaceAll("<MODULE_NAME>", it)
}.join(',') + ']}'
- return mockOkResponseWithBody(moduleReferences)
+ return mockResponseWithBody(HttpStatus.OK, moduleReferences)
}
private getModuleResourcesResponse(cmHandleId) {
def moduleResources = '[' + getModuleNamesForCmHandle(cmHandleId).collect {
MODULE_RESOURCES_RESPONSE_TEMPLATE.replaceAll("<MODULE_NAME>", it)
}.join(',') + ']'
- return mockOkResponseWithBody(moduleResources)
+ return mockResponseWithBody(HttpStatus.OK, moduleResources)
}
private getModuleNamesForCmHandle(cmHandleId) {
@@ -96,9 +111,13 @@ class DmiDispatcher extends Dispatcher {
return moduleNamesPerCmHandleId.get(cmHandleId)
}
- private static mockOkResponseWithBody(responseBody) {
+ private static mockResponse(status) {
+ return new MockResponse().setResponseCode(status.value())
+ }
+
+ private static mockResponseWithBody(status, responseBody) {
return new MockResponse()
- .setResponseCode(HttpStatus.OK.value())
+ .setResponseCode(status.value())
.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.setBody(responseBody)
}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpBearerTokenPassthroughSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpBearerTokenPassthroughSpec.groovy
index 2a35313f74..664fca82e5 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpBearerTokenPassthroughSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpBearerTokenPassthroughSpec.groovy
@@ -20,13 +20,8 @@
package org.onap.cps.integration.functional
-import okhttp3.mockwebserver.Dispatcher
-import okhttp3.mockwebserver.MockResponse
-import okhttp3.mockwebserver.RecordedRequest
-import org.jetbrains.annotations.NotNull
import org.onap.cps.integration.base.CpsIntegrationSpecBase
import org.springframework.http.HttpHeaders
-import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import spock.util.concurrent.PollingConditions
@@ -40,25 +35,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
class NcmpBearerTokenPassthroughSpec extends CpsIntegrationSpecBase {
- def lastAuthHeaderReceived = null
-
def setup() {
dmiDispatcher.moduleNamesPerCmHandleId['ch-1'] = ['M1', 'M2']
registerCmHandle(DMI_URL, 'ch-1', NO_MODULE_SET_TAG)
-
- mockDmiServer.setDispatcher(new Dispatcher() {
- @Override
- MockResponse dispatch(@NotNull RecordedRequest request) throws InterruptedException {
- if (request.path == '/actuator/health') {
- return new MockResponse()
- .addHeader("Content-Type", MediaType.APPLICATION_JSON).setBody('{"status":"UP"}')
- .setResponseCode(HttpStatus.OK.value())
- } else {
- lastAuthHeaderReceived = request.getHeader('Authorization')
- return new MockResponse().setResponseCode(HttpStatus.OK.value())
- }
- }
- })
}
def cleanup() {
@@ -75,7 +54,7 @@ class NcmpBearerTokenPassthroughSpec extends CpsIntegrationSpecBase {
.andExpect(status().is2xxSuccessful())
then: 'DMI has received request with bearer token'
- lastAuthHeaderReceived == 'Bearer some-bearer-token'
+ assert dmiDispatcher.lastAuthHeaderReceived == 'Bearer some-bearer-token'
where: 'all HTTP operations are applied'
httpMethod << [GET, POST, PUT, PATCH, DELETE]
@@ -91,7 +70,7 @@ class NcmpBearerTokenPassthroughSpec extends CpsIntegrationSpecBase {
.andExpect(status().is2xxSuccessful())
then: 'DMI has received request with no authorization header'
- lastAuthHeaderReceived == null
+ assert dmiDispatcher.lastAuthHeaderReceived == null
where: 'all HTTP operations are applied'
httpMethod << [GET, POST, PUT, PATCH, DELETE]
@@ -115,7 +94,7 @@ class NcmpBearerTokenPassthroughSpec extends CpsIntegrationSpecBase {
then: 'DMI will receive the async request with bearer token'
new PollingConditions().within(3, () -> {
- assert lastAuthHeaderReceived == 'Bearer some-bearer-token'
+ assert dmiDispatcher.lastAuthHeaderReceived == 'Bearer some-bearer-token'
})
}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy
index 0f442a82f1..26782708a5 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy
@@ -64,11 +64,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
and: 'CM-handle is initially in ADVISED state'
assert CmHandleState.ADVISED == objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState
- when: 'module sync runs'
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-
- then: 'CM-handle goes to READY state'
- new PollingConditions().within(3, () -> {
+ and: 'CM-handle goes to READY state after module sync'
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
assert CmHandleState.READY == objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState
})
@@ -96,11 +93,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: DMI_URL, createdCmHandles: [cmHandleToCreate])
objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
- and: 'module sync runs'
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-
then: 'CM-handle goes to LOCKED state with reason MODULE_SYNC_FAILED'
- new PollingConditions().within(3, () -> {
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
def cmHandleCompositeState = objectUnderTest.getCmHandleCompositeState('ch-1')
assert cmHandleCompositeState.cmHandleState == CmHandleState.LOCKED
assert cmHandleCompositeState.lockReason.lockReasonCategory == LockReasonCategory.MODULE_SYNC_FAILED
@@ -124,9 +118,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
def cmHandleToCreate = new NcmpServiceCmHandle(cmHandleId: 'ch-3', moduleSetTag: 'B')
objectUnderTest.updateDmiRegistrationAndSyncModule(new DmiPluginRegistration(dmiPlugin: DMI_URL, createdCmHandles: [cmHandleToCreate]))
- then: 'the CM-handle goes to READY state after module sync'
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
- new PollingConditions().within(3, () -> {
+ then: 'the CM-handle goes to READY state'
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
assert CmHandleState.READY == objectUnderTest.getCmHandleCompositeState('ch-3').cmHandleState
})
@@ -148,10 +141,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
def cmHandlesToCreate = [new NcmpServiceCmHandle(cmHandleId: 'ch-1'), new NcmpServiceCmHandle(cmHandleId: 'ch-2')]
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: DMI_URL, createdCmHandles: cmHandlesToCreate)
objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
- and: 'module sync runs'
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
then: 'CM-handles go to LOCKED state'
- new PollingConditions().within(3, () -> {
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.LOCKED
assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.LOCKED
})
@@ -159,20 +150,18 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
when: 'we wait for LOCKED CM handle retry time (actually just subtract 3 minutes from handles lastUpdateTime)'
overrideCmHandleLastUpdateTime('ch-1', OffsetDateTime.now().minusMinutes(3))
overrideCmHandleLastUpdateTime('ch-2', OffsetDateTime.now().minusMinutes(3))
- and: 'failed CM handles are reset'
- moduleSyncWatchdog.resetPreviouslyFailedCmHandles()
- then: 'CM-handles are ADVISED state'
- assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.ADVISED
- assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.ADVISED
+ then: 'CM-handles go to ADVISED state'
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
+ assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.ADVISED
+ assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.ADVISED
+ })
- when: 'DMI is available for retry'
- dmiDispatcher.isAvailable = true
- and: 'DMI will return expected modules'
+ when: 'DMI will return expected modules'
dmiDispatcher.moduleNamesPerCmHandleId = ['ch-1': ['M1', 'M2'], 'ch-2': ['M1', 'M3']]
- and: 'module sync runs'
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
+ and: 'DMI is available for retry'
+ dmiDispatcher.isAvailable = true
then: 'CM-handles go to READY state'
- new PollingConditions().within(3, () -> {
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.READY
assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.READY
})
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleUpgradeSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleUpgradeSpec.groovy
index 72e798335a..3a08cfd0c6 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleUpgradeSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleUpgradeSpec.groovy
@@ -62,14 +62,11 @@ class NcmpCmHandleUpgradeSpec extends CpsIntegrationSpecBase {
when: 'DMI will return different modules for upgrade: M1 and M3'
dmiDispatcher.moduleNamesPerCmHandleId[CM_HANDLE_ID] = ['M1', 'M3']
- and: 'module sync runs'
- moduleSyncWatchdog.resetPreviouslyFailedCmHandles()
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
then: 'CM-handle goes to READY state'
- new PollingConditions().eventually {
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
assert CmHandleState.READY == objectUnderTest.getCmHandleCompositeState(CM_HANDLE_ID).cmHandleState
- }
+ })
and: 'the CM-handle has expected moduleSetTag'
assert objectUnderTest.getNcmpServiceCmHandle(CM_HANDLE_ID).moduleSetTag == updatedModuleSetTag
@@ -107,14 +104,10 @@ class NcmpCmHandleUpgradeSpec extends CpsIntegrationSpecBase {
then: 'registration gives successful response'
assert dmiPluginRegistrationResponse.upgradedCmHandles == [CmHandleRegistrationResponse.createSuccessResponse(CM_HANDLE_ID)]
- when: 'module sync runs'
- moduleSyncWatchdog.resetPreviouslyFailedCmHandles()
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-
- then: 'CM-handle goes to READY state'
- new PollingConditions().eventually {
+ and: 'CM-handle goes to READY state'
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
assert CmHandleState.READY == objectUnderTest.getCmHandleCompositeState(CM_HANDLE_ID).cmHandleState
- }
+ })
and: 'the CM-handle has expected moduleSetTag'
assert objectUnderTest.getNcmpServiceCmHandle(CM_HANDLE_ID).moduleSetTag == updatedModuleSetTag
@@ -167,16 +160,12 @@ class NcmpCmHandleUpgradeSpec extends CpsIntegrationSpecBase {
objectUnderTest.updateDmiRegistrationAndSyncModule(
new DmiPluginRegistration(dmiPlugin: DMI_URL, upgradedCmHandles: cmHandlesToUpgrade))
- and: 'module sync runs'
- moduleSyncWatchdog.resetPreviouslyFailedCmHandles()
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
-
then: 'CM-handle goes to LOCKED state with reason MODULE_UPGRADE_FAILED'
- new PollingConditions(timeout: 3).eventually {
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
def cmHandleCompositeState = objectUnderTest.getCmHandleCompositeState(CM_HANDLE_ID)
assert cmHandleCompositeState.cmHandleState == CmHandleState.LOCKED
assert cmHandleCompositeState.lockReason.lockReasonCategory == LockReasonCategory.MODULE_UPGRADE_FAILED
- }
+ })
and: 'the CM-handle has same moduleSetTag as before'
assert objectUnderTest.getNcmpServiceCmHandle(CM_HANDLE_ID).moduleSetTag == 'oldTag'
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpRestApiSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpRestApiSpec.groovy
index 5325f1a86e..fbfebabd7f 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpRestApiSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpRestApiSpec.groovy
@@ -40,20 +40,18 @@ class NcmpRestApiSpec extends CpsIntegrationSpecBase {
'ch-2': ['M1', 'M2'],
'ch-3': ['M1', 'M3']
]
- and: 'a POST request is made to register the CM Handles'
+ when: 'a POST request is made to register the CM Handles'
def requestBody = '{"dmiPlugin":"'+DMI_URL+'","createdCmHandles":[{"cmHandle":"ch-1"},{"cmHandle":"ch-2"},{"cmHandle":"ch-3"}]}'
mvc.perform(post('/ncmpInventory/v1/ch').contentType(MediaType.APPLICATION_JSON).content(requestBody))
.andExpect(status().is2xxSuccessful())
- when: 'module sync runs'
- moduleSyncWatchdog.moduleSyncAdvisedCmHandles()
then: 'CM-handles go to READY state'
- new PollingConditions().eventually {
+ new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> {
(1..3).each {
mvc.perform(get('/ncmp/v1/ch/ch-'+it))
.andExpect(status().isOk())
.andExpect(jsonPath('$.state.cmHandleState').value('READY'))
}
- }
+ })
}
def 'Search for CM Handles by module using REST API.'() {
diff --git a/integration-test/src/test/resources/application.yml b/integration-test/src/test/resources/application.yml
index 58e6287955..fefae345e6 100644
--- a/integration-test/src/test/resources/application.yml
+++ b/integration-test/src/test/resources/application.yml
@@ -179,9 +179,9 @@ ncmp:
timers:
advised-modules-sync:
- sleep-time-ms: 100000
+ sleep-time-ms: 1000
locked-modules-sync:
- sleep-time-ms: 300000
+ sleep-time-ms: 1000
cm-handle-data-sync:
sleep-time-ms: 30000
subscription-forwarding: