aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Anjella Macabuhay <lee.anjella.macabuhay@est.tech>2024-05-07 09:57:09 +0000
committerGerrit Code Review <gerrit@onap.org>2024-05-07 09:57:09 +0000
commit7b935fc1a85db39ffe216f6f53fed21de1bbb11a (patch)
treee48078d23d03ef56ed64d2369bb78c5ad8ce3999
parentaf6c06cf3cc3e5e746c232bd8175ea3b2e19c698 (diff)
parent6c35c5dd0dbfc417a57bad71c22b03f21cb71e5f (diff)
Merge "Schedule response to client"
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java20
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImplSpec.groovy3
2 files changed, 16 insertions, 7 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java
index 395c511af..7872ba0a3 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java
@@ -57,20 +57,26 @@ public class CmNotificationSubscriptionHandlerServiceImpl implements CmNotificat
if (cmNotificationSubscriptionPersistenceService.isUniqueSubscriptionId(subscriptionId)) {
dmiCmNotificationSubscriptionCacheHandler.add(subscriptionId, predicates);
sendSubscriptionCreateRequestToDmi(subscriptionId);
+ scheduleCmNotificationSubscriptionNcmpOutEventResponse(subscriptionId);
} else {
- final Set<String> subscriptionTargetFilters = predicates.stream().flatMap(
- predicate -> predicate.getTargetFilter().stream()).collect(Collectors.toSet());
rejectAndPublishCmNotificationSubscriptionCreateRequest(subscriptionId,
- new ArrayList<>(subscriptionTargetFilters));
+ predicates);
}
}
+ private void scheduleCmNotificationSubscriptionNcmpOutEventResponse(final String subscriptionId) {
+ cmNotificationSubscriptionEventsHandler.publishCmNotificationSubscriptionNcmpOutEvent(subscriptionId,
+ "subscriptionCreateResponse", null, true);
+ }
+
private void rejectAndPublishCmNotificationSubscriptionCreateRequest(final String subscriptionId,
- final List<String> subscriptionTargetFilters) {
+ final List<Predicate> predicates) {
+ final Set<String> subscriptionTargetFilters =
+ predicates.stream().flatMap(predicate -> predicate.getTargetFilter().stream())
+ .collect(Collectors.toSet());
final CmNotificationSubscriptionNcmpOutEvent cmNotificationSubscriptionNcmpOutEvent =
- cmNotificationSubscriptionMappersHandler
- .toCmNotificationSubscriptionNcmpOutEventForRejectedRequest(subscriptionId,
- subscriptionTargetFilters);
+ cmNotificationSubscriptionMappersHandler.toCmNotificationSubscriptionNcmpOutEventForRejectedRequest(
+ subscriptionId, new ArrayList<>(subscriptionTargetFilters));
cmNotificationSubscriptionEventsHandler.publishCmNotificationSubscriptionNcmpOutEvent(subscriptionId,
"subscriptionCreateResponse", cmNotificationSubscriptionNcmpOutEvent, false);
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImplSpec.groovy
index 7d1a1d65f..98b4ee267 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImplSpec.groovy
@@ -72,6 +72,9 @@ class CmNotificationSubscriptionHandlerServiceImplSpec extends Specification{
and: 'the events handler method to publish DMI event is called correct number of times with the correct parameters'
testSubscriptionDetailsMap.size() * mockCmNotificationSubscriptionEventsHandler.publishCmNotificationSubscriptionDmiInEvent(
"test-id", "dmi-1", "subscriptionCreateRequest", testDmiInEvent)
+ and: 'we schedule to send the response after configured time from the cache'
+ 1 * mockCmNotificationSubscriptionEventsHandler.publishCmNotificationSubscriptionNcmpOutEvent(
+ "test-id", "subscriptionCreateResponse", null, true)
}
def 'Consume valid and but non-unique CmNotificationSubscription create message'() {