diff options
author | mpriyank <priyank.maheshwari@est.tech> | 2024-09-06 10:44:47 +0100 |
---|---|---|
committer | mpriyank <priyank.maheshwari@est.tech> | 2024-09-06 10:44:54 +0100 |
commit | 204c4e90c58aae5b72aa4085265be8dd8fc6a57c (patch) | |
tree | 0b8fa6e42a4306a12051d4120c8c5ffb0e6f5580 /dmi-service/src/main | |
parent | 77fd08845b489fb7880b2c51e62a3548c4b0a947 (diff) |
Update cps version in DMI plugin
- updated cps version to 3.5.2 i.e the latest released version
- updated corresponding dependant code from cps ncmp
- Fixed the testware
Issue-ID: CPS-2401
Change-Id: I8c3ed7cbdef11a195b86088006fd0e1e7642a572
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'dmi-service/src/main')
-rw-r--r-- | dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/avc/DmiDataAvcCloudEventCreator.java | 5 | ||||
-rw-r--r-- | dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiInEventConsumer.java (renamed from dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumer.java) | 50 | ||||
-rw-r--r-- | dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiOutEventToCloudEventMapper.java (renamed from dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiOutEventToCloudEventMapper.java) | 10 |
3 files changed, 31 insertions, 34 deletions
diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/avc/DmiDataAvcCloudEventCreator.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/avc/DmiDataAvcCloudEventCreator.java index b8bd277d..7dcc0122 100644 --- a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/avc/DmiDataAvcCloudEventCreator.java +++ b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/avc/DmiDataAvcCloudEventCreator.java @@ -39,7 +39,6 @@ import org.onap.cps.ncmp.events.avc1_0_0.DatastoreChanges; import org.onap.cps.ncmp.events.avc1_0_0.Edit; import org.onap.cps.ncmp.events.avc1_0_0.IetfYangPatchYangPatch; import org.onap.cps.ncmp.events.avc1_0_0.PushChangeUpdate; -import org.onap.cps.ncmp.events.avc1_0_0.Value; /** * Helper to create AvcEvents. @@ -84,14 +83,12 @@ public class DmiDataAvcCloudEventCreator { final IetfYangPatchYangPatch ietfYangPatchYangPatch = new IetfYangPatchYangPatch(); ietfYangPatchYangPatch.setPatchId("abcd"); final Edit edit1 = new Edit(); - final Value value = new Value(); final Map<String, Object> attributeMap = new LinkedHashMap<>(); attributeMap.put("isHoAllowed", false); - value.setAttributes(List.of(attributeMap)); edit1.setEditId("editId"); edit1.setOperation("replace"); edit1.setTarget("target_xpath"); - edit1.setValue(value); + edit1.setValue(List.of(attributeMap)); ietfYangPatchYangPatch.setEdit(List.of(edit1)); datastoreChanges.setIetfYangPatchYangPatch(ietfYangPatchYangPatch); pushChangeUpdate.setDatastoreChanges(datastoreChanges); diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumer.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiInEventConsumer.java index 3a9838b0..9df74504 100644 --- a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumer.java +++ b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiInEventConsumer.java @@ -25,9 +25,9 @@ import lombok.RequiredArgsConstructor; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.onap.cps.ncmp.dmi.notifications.cmsubscription.model.CmNotificationSubscriptionStatus; import org.onap.cps.ncmp.dmi.notifications.mapper.CloudEventMapper; -import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.dmi_to_ncmp.CmNotificationSubscriptionDmiOutEvent; -import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.dmi_to_ncmp.Data; -import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.ncmp_to_dmi.CmNotificationSubscriptionDmiInEvent; +import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.Data; +import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.DmiOutEvent; +import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_dmi.DmiInEvent; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.core.KafkaTemplate; @@ -35,31 +35,31 @@ import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor -public class CmNotificationSubscriptionDmiInEventConsumer { +public class DmiInEventConsumer { @Value("${app.dmi.avc.cm-subscription-dmi-out}") - private String cmNotificationSubscriptionDmiOutTopic; + private String dmoOutEventTopic; @Value("${dmi.service.name}") private String dmiName; private final KafkaTemplate<String, CloudEvent> cloudEventKafkaTemplate; /** - * Consume the cmNotificationSubscriptionDmiInCloudEvent event. + * Consume the DmiInCloudEvent. * - * @param cmNotificationSubscriptionDmiInCloudEvent the event to be consumed + * @param dmiInCloudEvent the event to be consumed */ @KafkaListener(topics = "${app.dmi.avc.cm-subscription-dmi-in}", containerFactory = "cloudEventConcurrentKafkaListenerContainerFactory") - public void consumeCmNotificationSubscriptionDmiInEvent( - final ConsumerRecord<String, CloudEvent> cmNotificationSubscriptionDmiInCloudEvent) { - final CmNotificationSubscriptionDmiInEvent cmNotificationSubscriptionDmiInEvent = - CloudEventMapper.toTargetEvent(cmNotificationSubscriptionDmiInCloudEvent.value(), - CmNotificationSubscriptionDmiInEvent.class); + public void consumeDmiInEvent( + final ConsumerRecord<String, CloudEvent> dmiInCloudEvent) { + final DmiInEvent cmNotificationSubscriptionDmiInEvent = + CloudEventMapper.toTargetEvent(dmiInCloudEvent.value(), + DmiInEvent.class); if (cmNotificationSubscriptionDmiInEvent != null) { - final String subscriptionId = cmNotificationSubscriptionDmiInCloudEvent.value().getId(); - final String subscriptionType = cmNotificationSubscriptionDmiInCloudEvent.value().getType(); - final String correlationId = String.valueOf(cmNotificationSubscriptionDmiInCloudEvent.value() + final String subscriptionId = dmiInCloudEvent.value().getId(); + final String subscriptionType = dmiInCloudEvent.value().getType(); + final String correlationId = String.valueOf(dmiInCloudEvent.value() .getExtension("correlationid")); if ("subscriptionCreateRequest".equals(subscriptionType)) { @@ -84,21 +84,21 @@ public class CmNotificationSubscriptionDmiInEventConsumer { final String eventKey, final String subscriptionType, final String correlationId, final CmNotificationSubscriptionStatus cmNotificationSubscriptionStatus) { - final CmNotificationSubscriptionDmiOutEvent cmNotificationSubscriptionDmiOutEvent = - new CmNotificationSubscriptionDmiOutEvent(); - final Data cmNotificationSubscriptionDmiOutEventData = new Data(); + final DmiOutEvent cmNotificationSubscriptionDmiOutEvent = + new DmiOutEvent(); + final Data dmiOutEventData = new Data(); if (cmNotificationSubscriptionStatus.equals(CmNotificationSubscriptionStatus.ACCEPTED)) { - cmNotificationSubscriptionDmiOutEventData.setStatusCode("1"); - cmNotificationSubscriptionDmiOutEventData.setStatusMessage("ACCEPTED"); + dmiOutEventData.setStatusCode("1"); + dmiOutEventData.setStatusMessage("ACCEPTED"); } else { - cmNotificationSubscriptionDmiOutEventData.setStatusCode("104"); - cmNotificationSubscriptionDmiOutEventData.setStatusMessage("REJECTED"); + dmiOutEventData.setStatusCode("104"); + dmiOutEventData.setStatusMessage("REJECTED"); } - cmNotificationSubscriptionDmiOutEvent.setData(cmNotificationSubscriptionDmiOutEventData); + cmNotificationSubscriptionDmiOutEvent.setData(dmiOutEventData); - cloudEventKafkaTemplate.send(cmNotificationSubscriptionDmiOutTopic, eventKey, - CmNotificationSubscriptionDmiOutEventToCloudEventMapper.toCloudEvent(cmNotificationSubscriptionDmiOutEvent, + cloudEventKafkaTemplate.send(dmoOutEventTopic, eventKey, + DmiOutEventToCloudEventMapper.toCloudEvent(cmNotificationSubscriptionDmiOutEvent, subscriptionType, dmiName, correlationId)); } diff --git a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiOutEventToCloudEventMapper.java b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiOutEventToCloudEventMapper.java index 51205da2..fd42c400 100644 --- a/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiOutEventToCloudEventMapper.java +++ b/dmi-service/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiOutEventToCloudEventMapper.java @@ -28,23 +28,23 @@ import java.util.UUID; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.onap.cps.ncmp.dmi.exception.CloudEventConstructionException; -import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.dmi_to_ncmp.CmNotificationSubscriptionDmiOutEvent; +import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.DmiOutEvent; @NoArgsConstructor(access = AccessLevel.PRIVATE) -public class CmNotificationSubscriptionDmiOutEventToCloudEventMapper { +public class DmiOutEventToCloudEventMapper { private static final ObjectMapper objectMapper = new ObjectMapper(); /** * Maps SubscriptionEventResponse to a CloudEvent. * - * @param cmSubscriptionDmiOutEvent object. + * @param dmiOutEvent object. * @param subscriptionType String of subscription type. * @param dmiName String of dmiName. * @param correlationId String of correlationId. * @return CloudEvent built. */ - public static CloudEvent toCloudEvent(final CmNotificationSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent, + public static CloudEvent toCloudEvent(final DmiOutEvent dmiOutEvent, final String subscriptionType, final String dmiName, final String correlationId) { try { @@ -52,7 +52,7 @@ public class CmNotificationSubscriptionDmiOutEventToCloudEventMapper { .withType(subscriptionType) .withDataSchema(URI.create("urn:cps:org.onap.ncmp.dmi.cm.subscription:1.0.0")) .withExtension("correlationid", correlationId) - .withData(objectMapper.writeValueAsBytes(cmSubscriptionDmiOutEvent)).build(); + .withData(objectMapper.writeValueAsBytes(dmiOutEvent)).build(); } catch (final Exception ex) { throw new CloudEventConstructionException("The Cloud Event could not be constructed", "Invalid object passed", ex); |