--- /dev/null
+{
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$id": "urn:cps:org.onap.ncmp.cmhandle.lcm-event.base",
+ "description": "The base (header fields) for LCM events",
+ "type": "object",
+ "javaType" : "org.onap.cps.ncmp.events.lcm.LcmEventBase",
+ "javaInterfaces" : ["org.onap.cps.events.LegacyEvent"],
+ "properties": {
+ "eventId": {
+ "description": "The unique id identifying the event",
+ "type": "string"
+ },
+ "eventCorrelationId": {
+ "description": "The id identifying the event",
+ "type": "string"
+ },
+ "eventTime": {
+ "description": "The timestamp when original event occurred",
+ "type": "string"
+ },
+ "eventSource": {
+ "description": "The source of the event",
+ "type": "string"
+ },
+ "eventType": {
+ "description": "The type of the event",
+ "type": "string"
+ },
+ "eventSchema": {
+ "description": "The schema that this event adheres to",
+ "type": "string"
+ },
+ "eventSchemaVersion": {
+ "description": "The version of the schema that this event adheres to",
+ "type": "string"
+ }
+ },
+ "required": [
+ "eventId",
+ "eventCorrelationId",
+ "eventTime",
+ "eventSource",
+ "eventType",
+ "eventSchema",
+ "eventSchemaVersion"
+ ],
+ "additionalProperties": false
+}
+++ /dev/null
-{
-
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$id": "urn:cps:org.onap.ncmp.cmhandle.lcm-event:v1",
-
- "$ref": "#/definitions/LcmEvent",
-
- "definitions": {
-
- "Values": {
- "description": "Values that represents the state of a cmHandle",
- "type": "object",
- "properties": {
- "dataSyncEnabled":{
- "description": "Whether data sync enabled",
- "type": "boolean"
- },
- "cmHandleState": {
- "description": "State of cmHandle",
- "type": "string",
- "enum": ["ADVISED", "READY", "LOCKED", "DELETING", "DELETED"]
- },
- "cmHandleProperties": {
- "description": "cmHandle properties",
- "type": "object",
- "default": null,
- "existingJavaType": "java.util.List<java.util.Map<String,String>>",
- "additionalProperties": false
- }
- },
- "additionalProperties": false
- },
-
- "Event": {
- "description": "The Payload of an event",
- "type": "object",
- "properties": {
- "cmHandleId": {
- "description": "cmHandle id",
- "type": "string"
- },
- "alternateId": {
- "description": "alternative id for cmHandle (e.g. 3GPP FDN)",
- "type": "string"
- },
- "moduleSetTag": {
- "description": "module set tag for cmHandle",
- "type": "string"
- },
- "dataProducerIdentifier": {
- "description": "data producer identifier for cmHandle",
- "type": "string"
- },
- "oldValues": {
- "$ref": "#/definitions/Values"
- },
- "newValues": {
- "$ref": "#/definitions/Values"
- }
- },
- "required": [
- "cmHandleId"
- ],
- "additionalProperties": false
- },
-
- "LcmEvent": {
- "description": "The payload for LCM event",
- "type": "object",
- "javaType" : "org.onap.cps.ncmp.events.lcm.v1.LcmEvent",
- "javaInterfaces" : ["org.onap.cps.events.LegacyEvent"],
- "properties": {
- "eventId": {
- "description": "The unique id identifying the event",
- "type": "string"
- },
- "eventCorrelationId": {
- "description": "The id identifying the event",
- "type": "string"
- },
- "eventTime": {
- "description": "The timestamp when original event occurred",
- "type": "string"
- },
- "eventSource": {
- "description": "The source of the event",
- "type": "string"
- },
- "eventType": {
- "description": "The type of the event",
- "type": "string"
- },
- "eventSchema": {
- "description": "The schema that this event adheres to",
- "type": "string"
- },
- "eventSchemaVersion": {
- "description": "The version of the schema that this event adheres to",
- "type": "string"
- },
- "event": {
- "$ref": "#/definitions/Event"
- }
- },
- "required": [
- "eventId",
- "eventCorrelationId",
- "eventTime",
- "eventSource",
- "eventType",
- "eventSchema",
- "eventSchemaVersion",
- "event"
- ],
- "additionalProperties": false
- }
-
- }
-}
--- /dev/null
+{
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$id": "urn:cps:org.onap.ncmp.cmhandle.lcm-event.v1",
+ "javaType": "org.onap.cps.ncmp.events.lcm.LcmEventV1",
+ "extends": {
+ "$ref": "lcm-event-base.json"
+ },
+ "type": "object",
+ "properties": {
+ "event": {
+ "$ref": "#/$defs/PayloadV1"
+ }
+ },
+ "required": ["event"],
+ "$defs": {
+ "PayloadV1": {
+ "description": "The Payload of an event",
+ "type": "object",
+ "properties": {
+ "cmHandleId": {
+ "description": "cmHandle id",
+ "type": "string"
+ },
+ "alternateId": {
+ "description": "alternative id for cmHandle (e.g. 3GPP FDN)",
+ "type": "string"
+ },
+ "moduleSetTag": {
+ "description": "module set tag for cmHandle",
+ "type": "string"
+ },
+ "dataProducerIdentifier": {
+ "description": "data producer identifier for cmHandle",
+ "type": "string"
+ },
+ "oldValues": {
+ "$ref": "#/$defs/Values"
+ },
+ "newValues": {
+ "$ref": "#/$defs/Values"
+ }
+ },
+ "required": ["cmHandleId"],
+ "additionalProperties": false
+ },
+ "Values": {
+ "description": "Values that represents the state and properties of a cmHandle",
+ "javaType": "org.onap.cps.ncmp.events.lcm.Values",
+ "type": "object",
+ "properties": {
+ "dataSyncEnabled": {
+ "description": "Whether data sync enabled",
+ "type": "boolean"
+ },
+ "cmHandleState": {
+ "description": "State of cmHandle",
+ "type": "string",
+ "enum": [
+ "ADVISED",
+ "READY",
+ "LOCKED",
+ "DELETING",
+ "DELETED"
+ ]
+ },
+ "cmHandleProperties": {
+ "description": "cmHandle properties",
+ "type": "object",
+ "default": null,
+ "existingJavaType": "java.util.List<java.util.Map<String,String>>",
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+}
--- /dev/null
+{
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$id": "urn:cps:org.onap.ncmp.cmhandle.lcm-event.v2",
+ "javaType": "org.onap.cps.ncmp.events.lcm.LcmEventV2",
+ "extends": {
+ "$ref": "lcm-event-base.json"
+ },
+ "type": "object",
+ "properties": {
+ "event": {
+ "$ref": "#/$defs/PayloadV2"
+ }
+ },
+ "required": ["event"],
+ "$defs": {
+ "PayloadV2": {
+ "description": "The Payload of an event V2",
+ "javaType": "org.onap.cps.ncmp.events.lcm.PayloadV2",
+ "type": "object",
+ "properties": {
+ "cmHandleId": {
+ "description": "cmHandle id",
+ "type": "string"
+ },
+ "oldProperties": {
+ "description": "the old cmHandle properties(values) that have changed or been deleted",
+ "type": "object",
+ "default": null,
+ "existingJavaType": "java.util.Map<String,Object>",
+ "additionalProperties": false
+ },
+ "newProperties": {
+ "description": "cmHandle properties(values) that have been changed or been created",
+ "type": "object",
+ "default": null,
+ "existingJavaType": "java.util.Map<String,Object>",
+ "additionalProperties": false
+ }
+ },
+ "required": ["cmHandleId"],
+ "additionalProperties": false
+ }
+ }
+
+
+
+
+}
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2025-2026 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 lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle;
-import org.onap.cps.ncmp.events.lcm.v1.Values;
+import org.onap.cps.ncmp.events.lcm.Values;
/**
* Utility class for examining and determining changes in CM handle properties.
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2025-2026 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 lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import org.onap.cps.ncmp.events.lcm.v1.Values;
+import org.onap.cps.ncmp.events.lcm.Values;
@NoArgsConstructor
@Getter
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2022-2026 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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle;
-import org.onap.cps.ncmp.events.lcm.v1.Event;
-import org.onap.cps.ncmp.events.lcm.v1.LcmEvent;
+import org.onap.cps.ncmp.events.lcm.LcmEventBase;
+import org.onap.cps.ncmp.events.lcm.LcmEventV1;
+import org.onap.cps.ncmp.events.lcm.PayloadV1;
import org.onap.cps.ncmp.impl.utils.EventDateTimeFormatter;
import org.springframework.stereotype.Service;
* @param targetNcmpServiceCmHandle target ncmp service cmhandle
* @return Populated LcmEvent
*/
- public LcmEvent createLcmEvent(final NcmpServiceCmHandle currentNcmpServiceCmHandle,
- final NcmpServiceCmHandle targetNcmpServiceCmHandle) {
+ public LcmEventV1 createLcmEventV1(final NcmpServiceCmHandle currentNcmpServiceCmHandle,
+ final NcmpServiceCmHandle targetNcmpServiceCmHandle) {
final String cmHandleId = targetNcmpServiceCmHandle.getCmHandleId();
final LcmEventType lcmEventType =
determineEventType(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle);
- final LcmEvent lcmEvent = createLcmEventWithHeaderDetails(cmHandleId, lcmEventType);
- final Event event = new Event();
- event.setCmHandleId(cmHandleId);
- event.setAlternateId(targetNcmpServiceCmHandle.getAlternateId());
- event.setModuleSetTag(targetNcmpServiceCmHandle.getModuleSetTag());
- event.setDataProducerIdentifier(targetNcmpServiceCmHandle.getDataProducerIdentifier());
+ final LcmEventV1 lcmEventV1 = new LcmEventV1();
+ populateHeaderDetails(lcmEventV1, cmHandleId, lcmEventType);
+ final PayloadV1 payloadV1 = new PayloadV1();
+ payloadV1.setCmHandleId(cmHandleId);
+ payloadV1.setAlternateId(targetNcmpServiceCmHandle.getAlternateId());
+ payloadV1.setModuleSetTag(targetNcmpServiceCmHandle.getModuleSetTag());
+ payloadV1.setDataProducerIdentifier(targetNcmpServiceCmHandle.getDataProducerIdentifier());
final CmHandlePropertyUpdates cmHandlePropertyUpdates =
determineEventValues(lcmEventType, currentNcmpServiceCmHandle, targetNcmpServiceCmHandle);
- event.setOldValues(cmHandlePropertyUpdates.getOldValues());
- event.setNewValues(cmHandlePropertyUpdates.getNewValues());
- lcmEvent.setEvent(event);
- return lcmEvent;
+ payloadV1.setOldValues(cmHandlePropertyUpdates.getOldValues());
+ payloadV1.setNewValues(cmHandlePropertyUpdates.getNewValues());
+ lcmEventV1.setEvent(payloadV1);
+ return lcmEventV1;
}
private static LcmEventType determineEventType(final NcmpServiceCmHandle currentNcmpServiceCmHandle,
return new CmHandlePropertyUpdates();
}
- private LcmEvent createLcmEventWithHeaderDetails(final String eventCorrelationId, final LcmEventType lcmEventType) {
- final LcmEvent lcmEvent = new LcmEvent();
- lcmEvent.setEventId(UUID.randomUUID().toString());
- lcmEvent.setEventCorrelationId(eventCorrelationId);
- lcmEvent.setEventTime(EventDateTimeFormatter.getCurrentIsoFormattedDateTime());
- lcmEvent.setEventSource("org.onap.ncmp");
- lcmEvent.setEventType(lcmEventType.getEventType());
- lcmEvent.setEventSchema("org.onap.ncmp:cmhandle-lcm-event");
- lcmEvent.setEventSchemaVersion("1.0");
- return lcmEvent;
+ private void populateHeaderDetails(final LcmEventBase lcmEventBase,
+ final String eventCorrelationId,
+ final LcmEventType lcmEventType) {
+ lcmEventBase.setEventId(UUID.randomUUID().toString());
+ lcmEventBase.setEventCorrelationId(eventCorrelationId);
+ lcmEventBase.setEventTime(EventDateTimeFormatter.getCurrentIsoFormattedDateTime());
+ lcmEventBase.setEventSource("org.onap.ncmp");
+ lcmEventBase.setEventType(lcmEventType.getEventType());
+ lcmEventBase.setEventSchema("org.onap.ncmp:cmhandle-lcm-event");
+ lcmEventBase.setEventSchemaVersion("1.0");
}
}
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2023-2026 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 lombok.extern.slf4j.Slf4j;
import org.onap.cps.events.EventProducer;
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle;
-import org.onap.cps.ncmp.events.lcm.v1.LcmEvent;
-import org.onap.cps.ncmp.events.lcm.v1.Values;
+import org.onap.cps.ncmp.events.lcm.LcmEventBase;
+import org.onap.cps.ncmp.events.lcm.LcmEventV1;
+import org.onap.cps.ncmp.events.lcm.Values;
import org.onap.cps.ncmp.impl.utils.YangDataConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.KafkaException;
private void sendLcmEvent(final NcmpServiceCmHandle currentNcmpServiceCmHandle,
final NcmpServiceCmHandle targetNcmpServiceCmHandle) {
if (notificationsEnabled) {
- final LcmEvent lcmEvent = lcmEventObjectCreator.createLcmEvent(currentNcmpServiceCmHandle,
- targetNcmpServiceCmHandle);
+ final LcmEventV1 lcmEventV1 = lcmEventObjectCreator.createLcmEventV1(currentNcmpServiceCmHandle,
+ targetNcmpServiceCmHandle);
final Timer.Sample timerSample = Timer.start(meterRegistry);
try {
- final Map<String, Object> headersAsMap = extractHeadersAsMap(lcmEvent);
+ final Map<String, Object> headersAsMap = extractHeadersAsMap(lcmEventV1);
final String eventKey = currentNcmpServiceCmHandle.getCmHandleId();
- eventProducer.sendLegacyEvent(topicName, eventKey, headersAsMap, lcmEvent);
- recordMetrics(lcmEvent, timerSample);
+ eventProducer.sendLegacyEvent(topicName, eventKey, headersAsMap, lcmEventV1);
+ recordMetrics(lcmEventV1, timerSample);
} catch (final KafkaException e) {
log.error("Unable to send message to topic : {} and cause : {}", topicName, e.getMessage());
}
}
}
- private Map<String, Object> extractHeadersAsMap(final LcmEvent lcmEvent) {
+ private Map<String, Object> extractHeadersAsMap(final LcmEventBase lcmEventBase) {
final Map<String, Object> headersAsMap = new HashMap<>(7);
- headersAsMap.put("eventId", lcmEvent.getEventId());
- headersAsMap.put("eventCorrelationId", lcmEvent.getEventCorrelationId());
- headersAsMap.put("eventTime", lcmEvent.getEventTime());
- headersAsMap.put("eventSource", lcmEvent.getEventSource());
- headersAsMap.put("eventType", lcmEvent.getEventType());
- headersAsMap.put("eventSchema", lcmEvent.getEventSchema());
- headersAsMap.put("eventSchemaVersion", lcmEvent.getEventSchemaVersion());
+ headersAsMap.put("eventId", lcmEventBase.getEventId());
+ headersAsMap.put("eventCorrelationId", lcmEventBase.getEventCorrelationId());
+ headersAsMap.put("eventTime", lcmEventBase.getEventTime());
+ headersAsMap.put("eventSource", lcmEventBase.getEventSource());
+ headersAsMap.put("eventType", lcmEventBase.getEventType());
+ headersAsMap.put("eventSchema", lcmEventBase.getEventSchema());
+ headersAsMap.put("eventSchemaVersion", lcmEventBase.getEventSchemaVersion());
return headersAsMap;
}
- private void recordMetrics(final LcmEvent lcmEvent, final Timer.Sample timerSample) {
+ private void recordMetrics(final LcmEventV1 lcmEventV1, final Timer.Sample timerSample) {
final List<Tag> tags = new ArrayList<>(4);
tags.add(METRIC_TAG_CLASS);
tags.add(METRIC_TAG_METHOD);
- tags.add(createCmHandleStateTag("oldCmHandleState", lcmEvent.getEvent().getOldValues()));
- tags.add(createCmHandleStateTag("newCmHandleState", lcmEvent.getEvent().getNewValues()));
+ tags.add(createCmHandleStateTag("oldCmHandleState", lcmEventV1.getEvent().getOldValues()));
+ tags.add(createCmHandleStateTag("newCmHandleState", lcmEventV1.getEvent().getNewValues()));
timerSample.stop(Timer.builder("cps.ncmp.lcm.events.send")
.description("Time taken to send a LCM event")
.tags(tags)
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2026 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.
+ * 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.inventory.sync.lcm;
+
+public enum LcmEventVersion {
+ V1,
+ V2
+}
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2022-2026 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.apache.kafka.common.serialization.StringDeserializer
import org.onap.cps.events.EventProducer
import org.onap.cps.events.LegacyEvent
-import org.onap.cps.ncmp.events.lcm.v1.Event
-import org.onap.cps.ncmp.events.lcm.v1.LcmEvent
+import org.onap.cps.ncmp.events.lcm.LcmEventV1
+import org.onap.cps.ncmp.events.lcm.PayloadV1
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.ncmp.utils.events.MessagingBaseSpec
import org.onap.cps.utils.JsonObjectMapper
def eventType = 'org.onap.ncmp.cmhandle.lcm.event'
def eventSchema = 'org.onap.ncmp.cmhandle.lcm.event'
def eventSchemaVersion = 'v1'
- def eventData = new LcmEvent(
+ def lcmEventV1 = new LcmEventV1(
eventId: eventId,
eventCorrelationId: eventCorrelationId,
eventSource: eventSource,
eventType: eventType,
eventSchema: eventSchema,
eventSchemaVersion: eventSchemaVersion,
- event: new Event(cmHandleId: 'cmhandle-test'))
+ event: new PayloadV1(cmHandleId: 'cmhandle-test'))
and: 'we have a event header'
def eventHeader = [
eventId : eventId,
and: 'consumer has a subscription'
legacyEventKafkaConsumer.subscribe([testTopic] as List<String>)
when: 'an event is sent'
- eventProducer.sendLegacyEvent(testTopic, eventKey, eventHeader, eventData)
+ eventProducer.sendLegacyEvent(testTopic, eventKey, eventHeader, lcmEventV1)
and: 'topic is polled'
def records = legacyEventKafkaConsumer.poll(Duration.ofMillis(1500))
then: 'poll returns one record'
assert eventKey == records[0].key
and: 'record matches the expected event'
def expectedJsonString = TestUtils.getResourceFileContent('expectedLcmEvent.json')
- def expectedLcmEvent = jsonObjectMapper.convertJsonString(expectedJsonString, LcmEvent.class)
- assert expectedLcmEvent == jsonObjectMapper.convertJsonString(records[0].value, LcmEvent.class)
+ def expectedLcmEvent = jsonObjectMapper.convertJsonString(expectedJsonString, LcmEventV1.class)
+ assert expectedLcmEvent == jsonObjectMapper.convertJsonString(records[0].value, LcmEventV1.class)
and: 'record header matches the expected parameters'
assert SerializationUtils.deserialize(records[0].headers().lastHeader('eventId').value()) == eventId
assert SerializationUtils.deserialize(records[0].headers().lastHeader('eventCorrelationId').value()) == eventCorrelationId
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2024 Nordix Foundation
+ * Copyright (C) 2022-2026 Nordix Foundation
* ================================================================================
* 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.CmHandleState
import org.onap.cps.ncmp.api.inventory.models.CompositeState
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
-import org.onap.cps.ncmp.events.lcm.v1.Values
+import org.onap.cps.ncmp.events.lcm.Values
import spock.lang.Specification
import static org.onap.cps.ncmp.api.inventory.models.CmHandleState.ADVISED
def currentNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeState(dataSyncEnabled: true, cmHandleState: currentCmHandleState), publicProperties: currentPublicProperties)
def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeState(dataSyncEnabled: true, cmHandleState: targetCmHandleState), publicProperties: targetPublicProperties)
when: 'the lcm event is created'
- def result = objectUnderTest.createLcmEvent(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
+ def result = objectUnderTest.createLcmEventV1(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
then: 'event header is mapped correctly'
assert result.eventSource == 'org.onap.ncmp'
assert result.eventCorrelationId == cmHandleId
def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeState(dataSyncEnabled: true, cmHandleState: READY),
publicProperties: publicProperties)
when: 'the lcm event is created'
- def result = objectUnderTest.createLcmEvent(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
+ def result = objectUnderTest.createLcmEventV1(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
then: 'Properties are just the one which are same'
assert result.event.oldValues == null
assert result.event.newValues == null
publicProperties: ['publicProperty1': 'value11', 'publicProperty2': 'value22'])
def currentNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, publicProperties: ['publicProperty1': 'value1', 'publicProperty2': 'value2'])
when: 'the lcm event is created'
- def result = objectUnderTest.createLcmEvent(currentNcmpServiceCmHandle, targetNcmpServiceCmhandle)
+ def result = objectUnderTest.createLcmEventV1(currentNcmpServiceCmHandle, targetNcmpServiceCmhandle)
then: 'event header is mapped correctly'
assert result.eventSource == 'org.onap.ncmp'
assert result.eventCorrelationId == cmHandleId
def currentNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeState(dataSyncEnabled: true, cmHandleState: DELETING),
publicProperties: ['publicProperty1': 'value1'])
when: 'the lcm event is created'
- def result = objectUnderTest.createLcmEvent(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
+ def result = objectUnderTest.createLcmEventV1(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
then: 'event header is mapped correctly'
assert result.eventSource == 'org.onap.ncmp'
assert result.eventCorrelationId == cmHandleId
def currentNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeState(dataSyncEnabled: currentDataSyncEnableFlag, cmHandleState: ADVISED))
def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeState(dataSyncEnabled: targetDataSyncEnableFlag, cmHandleState: READY))
when: 'the lcm event is created'
- def result = objectUnderTest.createLcmEvent(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
+ def result = objectUnderTest.createLcmEventV1(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
then: 'event header is mapped correctly'
assert result.eventSource == 'org.onap.ncmp'
assert result.eventCorrelationId == cmHandleId
def currentNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeState(dataSyncEnabled: currentDataSyncEnableFlag, cmHandleState: ADVISED))
def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeState(dataSyncEnabled: targetDataSyncEnableFlag, cmHandleState: READY))
when: 'the lcm event is created'
- def result = objectUnderTest.createLcmEvent(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
+ def result = objectUnderTest.createLcmEventV1(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
then: 'the data sync flag is not present in the event'
assert result.event.oldValues.dataSyncEnabled == null
assert result.event.newValues.dataSyncEnabled == null
def currentNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: currentAlternateId, moduleSetTag: currentModuleSetTag, dataProducerIdentifier: currentDataProducerIdentifier, compositeState: new CompositeState(dataSyncEnabled: false))
def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: targetAlternateId, moduleSetTag: targetModuleSetTag, dataProducerIdentifier: targetDataProducerIdentifier, compositeState: new CompositeState(dataSyncEnabled: false))
when: 'the lcm event is created'
- def result = objectUnderTest.createLcmEvent(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
+ def result = objectUnderTest.createLcmEventV1(currentNcmpServiceCmHandle, targetNcmpServiceCmHandle)
then: 'the alternate ID, module set tag, and data producer identifier are present or are an empty string in the payload'
assert result.event.alternateId == targetAlternateId
assert result.event.moduleSetTag == targetModuleSetTag
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2022-2026 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.
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2026 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.
+ * 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.inventory.sync.lcm
+
+import spock.lang.Specification
+
+class LcmEventVersionSpec extends Specification {
+
+ def 'Enum values.'() {
+ expect: 'enum has expected values'
+ assert LcmEventVersion.values() == [LcmEventVersion.V1, LcmEventVersion.V2] as LcmEventVersion[]
+ }
+
+ def 'Enum valueOf.'() {
+ expect: 'valueOf returns correct enum constant'
+ assert LcmEventVersion.valueOf('V1') == LcmEventVersion.V1
+ assert LcmEventVersion.valueOf('V2') == LcmEventVersion.V2
+ }
+}
<gmavenplus.plugin.version>4.0.1</gmavenplus.plugin.version>
<jacoco.version>0.8.14</jacoco.version>
<java.version>17</java.version>
- <jsonschema2pojo.maven.plugin.version>1.2.1</jsonschema2pojo.maven.plugin.version>
+ <jsonschema2pojo.maven.plugin.version>1.2.2</jsonschema2pojo.maven.plugin.version>
<maven.checkstyle.plugin.version>3.3.1</maven.checkstyle.plugin.version>
<maven.compiler.plugin.version>3.13.0</maven.compiler.plugin.version>
<maven.compiler.release>17</maven.compiler.release>
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2022-2026 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.
handleLegacyEventCallback(topicName, eventFuture);
}
-
private void handleLegacyEventCallback(final String topicName,
final CompletableFuture<SendResult<String, LegacyEvent>> eventFuture) {
eventFuture.whenComplete((result, e) -> logOutcome(topicName, result, e));
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2024-2026 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.
package org.onap.cps.integration.functional.ncmp.inventory
-
import org.apache.kafka.clients.consumer.KafkaConsumer
import org.onap.cps.events.LegacyEvent
import org.onap.cps.integration.KafkaTestContainer
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.inventory.models.LockReasonCategory
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
-import org.onap.cps.ncmp.events.lcm.v1.LcmEvent
+import org.onap.cps.ncmp.events.lcm.LcmEventV1
import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import spock.util.concurrent.PollingConditions
def messages = []
def headerMaps = []
consumerRecords.each { consumerRecord ->
- messages.add(jsonObjectMapper.convertJsonString(consumerRecord.value().toString(), LcmEvent))
+ messages.add(jsonObjectMapper.convertJsonString(consumerRecord.value().toString(), LcmEventV1))
headerMaps.add(getHeadersAsMap(consumerRecord))
}
and: 'both messages have the correct common attributes (that did not change)'
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2024-2026 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.CmHandleRegistrationResponse
import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
-import org.onap.cps.ncmp.events.lcm.v1.LcmEvent
+import org.onap.cps.ncmp.events.lcm.LcmEventV1
import org.onap.cps.ncmp.impl.NetworkCmProxyInventoryFacadeImpl
import java.time.Duration
and: 'the message has the updated data producer identifier'
def notificationMessages = []
for (def consumerRecord : consumerRecords) {
- notificationMessages.add(jsonObjectMapper.convertJsonString(consumerRecord.value().toString(), LcmEvent))
+ notificationMessages.add(jsonObjectMapper.convertJsonString(consumerRecord.value().toString(), LcmEventV1))
}
assert notificationMessages[0].event.cmHandleId.contains(cmHandleId)
assert notificationMessages[0].event.dataProducerIdentifier == 'my-data-producer-id'