summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src
diff options
context:
space:
mode:
authorDylanB95EST <dylan.byrne@est.tech>2022-02-21 12:57:08 +0000
committerBruno Sakoto <bruno.sakoto@bell.ca>2022-02-28 21:52:25 +0000
commitd042fcdae75be100f840b6313e078eab278d87ef (patch)
treeee5bba86b3ba00205334a1fe6ca41c0824097afd /cps-ncmp-service/src
parente0643ab5130dde375c229989e216341e623a9c55 (diff)
NCMP Java API depends on NCM-Rest-API (cyclic) through json properties on Java API
Using POJO and new converter class instead of previous object mapper Issue-ID: CPS-893 Change-Id: I75531f386f08cb172d2901a4bbe97ae22cc5937e Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
Diffstat (limited to 'cps-ncmp-service/src')
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java8
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandle.java4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/PersistenceCmHandlesList.java2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy19
5 files changed, 15 insertions, 30 deletions
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 aac44e43ec..446e45b2b8 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
@@ -81,15 +81,13 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
public void updateDmiRegistrationAndSyncModule(final DmiPluginRegistration dmiPluginRegistration) {
dmiPluginRegistration.validateDmiPluginRegistration();
try {
- if (dmiPluginRegistration.getCreatedCmHandles() != null) {
+ if (!dmiPluginRegistration.getCreatedCmHandles().isEmpty()) {
parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(dmiPluginRegistration);
}
- if (dmiPluginRegistration.getUpdatedCmHandles() != null) {
+ if (!dmiPluginRegistration.getUpdatedCmHandles().isEmpty()) {
parseAndUpdateCmHandlesInDmiRegistration(dmiPluginRegistration);
}
- if (dmiPluginRegistration.getRemovedCmHandles() != null) {
- parseAndRemoveCmHandlesInDmiRegistration(dmiPluginRegistration);
- }
+ parseAndRemoveCmHandlesInDmiRegistration(dmiPluginRegistration);
} catch (final JsonProcessingException | DataNodeNotFoundException e) {
final String errorMessage = String.format(
"Error occurred while processing the CM-handle registration request, caused by : [%s]",
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandle.java
index 9a9b6faaf9..88c6f33762 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandle.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandle.java
@@ -20,7 +20,6 @@
package org.onap.cps.ncmp.api.models;
-import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import java.util.Collections;
@@ -39,15 +38,12 @@ import org.springframework.validation.annotation.Validated;
@NoArgsConstructor
public class CmHandle {
- @JsonProperty("cmHandle")
private String cmHandleID;
@JsonSetter(nulls = Nulls.AS_EMPTY)
- @JsonProperty("cmHandleProperties")
private Map<String, String> dmiProperties = Collections.emptyMap();
@JsonSetter(nulls = Nulls.AS_EMPTY)
- @JsonProperty("publicCmHandleProperties")
private Map<String, String> publicProperties = Collections.emptyMap();
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java
index f1b3888c6e..c302f7de5a 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java
@@ -22,9 +22,8 @@ package org.onap.cps.ncmp.api.models;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonSetter;
-import com.fasterxml.jackson.annotation.Nulls;
import com.google.common.base.Strings;
+import java.util.Collections;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
@@ -39,20 +38,17 @@ import org.onap.cps.ncmp.api.impl.exception.NcmpException;
@JsonInclude(Include.NON_NULL)
public class DmiPluginRegistration {
- @JsonSetter(nulls = Nulls.AS_EMPTY)
private String dmiPlugin;
- @JsonSetter(nulls = Nulls.AS_EMPTY)
private String dmiDataPlugin;
- @JsonSetter(nulls = Nulls.AS_EMPTY)
private String dmiModelPlugin;
- private List<CmHandle> createdCmHandles;
+ private List<CmHandle> createdCmHandles = Collections.emptyList();
- private List<CmHandle> updatedCmHandles;
+ private List<CmHandle> updatedCmHandles = Collections.emptyList();
- private List<String> removedCmHandles;
+ private List<String> removedCmHandles = Collections.emptyList();
/**
* Validates plugin service names.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/PersistenceCmHandlesList.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/PersistenceCmHandlesList.java
index d4f6e952d8..9762ac4e12 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/PersistenceCmHandlesList.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/PersistenceCmHandlesList.java
@@ -30,7 +30,7 @@ import lombok.Getter;
public class PersistenceCmHandlesList {
@JsonProperty("cm-handles")
- private List<PersistenceCmHandle> persistenceCmHandles = new ArrayList<>();
+ private final List<PersistenceCmHandle> persistenceCmHandles = new ArrayList<>();
/**
* Create a PersistenceCmHandleList given all service names and a collection of cmHandles.
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 00fda149f2..a475f9c345 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
@@ -76,19 +76,19 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
expectedCallsToSaveNode * mockCpsDataService.saveListElements('NCMP-Admin', 'ncmp-dmi-registry',
'/dmi-registry', expectedJsonData, noTimestamp)
and: 'update data node leaves is called with correct parameters'
- expectedCallsToPropertyHandler * mockNetworkCmProxyDataServicePropertyHandler.updateCmHandleProperties(updatedCmHandles)
+ expectedCallsToUpdateCmHandleProperty * mockNetworkCmProxyDataServicePropertyHandler.updateCmHandleProperties(updatedCmHandles)
and: 'delete schema set is invoked with the correct parameters'
expectedCallsToDeleteSchemaSetAndListElement * mockCpsModuleService.deleteSchemaSet('NFP-Operational', 'cmHandle001', CASCADE_DELETE_ALLOWED)
and: 'delete list or list element is invoked with the correct parameters'
expectedCallsToDeleteSchemaSetAndListElement * mockCpsDataService.deleteListOrListElement('NCMP-Admin',
'ncmp-dmi-registry', "/dmi-registry/cm-handles[@id='cmHandle001']", noTimestamp)
where:
- scenario | createdCmHandles | updatedCmHandles | removedCmHandles || expectedCallsToSaveNode | expectedCallsToDeleteSchemaSetAndListElement | expectedCallsToPropertyHandler
- 'create' | [persistenceCmHandle] | [] | [] || 1 | 0 | 1
+ scenario | createdCmHandles | updatedCmHandles | removedCmHandles || expectedCallsToSaveNode | expectedCallsToDeleteSchemaSetAndListElement | expectedCallsToUpdateCmHandleProperty
+ 'create' | [persistenceCmHandle] | [] | [] || 1 | 0 | 0
'update' | [] | [persistenceCmHandle] | [] || 0 | 0 | 1
- 'delete' | [] | [] | cmHandlesArray || 0 | 1 | 1
+ 'delete' | [] | [] | cmHandlesArray || 0 | 1 | 0
'create, update and delete' | [persistenceCmHandle] | [persistenceCmHandle] | cmHandlesArray || 1 | 1 | 1
- 'no valid data' | null | null | null || 0 | 0 | 0
+ 'no valid data' | [] | [] | [] || 0 | 0 | 0
}
def 'Register a DMI Plugin for the given cm-handle(s) without DMI properties.'() {
@@ -107,22 +107,17 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
'/dmi-registry', expectedJsonData, noTimestamp)
}
- def 'Register a DMI Plugin for a given cm-handle(s) with JSON processing errors during #scenario process.'() {
+ def 'Register a DMI Plugin for a given cm-handle(s) with JSON processing errors during process.'() {
given: 'a registration without cm-handle properties '
NetworkCmProxyDataServiceImpl objectUnderTest = getObjectUnderTestWithModelSyncDisabled()
def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin:'some-plugin')
- dmiPluginRegistration.createdCmHandles = createdCmHandles
- dmiPluginRegistration.updatedCmHandles = updatedCmHandles
+ dmiPluginRegistration.createdCmHandles = [persistenceCmHandle]
and: 'an json processing exception occurs'
spiedJsonObjectMapper.asJsonString(_) >> { throw (new JsonProcessingException('')) }
when: 'registration is updated and modules are synced'
objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
then: 'a data validation exception is thrown'
thrown(DataValidationException)
- where:
- scenario | createdCmHandles | updatedCmHandles
- 'create' | [persistenceCmHandle] | []
- 'update' | [] | [persistenceCmHandle]
}
def 'Register a DMI Plugin for the given cm-handle(s) with no data found during delete process.'() {