summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2022-06-23 15:14:31 +0100
committermpriyank <priyank.maheshwari@est.tech>2022-06-23 15:16:49 +0100
commit9e597b73b7eba2006785034cc49294a21b6f967d (patch)
treedcd10b0c7c9cfd48679c678a76f5c04a1f1b76c1
parent40a8211b8f8f4b244b43620776a71371bc5371d6 (diff)
Remove operation from NcmpEvent
- Remove operation field from NcmpEvent schema as it is not required - Code refactoring corresponding to removal of operation field - Fixed test cases around it - UPCOMING: Some sort of state machine to handle the event publishing Issue-ID: CPS-1100 Change-Id: Ib89b86bd1408de2808b01d37a48ee44a2601f83d Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
-rw-r--r--cps-ncmp-events/src/main/resources/schemas/ncmp-event-schema-v1.json5
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java10
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreator.java27
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsService.java13
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java10
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy6
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy4
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy15
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreatorSpec.groovy17
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsPublisherSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsServiceSpec.groovy14
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncSpec.groovy12
-rw-r--r--cps-ncmp-service/src/test/resources/expectedNcmpEvent.json1
14 files changed, 24 insertions, 118 deletions
diff --git a/cps-ncmp-events/src/main/resources/schemas/ncmp-event-schema-v1.json b/cps-ncmp-events/src/main/resources/schemas/ncmp-event-schema-v1.json
index 05a0e93b31..2dcc30e6ed 100644
--- a/cps-ncmp-events/src/main/resources/schemas/ncmp-event-schema-v1.json
+++ b/cps-ncmp-events/src/main/resources/schemas/ncmp-event-schema-v1.json
@@ -59,11 +59,6 @@
"description": "cmHandle id",
"type": "string"
},
- "operation": {
- "description": "The name of the Operation that triggered this event.",
- "type": "string",
- "enum": ["CREATE", "UPDATE", "DELETE"]
- },
"cmhandle-state": {
"description": "State of cmHandle.",
"type": "string",
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index 2c7d92ef40..f8cab4f1ca 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -31,7 +31,6 @@ import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NO_TIMES
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum;
import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED;
import static org.onap.cps.utils.CmHandleQueryRestParametersValidator.validateCmHandleQueryParameters;
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.DELETE;
import java.util.ArrayList;
import java.util.Collection;
@@ -47,7 +46,6 @@ import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.NetworkCmProxyCmHandlerQueryService;
import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
-import org.onap.cps.ncmp.api.impl.event.NcmpEventsService;
import org.onap.cps.ncmp.api.impl.operations.DmiDataOperations;
import org.onap.cps.ncmp.api.impl.operations.DmiOperations;
import org.onap.cps.ncmp.api.impl.utils.YangDataConverter;
@@ -95,8 +93,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
private final NetworkCmProxyCmHandlerQueryService networkCmProxyCmHandlerQueryService;
- private final NcmpEventsService ncmpEventsService;
-
@Override
public DmiPluginRegistrationResponse updateDmiRegistrationAndSyncModule(
final DmiPluginRegistration dmiPluginRegistration) {
@@ -265,8 +261,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
cpsDataService.deleteListOrListElement(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
"/dmi-registry/cm-handles[@id='" + cmHandle + "']", NO_TIMESTAMP);
cmHandleRegistrationResponses.add(CmHandleRegistrationResponse.createSuccessResponse(cmHandle));
- log.debug("Publishing LCM Delete Event for cmHandleId : {}", cmHandle);
- ncmpEventsService.publishNcmpEvent(cmHandle, DELETE);
} catch (final DataNodeNotFoundException dataNodeNotFoundException) {
log.error("Unable to find dataNode for cmHandleId : {} , caused by : {}",
cmHandle, dataNodeNotFoundException.getMessage());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
index 1eef4c25f3..aae2f209ae 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
@@ -27,7 +27,6 @@ import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NCMP_DAT
import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NCMP_DMI_REGISTRY_ANCHOR;
import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NCMP_DMI_REGISTRY_PARENT;
import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NO_TIMESTAMP;
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.UPDATE;
import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
@@ -41,7 +40,6 @@ import java.util.regex.Pattern;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.api.CpsDataService;
-import org.onap.cps.ncmp.api.impl.event.NcmpEventsService;
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse;
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
@@ -64,8 +62,6 @@ public class NetworkCmProxyDataServicePropertyHandler {
private final CpsDataService cpsDataService;
- private final NcmpEventsService ncmpEventsService;
-
/**
* Iterates over incoming ncmpServiceCmHandles and update the dataNodes based on the updated attributes.
* The attributes which are not passed will remain as is.
@@ -109,7 +105,6 @@ public class NetworkCmProxyDataServicePropertyHandler {
private void processUpdates(final DataNode existingCmHandleDataNode, final NcmpServiceCmHandle incomingCmHandle) {
if (!incomingCmHandle.getPublicProperties().isEmpty()) {
updateProperties(existingCmHandleDataNode, PUBLIC_PROPERTY, incomingCmHandle.getPublicProperties());
- publishLcmEventOnPublicPropertiesUpdate(incomingCmHandle.getCmHandleId());
}
if (!incomingCmHandle.getDmiProperties().isEmpty()) {
updateProperties(existingCmHandleDataNode, DMI_PROPERTY, incomingCmHandle.getDmiProperties());
@@ -185,11 +180,6 @@ public class NetworkCmProxyDataServicePropertyHandler {
return new DataNodeBuilder().withXpath(xpath).withLeaves(ImmutableMap.copyOf(updatedLeaves)).build();
}
- private void publishLcmEventOnPublicPropertiesUpdate(final String cmHandleId) {
- log.debug("Publishing LCM Update event for cmHandleId : {}", cmHandleId);
- ncmpEventsService.publishNcmpEvent(cmHandleId, UPDATE);
- }
-
enum PropertyType {
DMI_PROPERTY("additional-properties"), PUBLIC_PROPERTY("public-properties");
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreator.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreator.java
index 3fca1bae84..df41eba8bd 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreator.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreator.java
@@ -20,8 +20,6 @@
package org.onap.cps.ncmp.api.impl.event;
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.DELETE;
-
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@@ -29,7 +27,6 @@ import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.ncmp.cmhandle.lcm.event.Event;
-import org.onap.ncmp.cmhandle.lcm.event.Event.Operation;
import org.onap.ncmp.cmhandle.lcm.event.NcmpEvent;
import org.springframework.stereotype.Component;
@@ -46,33 +43,25 @@ public class NcmpEventsCreator {
* Populate NcmpEvent.
*
* @param cmHandleId Cm Handle Identifier
- * @param operation Relevant Operation
* @param ncmpServiceCmHandle Ncmp CmHandle Data
* @return Populated NcmpEvent
*/
- public NcmpEvent populateNcmpEvent(final String cmHandleId, final Operation operation,
- final NcmpServiceCmHandle ncmpServiceCmHandle) {
- return createNcmpEvent(cmHandleId, operation, ncmpServiceCmHandle);
+ public NcmpEvent populateNcmpEvent(final String cmHandleId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ return createNcmpEvent(cmHandleId, ncmpServiceCmHandle);
}
- private NcmpEvent createNcmpEvent(final String cmHandleId, final Operation operation,
- final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ private NcmpEvent createNcmpEvent(final String cmHandleId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
final NcmpEvent ncmpEvent = ncmpEventHeader(cmHandleId);
- ncmpEvent.setEvent(ncmpEventPayload(cmHandleId, operation, ncmpServiceCmHandle));
+ ncmpEvent.setEvent(ncmpEventPayload(cmHandleId, ncmpServiceCmHandle));
return ncmpEvent;
}
- private Event ncmpEventPayload(final String eventCorrelationId, final Operation operation,
- final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ private Event ncmpEventPayload(final String eventCorrelationId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
final Event event = new Event();
- event.setOperation(operation);
event.setCmHandleId(eventCorrelationId);
-
- if (!DELETE.equals(operation)) {
- event.setCmhandleState(Event.CmhandleState.fromValue(
- ncmpServiceCmHandle.getCompositeState().getCmHandleState().toString()));
- event.setCmhandleProperties(List.of(ncmpServiceCmHandle.getPublicProperties()));
- }
+ event.setCmhandleState(
+ Event.CmhandleState.fromValue(ncmpServiceCmHandle.getCompositeState().getCmHandleState().toString()));
+ event.setCmhandleProperties(List.of(ncmpServiceCmHandle.getPublicProperties()));
return event;
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsService.java
index 3cd4068a9e..6804ac0f0b 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsService.java
@@ -25,7 +25,6 @@ import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.impl.utils.YangDataConverter;
import org.onap.cps.ncmp.api.inventory.InventoryPersistence;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
-import org.onap.ncmp.cmhandle.lcm.event.Event.Operation;
import org.onap.ncmp.cmhandle.lcm.event.NcmpEvent;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -52,16 +51,12 @@ public class NcmpEventsService {
* Publish the NcmpEvent to the public topic.
*
* @param cmHandleId Cm Handle Id
- * @param operation Relevant operation(CREATE,UPDATE or DELETE)
*/
- public void publishNcmpEvent(final String cmHandleId, final Operation operation) {
+ public void publishNcmpEvent(final String cmHandleId) {
- NcmpServiceCmHandle ncmpServiceCmHandle = new NcmpServiceCmHandle();
- if (Operation.DELETE != operation) {
- ncmpServiceCmHandle = YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(
- inventoryPersistence.getYangModelCmHandle(cmHandleId));
- }
- final NcmpEvent ncmpEvent = ncmpEventsCreator.populateNcmpEvent(cmHandleId, operation, ncmpServiceCmHandle);
+ final NcmpServiceCmHandle ncmpServiceCmHandle = YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(
+ inventoryPersistence.getYangModelCmHandle(cmHandleId));
+ final NcmpEvent ncmpEvent = ncmpEventsCreator.populateNcmpEvent(cmHandleId, ncmpServiceCmHandle);
ncmpEventsPublisher.publishEvent(topicName, cmHandleId, ncmpEvent);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
index 9cfa0a05c8..c920649b8b 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
@@ -21,12 +21,9 @@
package org.onap.cps.ncmp.api.inventory.sync;
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.CREATE;
-
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.api.impl.event.NcmpEventsService;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.inventory.CmHandleState;
import org.onap.cps.ncmp.api.inventory.CompositeState;
@@ -47,11 +44,8 @@ public class ModuleSyncWatchdog {
private final ModuleSyncService moduleSyncService;
- private final NcmpEventsService ncmpEventsService;
-
/**
* Execute Cm Handle poll which changes the cm handle state from 'ADVISED' to 'READY'.
- * Also publish the LCM Create Event when cm handle state is moved to 'READY'.
*/
@Scheduled(fixedDelayString = "${timers.advised-modules-sync.sleep-time-ms:30000}")
public void executeAdvisedCmHandlePoll() {
@@ -72,10 +66,6 @@ public class ModuleSyncWatchdog {
inventoryPersistence.saveCmHandleState(cmHandleId, compositeState);
log.info("{} is now in {} state", cmHandleId,
advisedCmHandle.getCompositeState().getCmHandleState());
- if (compositeState.getCmHandleState() == CmHandleState.READY) {
- log.debug("Publishing LCM Create Event for cmHandleId : {}", cmHandleId);
- ncmpEventsService.publishNcmpEvent(cmHandleId, CREATE);
- }
advisedCmHandle = syncUtils.getAnAdvisedCmHandle();
}
log.debug("No Cm-Handles currently found in an ADVISED state");
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
index 8a45e66971..5357c42b7d 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
@@ -23,8 +23,6 @@ package org.onap.cps.ncmp.api.impl
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.api.NetworkCmProxyCmHandlerQueryService
-import org.onap.cps.ncmp.api.impl.event.NcmpEventsService
-import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
@@ -67,8 +65,6 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def mockInventoryPersistence = Mock(InventoryPersistence)
def mockModuleSyncService = Mock(ModuleSyncService)
def stubbedNetworkCmProxyCmHandlerQueryService = Stub(NetworkCmProxyCmHandlerQueryService)
- def mockNcmpEventsService = Mock(NcmpEventsService)
-
def noTimestamp = null
def objectUnderTest = getObjectUnderTest()
@@ -352,6 +348,6 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
def getObjectUnderTest() {
return Spy(new NetworkCmProxyDataServiceImpl(mockCpsDataService, spiedJsonObjectMapper, mockDmiDataOperations,
mockCpsModuleService, mockCpsAdminService, mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence,
- mockModuleSyncService, stubbedNetworkCmProxyCmHandlerQueryService, mockNcmpEventsService))
+ mockModuleSyncService, stubbedNetworkCmProxyCmHandlerQueryService))
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
index 783fabb1d3..d58fe6a7cd 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
@@ -23,7 +23,6 @@
package org.onap.cps.ncmp.api.impl
import org.onap.cps.ncmp.api.NetworkCmProxyCmHandlerQueryService
-import org.onap.cps.ncmp.api.impl.event.NcmpEventsService
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import org.onap.cps.ncmp.api.inventory.CmHandleState
import org.onap.cps.ncmp.api.inventory.CompositeState
@@ -67,7 +66,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
def mockModuleSyncService = Mock(ModuleSyncService)
def mockDmiPluginRegistration = Mock(DmiPluginRegistration)
def mockCpsCmHandlerQueryService = Mock(NetworkCmProxyCmHandlerQueryService)
- def mockNcmpEventsService = Mock(NcmpEventsService)
def NO_TOPIC = null
def NO_REQUEST_ID = null
@@ -78,7 +76,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
def objectUnderTest = new NetworkCmProxyDataServiceImpl(mockCpsDataService, spiedJsonObjectMapper, mockDmiDataOperations,
mockCpsModuleService, mockCpsAdminService, nullNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence,
- mockModuleSyncService, mockCpsCmHandlerQueryService, mockNcmpEventsService)
+ mockModuleSyncService, mockCpsCmHandlerQueryService)
def cmHandleXPath = "/dmi-registry/cm-handles[@id='testCmHandle']"
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
index 0cf04a9ff3..3efc9c43b9 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
@@ -21,14 +21,12 @@
package org.onap.cps.ncmp.api.impl
-import org.onap.cps.ncmp.api.impl.event.NcmpEventsService
import org.onap.cps.spi.exceptions.DataValidationException
import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_DOES_NOT_EXIST
import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_INVALID_ID
import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.UNKNOWN_ERROR
import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.Status
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.UPDATE
import org.onap.cps.api.CpsDataService
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
@@ -41,9 +39,8 @@ import spock.lang.Specification
class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
def mockCpsDataService = Mock(CpsDataService)
- def mockNcmpEventsService = Mock(NcmpEventsService)
- def objectUnderTest = new NetworkCmProxyDataServicePropertyHandler(mockCpsDataService, mockNcmpEventsService)
+ def objectUnderTest = new NetworkCmProxyDataServicePropertyHandler(mockCpsDataService)
def dataspaceName = 'NCMP-Admin'
def anchorName = 'ncmp-dmi-registry'
def static cmHandleId = 'myHandle1'
@@ -70,8 +67,6 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
assert args[3].leaves.containsAll(convertToProperties(expectedPropertiesAfterUpdate))
}
}
- and: 'ncmp event is published'
- 1 * mockNcmpEventsService.publishNcmpEvent(cmHandleId, UPDATE)
where: 'following public properties updates are made'
scenario | updatedPublicProperties || expectedPropertiesAfterUpdate
'property added' | ['newPubProp1': 'pub-val'] || [['publicProp3': 'publicValue3'], ['publicProp4': 'publicValue4'], ['newPubProp1': 'pub-val']]
@@ -94,8 +89,6 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
assert args[3].leaves.containsAll(convertToProperties(expectedPropertiesAfterUpdate))
}
}
- and: 'ncmp event is not published on dmi properties update'
- 0 * mockNcmpEventsService.publishNcmpEvent(_, _)
where: 'following DMI properties updates are made'
scenario | updatedDmiProperties || expectedPropertiesAfterUpdate | expectedCallsToReplaceMethod
'property added' | ['newAdditionalProp1': 'add-value'] || [['additionalProp1': 'additionalValue1'], ['additionalProp2': 'additionalValue2'], ['newAdditionalProp1': 'add-value']] | 1
@@ -121,8 +114,6 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
assert arg[2].contains("@name='publicProp")
}
}
- and: 'ncmp event is published with updated public properties'
- 1 * mockNcmpEventsService.publishNcmpEvent(cmHandleId, UPDATE)
where: 'following public properties updates are made'
scenario | originalPropertyDataNodes || expectedCallsToDeleteDataNode
'2 original properties, both removed' | propertyDataNodes || 2
@@ -145,8 +136,6 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
assert it.registrationError == expectedError
assert it.errorText == expectedErrorText
}
- and: 'ncmp event is not published'
- 0 * mockNcmpEventsService.publishNcmpEvent(_, _)
where:
scenario | cmHandleId | exception || expectedError | expectedErrorText
'Cm Handle does not exist' | 'cmHandleId' | new DataNodeNotFoundException('NCMP-Admin', 'ncmp-dmi-registry') || CM_HANDLE_DOES_NOT_EXIST | 'cm-handle does not exist'
@@ -183,8 +172,6 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
}
then: 'the replace list method is called twice'
2 * mockCpsDataService.replaceListContent(dataspaceName, anchorName, cmHandleXpath, _, noTimeStamp)
- and: 'the ncmp event is published'
- 2 * mockNcmpEventsService.publishNcmpEvent(cmHandleId, UPDATE)
}
def convertToProperties(expectedPropertiesAfterUpdateAsMap) {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreatorSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreatorSpec.groovy
index ae38714e25..24362ee47c 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreatorSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreatorSpec.groovy
@@ -25,10 +25,6 @@ import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
import spock.lang.Specification
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.CREATE
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.DELETE
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.UPDATE
-
class NcmpEventsCreatorSpec extends Specification {
def objectUnderTest = new NcmpEventsCreator()
@@ -39,19 +35,12 @@ class NcmpEventsCreatorSpec extends Specification {
def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, compositeState: new CompositeStateBuilder().withCmHandleState(CmHandleState.READY).build(),
publicProperties: ['publicProperty1': 'value1', 'publicProperty2': 'value2'])
when: 'the event is populated'
- def result = objectUnderTest.populateNcmpEvent(cmHandleId, operation, ncmpServiceCmHandle)
+ def result = objectUnderTest.populateNcmpEvent(cmHandleId, ncmpServiceCmHandle)
then: 'event header is mapped correctly'
assert result.eventSource == 'org.onap.ncmp'
assert result.eventCorrelationId == cmHandleId
and: 'event payload is mapped correctly'
- assert result.event.operation == operation
- assert (result.event.cmhandleProperties != null) ? result.event.cmhandleProperties.size() : 0 == cmHandlePropertiesListSize
- assert (result.event.cmhandleProperties != null) ? result.event.cmhandleProperties[0] : null == cmHandleProperties
- where: 'the following operations are used'
- operation | cmHandlePropertiesListSize | cmHandleProperties
- CREATE | 1 | ['publicProperty1': 'value1', 'publicProperty2': 'value2']
- UPDATE | 1 | ['publicProperty1': 'value1', 'publicProperty2': 'value2']
- DELETE | 0 | null
-
+ assert result.event.cmhandleProperties.size() == 1
+ assert result.event.cmhandleProperties[0] == ['publicProperty1': 'value1', 'publicProperty2': 'value2']
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsPublisherSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsPublisherSpec.groovy
index 774a46558b..fa486d04e0 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsPublisherSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsPublisherSpec.groovy
@@ -60,7 +60,7 @@ class NcmpEventsPublisherSpec extends MessagingSpec {
eventSource: URI.create('org.onap.ncmp'),
eventTime: '2022-12-31T20:30:40.000+0000',
eventType: 'org.onap.ncmp.cmhandle.lcm.event',
- event: new Event(cmHandleId: 'cmhandle-test', cmhandleState: 'READY', operation: 'CREATE', cmhandleProperties: [['publicProperty1': 'value1'], ['publicProperty2': 'value2']]))
+ event: new Event(cmHandleId: 'cmhandle-test', cmhandleState: 'READY', cmhandleProperties: [['publicProperty1': 'value1'], ['publicProperty2': 'value2']]))
and: 'we have an expected NcmpEvent'
def expectedJsonString = TestUtils.getResourceFileContent('expectedNcmpEvent.json')
def expectedNcmpEvent = jsonObjectMapper.convertJsonString(expectedJsonString, NcmpEvent.class)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsServiceSpec.groovy
index 9774235561..e265fef054 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsServiceSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/NcmpEventsServiceSpec.groovy
@@ -26,10 +26,6 @@ import org.onap.cps.ncmp.api.inventory.InventoryPersistence
import org.onap.ncmp.cmhandle.lcm.event.NcmpEvent
import spock.lang.Specification
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.CREATE
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.DELETE
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.UPDATE
-
class NcmpEventsServiceSpec extends Specification {
def mockInventoryPersistence = Mock(InventoryPersistence)
@@ -40,23 +36,21 @@ class NcmpEventsServiceSpec extends Specification {
def 'Create and Publish event for #operation'() {
given: 'a cm handle id and operation and responses are mocked'
- mockResponses('test-cm-handle-id', operation, 'test-topic')
+ mockResponses('test-cm-handle-id', 'test-topic')
when: 'service is called to publish ncmp event'
- objectUnderTest.publishNcmpEvent('test-cm-handle-id', operation)
+ objectUnderTest.publishNcmpEvent('test-cm-handle-id')
then: 'no exception is thrown'
noExceptionThrown()
- where: 'for following operations'
- operation << [CREATE, UPDATE, DELETE]
}
- def mockResponses(cmHandleId, operation, topicName) {
+ def mockResponses(cmHandleId, topicName) {
def yangModelCmHandle = new YangModelCmHandle(id: cmHandleId, publicProperties: [new YangModelCmHandle.Property('publicProperty1', 'value1')], dmiProperties: [])
def ncmpEvent = new NcmpEvent(eventId: UUID.randomUUID().toString(), eventCorrelationId: cmHandleId)
def ncmpServiceCmhandle = YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(yangModelCmHandle)
mockInventoryPersistence.getYangModelCmHandle(cmHandleId) >> yangModelCmHandle
- mockNcmpEventsMapper.populateNcmpEvent(cmHandleId, operation, ncmpServiceCmhandle) >> ncmpEvent
+ mockNcmpEventsMapper.populateNcmpEvent(cmHandleId, ncmpServiceCmhandle) >> ncmpEvent
mockNcmpEventsPublisher.publishEvent(topicName, cmHandleId, ncmpEvent) >> {}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncSpec.groovy
index 8752bff582..614783efd7 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncSpec.groovy
@@ -21,9 +21,6 @@
package org.onap.cps.ncmp.api.inventory.sync
-import static org.onap.ncmp.cmhandle.lcm.event.Event.Operation.CREATE
-
-import org.onap.cps.ncmp.api.impl.event.NcmpEventsService
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import org.onap.cps.ncmp.api.inventory.CmHandleState
import org.onap.cps.ncmp.api.inventory.CompositeState
@@ -40,11 +37,9 @@ class ModuleSyncSpec extends Specification {
def mockModuleSyncService = Mock(ModuleSyncService)
- def mockNcmpEventsService = Mock(NcmpEventsService)
-
def cmHandleState = CmHandleState.ADVISED
- def objectUnderTest = new ModuleSyncWatchdog(mockInventoryPersistence, mockSyncUtils, mockModuleSyncService, mockNcmpEventsService)
+ def objectUnderTest = new ModuleSyncWatchdog(mockInventoryPersistence, mockSyncUtils, mockModuleSyncService)
def 'Schedule a Cm-Handle Sync for ADVISED Cm-Handles'() {
given: 'cm handles in an advised state'
@@ -72,9 +67,6 @@ class ModuleSyncSpec extends Specification {
assert compositeState2.getCmHandleState() == CmHandleState.READY
and: 'the second cm handle state is updated'
1 * mockInventoryPersistence.saveCmHandleState('some-cm-handle-2', compositeState2)
- and: 'the ncmp event will be published for both cmHandles'
- 1 * mockNcmpEventsService.publishNcmpEvent('some-cm-handle', CREATE)
- 1 * mockNcmpEventsService.publishNcmpEvent('some-cm-handle-2', CREATE)
}
def 'Schedule a Cm-Handle Sync for ADVISED Cm-Handle with failure'() {
@@ -95,8 +87,6 @@ class ModuleSyncSpec extends Specification {
1 * mockSyncUtils.updateLockReasonDetailsAndAttempts(compositeState, LockReasonCategory.LOCKED_MISBEHAVING ,'some exception')
and: 'the cm handle state is updated'
1 * mockInventoryPersistence.saveCmHandleState('some-cm-handle', compositeState)
- and: 'the ncmp event is not published'
- 0 * mockNcmpEventsService.publishNcmpEvent(_, _)
}
diff --git a/cps-ncmp-service/src/test/resources/expectedNcmpEvent.json b/cps-ncmp-service/src/test/resources/expectedNcmpEvent.json
index 903bc3aab8..3d457a0a3d 100644
--- a/cps-ncmp-service/src/test/resources/expectedNcmpEvent.json
+++ b/cps-ncmp-service/src/test/resources/expectedNcmpEvent.json
@@ -7,7 +7,6 @@
"eventSchema": "org.onap.ncmp.cmhandle.lcm.event:v1",
"event": {
"cmHandleId": "cmhandle-test",
- "operation": "CREATE",
"cmhandle-state": "READY",
"cmhandle-properties": [
{