diff options
author | 2025-03-23 18:53:04 +0000 | |
---|---|---|
committer | 2025-03-25 14:31:02 +0000 | |
commit | a0165fd30cd372f5c166057a34ab931c716c92ac (patch) | |
tree | dc91f49edb746c9aedcf121fc146817da16669f5 | |
parent | b3279eefb5ad55054e6098b266686def8367286d (diff) |
Refactor Consumers/Producers based on agreed format
- agreed: consumer over producer
- agreed: 'Consumer' is named based on what it consumes
- agreed: no 'Publisher' in names, use producer instead
- AsyncRestRequestResponseEventConsumer to DmiAsyncRequestResponseEventConsumer
- LcmEventsService to LcmEventsProducer
- CmAvcEventPublisher to InventoryEventProducer
- CpsDataUpdateEventsService to CpsDataUpdateEventsProducer
- see https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16514237/CPS+Data+Notifications+Overview?force_transition=43836314-5d80-4b83-b9f4-7880332d79a4 for more info
Issue-ID: CPS-2597
Change-Id: Iaafb435fcf985372d4858bcbbcd98901ac778b52
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
18 files changed, 77 insertions, 78 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/async/AsyncRestRequestResponseEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/async/DmiAsyncRequestResponseEventConsumer.java index f14bb15842..e2803e89a1 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/async/AsyncRestRequestResponseEventConsumer.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/async/DmiAsyncRequestResponseEventConsumer.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (c) 2023-2024 Nordix Foundation. + * Copyright (c) 2023-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.stereotype.Component; @Slf4j @RequiredArgsConstructor @ConditionalOnProperty(name = "notification.enabled", havingValue = "true", matchIfMissing = true) -public class AsyncRestRequestResponseEventConsumer { +public class DmiAsyncRequestResponseEventConsumer { private final EventsPublisher<NcmpAsyncRequestResponseEvent> eventsPublisher; private final NcmpAsyncRequestResponseEventMapper ncmpAsyncRequestResponseEventMapper; diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerAsyncHelper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerAsyncHelper.java index a53c902683..9d5bc1575a 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerAsyncHelper.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerAsyncHelper.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2023-2024 Nordix Foundation + * Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.stereotype.Service; public class LcmEventsCmHandleStateHandlerAsyncHelper { private final LcmEventsCreator lcmEventsCreator; - private final LcmEventsService lcmEventsService; + private final LcmEventsProducer lcmEventsProducer; /** * Publish LcmEvent in batches and in asynchronous manner. @@ -58,7 +58,7 @@ public class LcmEventsCmHandleStateHandlerAsyncHelper { existingNcmpServiceCmHandle); final LcmEvent lcmEvent = lcmEventsCreator.populateLcmEvent(cmHandleId, targetNcmpServiceCmHandle, existingNcmpServiceCmHandle); - lcmEventsService.publishLcmEvent(cmHandleId, lcmEvent, lcmEventHeader); + lcmEventsProducer.publishLcmEvent(cmHandleId, lcmEvent, lcmEventHeader); } private static NcmpServiceCmHandle toNcmpServiceCmHandle(final YangModelCmHandle yangModelCmHandle) { diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsProducer.java index 192667175e..d62688de1d 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsService.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsProducer.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2024 Nordix Foundation + * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,16 +38,16 @@ import org.springframework.kafka.KafkaException; import org.springframework.stereotype.Service; /** - * LcmEventsService to call the publisher and publish on the dedicated topic. + * LcmEventsProducer to call the publisher and publish on the dedicated topic. */ @Slf4j @Service @RequiredArgsConstructor -public class LcmEventsService { +public class LcmEventsProducer { private static final Tag TAG_METHOD = Tag.of("method", "publishLcmEvent"); - private static final Tag TAG_CLASS = Tag.of("class", LcmEventsService.class.getName()); + private static final Tag TAG_CLASS = Tag.of("class", LcmEventsProducer.class.getName()); private static final String UNAVAILABLE_CM_HANDLE_STATE = "N/A"; private final EventsPublisher<LcmEvent> eventsPublisher; private final JsonObjectMapper jsonObjectMapper; diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java index 692bf5caee..27ad535344 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManager.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2023-2024 Nordix Foundation + * Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.onap.cps.ncmp.impl.dmi.DmiServiceNameResolver; import org.onap.cps.ncmp.impl.inventory.InventoryPersistence; import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle; import org.onap.cps.ncmp.impl.models.RequiredDmiService; -import org.onap.cps.ncmp.utils.events.CmAvcEventPublisher; +import org.onap.cps.ncmp.utils.events.InventoryEventProducer; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @@ -52,7 +52,7 @@ public class TrustLevelManager { private final IMap<String, TrustLevel> trustLevelPerDmiPlugin; private final InventoryPersistence inventoryPersistence; - private final CmAvcEventPublisher cmAvcEventPublisher; + private final InventoryEventProducer inventoryEventProducer; private static final String AVC_CHANGED_ATTRIBUTE_NAME = "trustLevel"; private static final String AVC_NO_OLD_VALUE = null; @@ -82,7 +82,7 @@ public class TrustLevelManager { } trustLevelPerCmHandleIdForCache.put(cmHandleId, initialTrustLevel); if (TrustLevel.NONE.equals(initialTrustLevel)) { - cmAvcEventPublisher.publishAvcEvent(cmHandleId, + inventoryEventProducer.publishAvcEvent(cmHandleId, AVC_CHANGED_ATTRIBUTE_NAME, AVC_NO_OLD_VALUE, initialTrustLevel.name()); @@ -197,7 +197,7 @@ public class TrustLevelManager { } else { log.info("The trust level for Cm Handle: {} is now: {} ", notificationCandidateCmHandleId, newEffectiveTrustLevel); - cmAvcEventPublisher.publishAvcEvent(notificationCandidateCmHandleId, + inventoryEventProducer.publishAvcEvent(notificationCandidateCmHandleId, AVC_CHANGED_ATTRIBUTE_NAME, oldEffectiveTrustLevel.name(), newEffectiveTrustLevel.name()); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/utils/events/CmAvcEventPublisher.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/utils/events/InventoryEventProducer.java index 2bb35864d3..f388ee1b20 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/utils/events/CmAvcEventPublisher.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/utils/events/InventoryEventProducer.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2023-2025 Nordix Foundation + * Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor -public class CmAvcEventPublisher { +public class InventoryEventProducer { private final EventsPublisher<CloudEvent> eventsPublisher; diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/CpsAsyncRequestResponseEventIntegrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/CpsAsyncRequestResponseEventIntegrationSpec.groovy index 4bcafe8c61..c651bb5d0f 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/CpsAsyncRequestResponseEventIntegrationSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/CpsAsyncRequestResponseEventIntegrationSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (c) 2022-2024 Nordix Foundation. + * Copyright (c) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,9 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.annotation.DirtiesContext import org.testcontainers.spock.Testcontainers - import java.time.Duration -@SpringBootTest(classes = [EventsPublisher, AsyncRestRequestResponseEventConsumer, ObjectMapper, JsonObjectMapper]) +@SpringBootTest(classes = [EventsPublisher, DmiAsyncRequestResponseEventConsumer, ObjectMapper, JsonObjectMapper]) @Testcontainers @DirtiesContext class NcmpAsyncRequestResponseEventProducerIntegrationSpec extends MessagingBaseSpec { @@ -53,8 +52,8 @@ class NcmpAsyncRequestResponseEventProducerIntegrationSpec extends MessagingBase Mappers.getMapper(NcmpAsyncRequestResponseEventMapper.class) @SpringBean - AsyncRestRequestResponseEventConsumer ncmpAsyncRequestResponseEventConsumer = - new AsyncRestRequestResponseEventConsumer(cpsAsyncRequestResponseEventPublisher, + DmiAsyncRequestResponseEventConsumer dmiAsyncRequestResponseEventConsumer = + new DmiAsyncRequestResponseEventConsumer(cpsAsyncRequestResponseEventPublisher, ncmpAsyncRequestResponseEventMapper) @Autowired @@ -69,7 +68,7 @@ class NcmpAsyncRequestResponseEventProducerIntegrationSpec extends MessagingBase def jsonData = TestUtils.getResourceFileContent('dmiAsyncRequestResponseEvent.json') def testEventSent = jsonObjectMapper.convertJsonString(jsonData, DmiAsyncRequestResponseEvent.class) when: 'the event is consumed' - ncmpAsyncRequestResponseEventConsumer.consumeAndForward(testEventSent) + dmiAsyncRequestResponseEventConsumer.consumeAndForward(testEventSent) and: 'the topic is polled' def records = legacyEventKafkaConsumer.poll(Duration.ofMillis(1500)) then: 'poll returns one record' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/FilterStrategiesIntegrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/FilterStrategiesIntegrationSpec.groovy index 01d2a3666b..8039d4767c 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/FilterStrategiesIntegrationSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/FilterStrategiesIntegrationSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (c) 2023-2024 Nordix Foundation. + * Copyright (c) 2023-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import spock.util.concurrent.PollingConditions import java.util.concurrent.TimeUnit -@SpringBootTest(classes =[DataOperationEventConsumer, AsyncRestRequestResponseEventConsumer, RecordFilterStrategies, KafkaConfig]) +@SpringBootTest(classes =[DataOperationEventConsumer, DmiAsyncRequestResponseEventConsumer, RecordFilterStrategies, KafkaConfig]) @DirtiesContext @Testcontainers @EnableAutoConfiguration diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/SerializationIntegrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/SerializationIntegrationSpec.groovy index 3fe7ec222e..75738b443f 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/SerializationIntegrationSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/async/SerializationIntegrationSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (c) 2023-2024 Nordix Foundation. + * Copyright (c) 2023-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import org.springframework.test.annotation.DirtiesContext import org.testcontainers.spock.Testcontainers import spock.util.concurrent.PollingConditions -@SpringBootTest(classes =[DataOperationEventConsumer, AsyncRestRequestResponseEventConsumer, RecordFilterStrategies, KafkaConfig]) +@SpringBootTest(classes =[DataOperationEventConsumer, DmiAsyncRequestResponseEventConsumer, RecordFilterStrategies, KafkaConfig]) @DirtiesContext @Testcontainers @EnableAutoConfiguration diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerImplSpec.groovy index 62db2e34ad..73b5948432 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerImplSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2025 Nordix Foundation + * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,10 +55,10 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { def mockInventoryPersistence = Mock(InventoryPersistence) def mockLcmEventsCreator = Mock(LcmEventsCreator) - def mockLcmEventsService = Mock(LcmEventsService) + def mockLcmEventsProducer = Mock(LcmEventsProducer) def mockCmHandleStateMonitor = Mock(CmHandleStateMonitor) - def lcmEventsCmHandleStateHandlerAsyncHelper = new LcmEventsCmHandleStateHandlerAsyncHelper(mockLcmEventsCreator, mockLcmEventsService) + def lcmEventsCmHandleStateHandlerAsyncHelper = new LcmEventsCmHandleStateHandlerAsyncHelper(mockLcmEventsCreator, mockLcmEventsProducer) def objectUnderTest = new LcmEventsCmHandleStateHandlerImpl(mockInventoryPersistence, lcmEventsCmHandleStateHandlerAsyncHelper, mockCmHandleStateMonitor) def cmHandleId = 'cmhandle-id-1' @@ -83,7 +83,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { assert loggingEvent.level == Level.INFO assert loggingEvent.formattedMessage == "${cmHandleId} is now in ${toCmHandleState} state" and: 'event service is called to publish event' - 1 * mockLcmEventsService.publishLcmEvent(cmHandleId, _, _) + 1 * mockLcmEventsProducer.publishLcmEvent(cmHandleId, _, _) where: 'state change parameters are provided' stateChange | fromCmHandleState | toCmHandleState 'ADVISED to READY' | ADVISED | READY @@ -100,7 +100,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { then: 'CM-handle is saved using inventory persistence' 1 * mockInventoryPersistence.saveCmHandleBatch(List.of(yangModelCmHandle)) and: 'event service is called to publish event' - 1 * mockLcmEventsService.publishLcmEvent(cmHandleId, _, _) + 1 * mockLcmEventsProducer.publishLcmEvent(cmHandleId, _, _) and: 'a log entry is written' assert getLogMessage(0) == "${cmHandleId} is now in ADVISED state" } @@ -120,7 +120,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { } } and: 'event service is called to publish event' - 1 * mockLcmEventsService.publishLcmEvent(cmHandleId, _, _) + 1 * mockLcmEventsProducer.publishLcmEvent(cmHandleId, _, _) and: 'a log entry is written' assert getLogMessage(0) == "${cmHandleId} is now in ADVISED state" } @@ -142,7 +142,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { } } and: 'event service is called to publish event' - 1 * mockLcmEventsService.publishLcmEvent(cmHandleId, _, _) + 1 * mockLcmEventsProducer.publishLcmEvent(cmHandleId, _, _) and: 'a log entry is written' assert getLogMessage(0) == "${cmHandleId} is now in READY state" } @@ -158,7 +158,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { and: 'method to persist cm handle state is called once' 1 * mockInventoryPersistence.saveCmHandleStateBatch(Map.of(yangModelCmHandle.getId(), yangModelCmHandle.getCompositeState())) and: 'the method to publish Lcm event is called once' - 1 * mockLcmEventsService.publishLcmEvent(cmHandleId, _, _) + 1 * mockLcmEventsProducer.publishLcmEvent(cmHandleId, _, _) } def 'Update cmHandle state to DELETING to DELETED' (){ @@ -170,7 +170,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { then: 'the cm handle state is as expected' yangModelCmHandle.getCompositeState().getCmHandleState() == DELETED and: 'the method to publish Lcm event is called once' - 1 * mockLcmEventsService.publishLcmEvent(cmHandleId, _, _) + 1 * mockLcmEventsProducer.publishLcmEvent(cmHandleId, _, _) } def 'No state change and no event to be published'() { @@ -182,7 +182,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { 1 * mockInventoryPersistence.saveCmHandleBatch(EMPTY_LIST) 1 * mockInventoryPersistence.saveCmHandleStateBatch(EMPTY_MAP) and: 'no event will be published' - 0 * mockLcmEventsService.publishLcmEvent(*_) + 0 * mockLcmEventsProducer.publishLcmEvent(*_) and: 'no log entries are written' assert logger.list.empty } @@ -201,7 +201,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { and: 'no state updates are persisted' 1 * mockInventoryPersistence.saveCmHandleStateBatch(EMPTY_MAP) and: 'event service is called to publish events' - 2 * mockLcmEventsService.publishLcmEvent(_, _, _) + 2 * mockLcmEventsProducer.publishLcmEvent(_, _, _) and: 'two log entries are written' assert getLogMessage(0) == 'cmhandle1 is now in ADVISED state' assert getLogMessage(1) == 'cmhandle2 is now in ADVISED state' @@ -221,7 +221,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { and: 'no new handles are persisted' 1 * mockInventoryPersistence.saveCmHandleBatch(EMPTY_LIST) and: 'event service is called to publish events' - 2 * mockLcmEventsService.publishLcmEvent(_, _, _) + 2 * mockLcmEventsProducer.publishLcmEvent(_, _, _) and: 'two log entries are written' assert getLogMessage(0) == 'cmhandle1 is now in READY state' assert getLogMessage(1) == 'cmhandle2 is now in DELETING state' @@ -237,7 +237,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { and: 'no new handles are persisted' 1 * mockInventoryPersistence.saveCmHandleBatch(EMPTY_LIST) and: 'event service is called to publish events' - 2 * mockLcmEventsService.publishLcmEvent(_, _, _) + 2 * mockLcmEventsProducer.publishLcmEvent(_, _, _) and: 'two log entries are written' assert getLogMessage(0) == 'cmhandle1 is now in DELETED state' assert getLogMessage(1) == 'cmhandle2 is now in DELETED state' @@ -253,7 +253,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification { then: 'the exception is not handled' thrown(RuntimeException) and: 'no events are published' - 0 * mockLcmEventsService.publishLcmEvent(_, _, _) + 0 * mockLcmEventsProducer.publishLcmEvent(_, _, _) and: 'no log entries are written' assert logger.list.empty } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsProducerSpec.groovy index 73c66089a3..a0b6de1aa4 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsServiceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsProducerSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2024 Nordix Foundation + * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,13 +34,13 @@ import org.onap.cps.utils.JsonObjectMapper import org.springframework.kafka.KafkaException import spock.lang.Specification -class LcmEventsServiceSpec extends Specification { +class LcmEventsProducerSpec extends Specification { def mockLcmEventsPublisher = Mock(EventsPublisher) def mockJsonObjectMapper = Mock(JsonObjectMapper) def meterRegistry = new SimpleMeterRegistry() - def objectUnderTest = new LcmEventsService(mockLcmEventsPublisher, mockJsonObjectMapper, meterRegistry) + def objectUnderTest = new LcmEventsProducer(mockLcmEventsPublisher, mockJsonObjectMapper, meterRegistry) def 'Create and Publish lcm event where events are #scenario'() { given: 'a cm handle id, Lcm Event, and headers' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy index 1ab517cdcf..72ca190ff1 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelManagerSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2023-2024 Nordix Foundation + * Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle import org.onap.cps.ncmp.api.inventory.models.TrustLevel import org.onap.cps.ncmp.impl.inventory.InventoryPersistence import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle -import org.onap.cps.ncmp.utils.events.CmAvcEventPublisher +import org.onap.cps.ncmp.utils.events.InventoryEventProducer import spock.lang.Specification class TrustLevelManagerSpec extends Specification { @@ -39,13 +39,13 @@ class TrustLevelManagerSpec extends Specification { IMap<String, TrustLevel> trustLevelPerDmiPlugin def mockInventoryPersistence = Mock(InventoryPersistence) - def mockAttributeValueChangeEventPublisher = Mock(CmAvcEventPublisher) + def mockInventoryEventProducer = Mock(InventoryEventProducer) def setup() { hazelcastInstance = Hazelcast.newHazelcastInstance() trustLevelPerCmHandleId = hazelcastInstance.getMap("trustLevelPerCmHandle") trustLevelPerDmiPlugin = hazelcastInstance.getMap("trustLevelPerCmHandle") - objectUnderTest = new TrustLevelManager(trustLevelPerCmHandleId, trustLevelPerDmiPlugin, mockInventoryPersistence, mockAttributeValueChangeEventPublisher) + objectUnderTest = new TrustLevelManager(trustLevelPerCmHandleId, trustLevelPerDmiPlugin, mockInventoryPersistence, mockInventoryEventProducer) } def cleanup() { @@ -71,7 +71,7 @@ class TrustLevelManagerSpec extends Specification { when: 'method to register to the cache is called' objectUnderTest.registerCmHandles(cmHandleModelsToBeCreated) then: 'no notification sent' - 0 * mockAttributeValueChangeEventPublisher.publishAvcEvent(*_) + 0 * mockInventoryEventProducer.publishAvcEvent(*_) and: 'both cm handles are in the cache and are trusted' assert trustLevelPerCmHandleId.get('ch-1') == TrustLevel.COMPLETE assert trustLevelPerCmHandleId.get('ch-2') == TrustLevel.COMPLETE @@ -83,7 +83,7 @@ class TrustLevelManagerSpec extends Specification { when: 'method to register to the cache is called' objectUnderTest.registerCmHandles(cmHandleModelsToBeCreated) then: 'notification is sent' - 1 * mockAttributeValueChangeEventPublisher.publishAvcEvent(*_) + 1 * mockInventoryEventProducer.publishAvcEvent(*_) } def 'Dmi trust level updated'() { @@ -94,7 +94,7 @@ class TrustLevelManagerSpec extends Specification { when: 'the update is handled' objectUnderTest.updateDmi('my-dmi', ['ch-1'], TrustLevel.NONE) then: 'notification is sent' - 1 * mockAttributeValueChangeEventPublisher.publishAvcEvent('ch-1', 'trustLevel', 'COMPLETE', 'NONE') + 1 * mockInventoryEventProducer.publishAvcEvent('ch-1', 'trustLevel', 'COMPLETE', 'NONE') and: 'the dmi in the cache is not trusted' assert trustLevelPerDmiPlugin.get('my-dmi') == TrustLevel.NONE } @@ -107,7 +107,7 @@ class TrustLevelManagerSpec extends Specification { when: 'the update is handled' objectUnderTest.updateDmi('my-dmi', ['ch-1'], TrustLevel.COMPLETE) then: 'no notification is sent' - 0 * mockAttributeValueChangeEventPublisher.publishAvcEvent(*_) + 0 * mockInventoryEventProducer.publishAvcEvent(*_) and: 'the dmi in the cache is trusted' assert trustLevelPerDmiPlugin.get('my-dmi') == TrustLevel.COMPLETE } @@ -124,7 +124,7 @@ class TrustLevelManagerSpec extends Specification { then: 'the cm handle in the cache is trusted' assert trustLevelPerCmHandleId.get('ch-1', TrustLevel.COMPLETE) and: 'notification is sent' - 1 * mockAttributeValueChangeEventPublisher.publishAvcEvent('ch-1', 'trustLevel', 'NONE', 'COMPLETE') + 1 * mockInventoryEventProducer.publishAvcEvent('ch-1', 'trustLevel', 'NONE', 'COMPLETE') } def 'CmHandle trust level updated with same value'() { @@ -139,7 +139,7 @@ class TrustLevelManagerSpec extends Specification { then: 'the cm handle in the cache is not trusted' assert trustLevelPerCmHandleId.get('ch-1', TrustLevel.NONE) and: 'no notification is sent' - 0 * mockAttributeValueChangeEventPublisher.publishAvcEvent(*_) + 0 * mockInventoryEventProducer.publishAvcEvent(*_) } def 'Dmi trust level restored to complete with non trusted CmHandle'() { @@ -152,7 +152,7 @@ class TrustLevelManagerSpec extends Specification { then: 'the cm handle in the cache is still NONE' assert trustLevelPerCmHandleId.get('ch-1') == TrustLevel.NONE and: 'no notification is sent' - 0 * mockAttributeValueChangeEventPublisher.publishAvcEvent(*_) + 0 * mockInventoryEventProducer.publishAvcEvent(*_) } def 'Apply effective trust level among CmHandle and dmi plugin'() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/utils/events/CmAvcEventPublisherSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/utils/events/InventoryEventProducerSpec.groovy index 051f5df4cf..1aa7aab0f3 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/utils/events/CmAvcEventPublisherSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/utils/events/InventoryEventProducerSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (c) 2023-2024 Nordix Foundation. + * Copyright (c) 2023-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,10 +30,10 @@ import org.onap.cps.utils.JsonObjectMapper import org.springframework.test.context.ContextConfiguration @ContextConfiguration(classes = [CpsApplicationContext, ObjectMapper, JsonObjectMapper]) -class CmAvcEventPublisherSpec extends MessagingBaseSpec { +class InventoryEventProducerSpec extends MessagingBaseSpec { def mockEventsPublisher = Mock(EventsPublisher<CloudEvent>) - def objectUnderTest = new CmAvcEventPublisher(mockEventsPublisher) + def objectUnderTest = new InventoryEventProducer(mockEventsPublisher) def 'Publish an attribute value change event'() { given: 'the event key' diff --git a/cps-service/src/main/java/org/onap/cps/events/CpsDataUpdateEventsService.java b/cps-service/src/main/java/org/onap/cps/events/CpsDataUpdateEventsProducer.java index 3bcc1923a4..3061fd2022 100644 --- a/cps-service/src/main/java/org/onap/cps/events/CpsDataUpdateEventsService.java +++ b/cps-service/src/main/java/org/onap/cps/events/CpsDataUpdateEventsProducer.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2024-2025 TechMahindra Ltd. - * Copyright (C) 2024 Nordix Foundation. + * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import org.springframework.stereotype.Service; @Slf4j @Service @RequiredArgsConstructor -public class CpsDataUpdateEventsService { +public class CpsDataUpdateEventsProducer { private final EventsPublisher<CpsDataUpdatedEvent> eventsPublisher; diff --git a/cps-service/src/main/java/org/onap/cps/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/impl/CpsDataServiceImpl.java index a93bf9ac82..586941a561 100644 --- a/cps-service/src/main/java/org/onap/cps/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/impl/CpsDataServiceImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2025 Nordix Foundation + * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2020-2022 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022-2025 TechMahindra Ltd. @@ -48,7 +48,7 @@ import org.onap.cps.api.model.DataNode; import org.onap.cps.api.model.DeltaReport; import org.onap.cps.api.parameters.FetchDescendantsOption; import org.onap.cps.cpspath.parser.CpsPathUtil; -import org.onap.cps.events.CpsDataUpdateEventsService; +import org.onap.cps.events.CpsDataUpdateEventsProducer; import org.onap.cps.events.model.Data.Operation; import org.onap.cps.spi.CpsDataPersistenceService; import org.onap.cps.utils.ContentType; @@ -66,7 +66,7 @@ public class CpsDataServiceImpl implements CpsDataService { private static final long DEFAULT_LOCK_TIMEOUT_IN_MILLISECONDS = 300L; private final CpsDataPersistenceService cpsDataPersistenceService; - private final CpsDataUpdateEventsService cpsDataUpdateEventsService; + private final CpsDataUpdateEventsProducer cpsDataUpdateEventsProducer; private final CpsAnchorService cpsAnchorService; private final DataNodeFactory dataNodeFactory; @@ -396,7 +396,7 @@ public class CpsDataServiceImpl implements CpsDataService { final Operation operation, final OffsetDateTime observedTimestamp) { try { - cpsDataUpdateEventsService.publishCpsDataUpdateEvent(anchor, xpath, operation, observedTimestamp); + cpsDataUpdateEventsProducer.publishCpsDataUpdateEvent(anchor, xpath, operation, observedTimestamp); } catch (final Exception exception) { log.error("Failed to send message to notification service", exception); } diff --git a/cps-service/src/main/java/org/onap/cps/impl/CpsDataspaceServiceImpl.java b/cps-service/src/main/java/org/onap/cps/impl/CpsDataspaceServiceImpl.java index 1a85147b64..ac55b81bdc 100644 --- a/cps-service/src/main/java/org/onap/cps/impl/CpsDataspaceServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/impl/CpsDataspaceServiceImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2023 Nordix Foundation + * Copyright (C) 2020-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2020-2022 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022 TechMahindra Ltd. diff --git a/cps-service/src/test/groovy/org/onap/cps/events/CpsDataUpdateEventsServiceSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/events/CpsDataUpdateEventsProducerSpec.groovy index e5160a0be7..641e399622 100644 --- a/cps-service/src/test/groovy/org/onap/cps/events/CpsDataUpdateEventsServiceSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/events/CpsDataUpdateEventsProducerSpec.groovy @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2024-2025 TechMahindra Ltd. - * Copyright (C) 2024 Nordix Foundation. + * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,12 +39,12 @@ import static org.onap.cps.events.model.Data.Operation.DELETE import static org.onap.cps.events.model.Data.Operation.UPDATE @ContextConfiguration(classes = [ObjectMapper, JsonObjectMapper]) -class CpsDataUpdateEventsServiceSpec extends Specification { +class CpsDataUpdateEventsProducerSpec extends Specification { def mockEventsPublisher = Mock(EventsPublisher) def objectMapper = new ObjectMapper(); def mockCpsNotificationService = Mock(CpsNotificationService) - def objectUnderTest = new CpsDataUpdateEventsService(mockEventsPublisher, mockCpsNotificationService) + def objectUnderTest = new CpsDataUpdateEventsProducer(mockEventsPublisher, mockCpsNotificationService) def setup() { mockCpsNotificationService.isNotificationEnabled('dataspace01', 'anchor01') >> true diff --git a/cps-service/src/test/groovy/org/onap/cps/impl/CpsDataServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/impl/CpsDataServiceImplSpec.groovy index 967bcc0aa0..a4bfd569c5 100644 --- a/cps-service/src/test/groovy/org/onap/cps/impl/CpsDataServiceImplSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/impl/CpsDataServiceImplSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2025 Nordix Foundation + * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2021-2022 Bell Canada. * Modifications Copyright (C) 2022-2025 TechMahindra Ltd. @@ -37,7 +37,7 @@ import org.onap.cps.api.exceptions.SessionManagerException import org.onap.cps.api.exceptions.SessionTimeoutException import org.onap.cps.api.model.Anchor import org.onap.cps.api.parameters.FetchDescendantsOption -import org.onap.cps.events.CpsDataUpdateEventsService +import org.onap.cps.events.CpsDataUpdateEventsProducer import org.onap.cps.spi.CpsDataPersistenceService import org.onap.cps.utils.ContentType import org.onap.cps.utils.CpsValidator @@ -66,13 +66,13 @@ class CpsDataServiceImplSpec extends Specification { def mockTimedYangTextSchemaSourceSetBuilder = Mock(TimedYangTextSchemaSourceSetBuilder) def yangParser = new YangParser(new YangParserHelper(), mockYangTextSchemaSourceSetCache, mockTimedYangTextSchemaSourceSetBuilder) def mockCpsDeltaService = Mock(CpsDeltaService); - def mockDataUpdateEventsService = Mock(CpsDataUpdateEventsService) + def mockCpsDataUpdateEventsProducer = Mock(CpsDataUpdateEventsProducer) def jsonObjectMapper = new JsonObjectMapper(new ObjectMapper()) def mockPrefixResolver = Mock(PrefixResolver) def dataMapper = new DataMapper(mockCpsAnchorService, mockPrefixResolver) def dataNodeFactory = new DataNodeFactoryImpl(yangParser) - def objectUnderTest = new CpsDataServiceImpl(mockCpsDataPersistenceService, mockDataUpdateEventsService, mockCpsAnchorService, + def objectUnderTest = new CpsDataServiceImpl(mockCpsDataPersistenceService, mockCpsDataUpdateEventsProducer, mockCpsAnchorService, dataNodeFactory, mockCpsValidator, yangParser, mockCpsDeltaService, dataMapper, jsonObjectMapper) def logger = (Logger) LoggerFactory.getLogger(objectUnderTest.class) @@ -577,8 +577,8 @@ class CpsDataServiceImplSpec extends Specification { and: 'the persistence service method is invoked with the correct parameters' 1 * mockCpsDataPersistenceService.deleteDataNodes(dataspaceName, _ as Collection<String>) and: 'a data update event is sent for each anchor' - 1 * mockDataUpdateEventsService.publishCpsDataUpdateEvent(anchor1, '/', DELETE, observedTimestamp) - 1 * mockDataUpdateEventsService.publishCpsDataUpdateEvent(anchor2, '/', DELETE, observedTimestamp) + 1 * mockCpsDataUpdateEventsProducer.publishCpsDataUpdateEvent(anchor1, '/', DELETE, observedTimestamp) + 1 * mockCpsDataUpdateEventsProducer.publishCpsDataUpdateEvent(anchor2, '/', DELETE, observedTimestamp) } def "Validating #scenario when dry run is enabled."() { @@ -643,7 +643,7 @@ class CpsDataServiceImplSpec extends Specification { given: 'schema set for given anchor and dataspace references test-tree model' setupSchemaSetMocks('test-tree.yang') when: 'publisher set to throw an exception' - mockDataUpdateEventsService.publishCpsDataUpdateEvent(_, _, _, _) >> { throw new Exception("publishing failed")} + mockCpsDataUpdateEventsProducer.publishCpsDataUpdateEvent(_, _, _, _) >> { throw new Exception("publishing failed")} and: 'an update event is performed' objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, '/', '{"test-tree": {"branch": []}}', observedTimestamp, ContentType.JSON) then: 'the exception is not bubbled up' diff --git a/cps-service/src/test/groovy/org/onap/cps/impl/E2ENetworkSliceSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/impl/E2ENetworkSliceSpec.groovy index 893cce6687..c9c1991c53 100755 --- a/cps-service/src/test/groovy/org/onap/cps/impl/E2ENetworkSliceSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/impl/E2ENetworkSliceSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2025 Nordix Foundation. + * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved. * Modifications Copyright (C) 2021-2022 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022-2025 TechMahindra Ltd. @@ -28,7 +28,7 @@ import org.onap.cps.TestUtils import org.onap.cps.api.CpsAnchorService import org.onap.cps.api.CpsDeltaService import org.onap.cps.api.model.Anchor -import org.onap.cps.events.CpsDataUpdateEventsService +import org.onap.cps.events.CpsDataUpdateEventsProducer import org.onap.cps.spi.CpsDataPersistenceService import org.onap.cps.spi.CpsModulePersistenceService import org.onap.cps.utils.ContentType @@ -56,9 +56,9 @@ class E2ENetworkSliceSpec extends Specification { def cpsModuleServiceImpl = new CpsModuleServiceImpl(mockCpsModulePersistenceService, mockYangTextSchemaSourceSetCache, mockCpsAnchorService, mockCpsValidator,timedYangTextSchemaSourceSetBuilder) - def mockDataUpdateEventsService = Mock(CpsDataUpdateEventsService) + def mockCpsDataUpdateEventsProducer = Mock(CpsDataUpdateEventsProducer) def dataNodeFactory = new DataNodeFactoryImpl(yangParser) - def cpsDataServiceImpl = new CpsDataServiceImpl(mockCpsDataPersistenceService, mockDataUpdateEventsService, mockCpsAnchorService, dataNodeFactory, mockCpsValidator, yangParser, mockCpsDeltaService, dataMapper, jsonObjectMapper) + def cpsDataServiceImpl = new CpsDataServiceImpl(mockCpsDataPersistenceService, mockCpsDataUpdateEventsProducer, mockCpsAnchorService, dataNodeFactory, mockCpsValidator, yangParser, mockCpsDeltaService, dataMapper, jsonObjectMapper) def dataspaceName = 'someDataspace' def anchorName = 'someAnchor' def schemaSetName = 'someSchemaSet' |