Remove Mappers and Events Facade 97/138397/1
authormpriyank <priyank.maheshwari@est.tech>
Fri, 5 Jul 2024 11:33:06 +0000 (12:33 +0100)
committermpriyank <priyank.maheshwari@est.tech>
Fri, 5 Jul 2024 11:33:11 +0000 (12:33 +0100)
- Removing Mappers and Events Facade and introducing the normal classes
  that this facade was wrapping
- Corresponding changes in the testware

Issue-ID: CPS-2298
Change-Id: I380d73ff3a9b3bf79633cd91580d6a4dee00a662
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacade.java [deleted file]
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacade.java [deleted file]
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventPublishingTask.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/EventsFacadeSpec.groovy [deleted file]
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/MappersFacadeSpec.groovy [deleted file]
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiOutEventConsumerSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/CmSubscriptionHandlerImplSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventProducerSpec.groovy

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 (file)
index fbe2126..0000000
+++ /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 (file)
index e79b4e6..0000000
+++ /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);
-    }
-}
index 2a45818..20ccf52 100644 (file)
@@ -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,
index e225b70..9d33d25 100644 (file)
@@ -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);
         });
     }
index 92800f4..01d7209 100644 (file)
@@ -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);
     }
index 5636237..f8f253d 100644 (file)
@@ -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/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 (file)
index bc2df10..0000000
+++ /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 (file)
index 79b9ad5..0000000
+++ /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)
-    }
-}
index 44e2404..06003fd 100644 (file)
@@ -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
index caefdee..3f6556d 100644 (file)
@@ -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)
     }
 }
index f96f3df..e03682d 100644 (file)
@@ -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)
     }