/*
* ============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.
@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;
/*
* ============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.
public class LcmEventsCmHandleStateHandlerAsyncHelper {
private final LcmEventsCreator lcmEventsCreator;
- private final LcmEventsService lcmEventsService;
+ private final LcmEventsProducer lcmEventsProducer;
/**
* Publish LcmEvent in batches and in asynchronous manner.
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) {
/*
* ============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.
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;
/*
* ============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.
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;
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;
}
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());
} 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());
/*
* ============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.
@Service
@RequiredArgsConstructor
-public class CmAvcEventPublisher {
+public class InventoryEventProducer {
private final EventsPublisher<CloudEvent> eventsPublisher;
/*
* ============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.
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 {
Mappers.getMapper(NcmpAsyncRequestResponseEventMapper.class)
@SpringBean
- AsyncRestRequestResponseEventConsumer ncmpAsyncRequestResponseEventConsumer =
- new AsyncRestRequestResponseEventConsumer(cpsAsyncRequestResponseEventPublisher,
+ DmiAsyncRequestResponseEventConsumer dmiAsyncRequestResponseEventConsumer =
+ new DmiAsyncRequestResponseEventConsumer(cpsAsyncRequestResponseEventPublisher,
ncmpAsyncRequestResponseEventMapper)
@Autowired
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'
/*
* ============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.
import java.util.concurrent.TimeUnit
-@SpringBootTest(classes =[DataOperationEventConsumer, AsyncRestRequestResponseEventConsumer, RecordFilterStrategies, KafkaConfig])
+@SpringBootTest(classes =[DataOperationEventConsumer, DmiAsyncRequestResponseEventConsumer, RecordFilterStrategies, KafkaConfig])
@DirtiesContext
@Testcontainers
@EnableAutoConfiguration
/*
* ============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.
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
/*
* ============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.
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'
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
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"
}
}
}
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"
}
}
}
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"
}
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' (){
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'() {
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
}
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'
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'
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'
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
}
/*
* ============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.
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'
/*
* ============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.
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 {
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() {
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
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'() {
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
}
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
}
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'() {
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'() {
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'() {
/*
* ============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.
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'
/*
* ============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.
@Slf4j
@Service
@RequiredArgsConstructor
-public class CpsDataUpdateEventsService {
+public class CpsDataUpdateEventsProducer {
private final EventsPublisher<CpsDataUpdatedEvent> eventsPublisher;
/*
* ============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.
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;
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;
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);
}
/*
* ============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.
/*
* ============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.
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
/*
* ============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.
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
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)
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."() {
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'
/*
* ============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.
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
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'