aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest/src
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-rest/src')
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java18
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapperSpec.groovy2
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy32
3 files changed, 17 insertions, 35 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index f21c6ecbdd..11252b7504 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -34,15 +34,12 @@ import io.micrometer.core.annotation.Timed;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.impl.NetworkCmProxyFacade;
-import org.onap.cps.ncmp.api.impl.config.embeddedcache.TrustLevelCacheConfig;
import org.onap.cps.ncmp.api.impl.exception.InvalidDatastoreException;
import org.onap.cps.ncmp.api.impl.operations.DatastoreType;
-import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel;
import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade;
import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryApiParameters;
import org.onap.cps.ncmp.api.inventory.models.CompositeState;
@@ -63,7 +60,6 @@ import org.onap.cps.ncmp.rest.util.DeprecationHelper;
import org.onap.cps.spi.model.DataNode;
import org.onap.cps.spi.model.ModuleDefinition;
import org.onap.cps.utils.JsonObjectMapper;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
@@ -83,12 +79,8 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
private final DeprecationHelper deprecationHelper;
private final NcmpRestInputMapper ncmpRestInputMapper;
private final CmHandleStateMapper cmHandleStateMapper;
-
private final DataOperationRequestMapper dataOperationRequestMapper;
- @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_CM_HANDLE)
- private final Map<String, TrustLevel> trustLevelPerCmHandle;
-
/**
* Get resource data from datastore.
*
@@ -268,9 +260,9 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
deprecationHelper.mapOldConditionProperties(cmHandleQueryParameters);
final Collection<NcmpServiceCmHandle> cmHandles = networkCmProxyInventoryFacade
.executeCmHandleSearch(cmHandleQueryApiParameters);
- final List<RestOutputCmHandle> outputCmHandles =
+ final List<RestOutputCmHandle> restOutputCmHandles =
cmHandles.stream().map(this::toRestOutputCmHandle).collect(Collectors.toList());
- return ResponseEntity.ok(outputCmHandles);
+ return ResponseEntity.ok(restOutputCmHandles);
}
/**
@@ -394,18 +386,16 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
return new ResponseEntity<>(HttpStatus.OK);
}
-
private RestOutputCmHandle toRestOutputCmHandle(final NcmpServiceCmHandle ncmpServiceCmHandle) {
final RestOutputCmHandle restOutputCmHandle = new RestOutputCmHandle();
final CmHandlePublicProperties cmHandlePublicProperties = new CmHandlePublicProperties();
- final TrustLevel cmHandleCurrentTrustLevel = trustLevelPerCmHandle.get(ncmpServiceCmHandle.getCmHandleId());
restOutputCmHandle.setCmHandle(ncmpServiceCmHandle.getCmHandleId());
cmHandlePublicProperties.add(ncmpServiceCmHandle.getPublicProperties());
restOutputCmHandle.setPublicCmHandleProperties(cmHandlePublicProperties);
restOutputCmHandle.setState(cmHandleStateMapper.toCmHandleCompositeStateExternalLockReason(
ncmpServiceCmHandle.getCompositeState()));
- if (cmHandleCurrentTrustLevel != null) {
- restOutputCmHandle.setTrustLevel(cmHandleCurrentTrustLevel.toString());
+ if (ncmpServiceCmHandle.getCurrentTrustLevel() != null) {
+ restOutputCmHandle.setTrustLevel(ncmpServiceCmHandle.getCurrentTrustLevel().toString());
}
restOutputCmHandle.setModuleSetTag(ncmpServiceCmHandle.getModuleSetTag());
restOutputCmHandle.setAlternateId(ncmpServiceCmHandle.getAlternateId());
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapperSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapperSpec.groovy
index f6b9e35912..41521f6398 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapperSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapperSpec.groovy
@@ -21,9 +21,9 @@
package org.onap.cps.ncmp.rest.controller
import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel
import org.onap.cps.ncmp.api.inventory.models.CmHandleQueryServiceParameters
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
+import org.onap.cps.ncmp.api.inventory.models.TrustLevel
import org.onap.cps.ncmp.rest.model.CmHandleQueryParameters
import org.onap.cps.ncmp.rest.model.ConditionProperties
import org.onap.cps.ncmp.rest.model.RestDmiPluginRegistration
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index 398d632464..65d6d8ca76 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -33,10 +33,10 @@ import org.mapstruct.factory.Mappers
import org.onap.cps.TestUtils
import org.onap.cps.events.EventsPublisher
import org.onap.cps.ncmp.api.impl.NetworkCmProxyFacade
-import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel
import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
import org.onap.cps.ncmp.api.inventory.models.CompositeState
import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
+import org.onap.cps.ncmp.api.inventory.models.TrustLevel
import org.onap.cps.ncmp.api.models.CmResourceAddress
import org.onap.cps.ncmp.impl.inventory.DataStoreSyncState
import org.onap.cps.ncmp.impl.inventory.models.CmHandleState
@@ -108,9 +108,6 @@ class NetworkCmProxyControllerSpec extends Specification {
DataOperationRequestMapper dataOperationRequestMapper = Mappers.getMapper(DataOperationRequestMapper)
@SpringBean
- Map<String, TrustLevel> trustLevelPerCmHandle = [:]
-
- @SpringBean
DeprecationHelper stubbedDeprecationHelper = Stub()
@Value('${rest.api.ncmp-base-path}/v1')
@@ -123,7 +120,6 @@ class NetworkCmProxyControllerSpec extends Specification {
@Shared
def NO_TOPIC = null
def NO_OPTIONS = null
- def NO_REQUEST_ID = null
def NO_AUTH_HEADER = null
def logger = Spy(ListAppender<ILoggingEvent>)
@@ -272,6 +268,7 @@ class NetworkCmProxyControllerSpec extends Specification {
def cmHandle1 = new NcmpServiceCmHandle()
cmHandle1.cmHandleId = 'ch-1'
cmHandle1.publicProperties = [color: 'yellow']
+ cmHandle1.currentTrustLevel = TrustLevel.NONE
def cmHandle2 = new NcmpServiceCmHandle()
cmHandle2.cmHandleId = 'ch-2'
cmHandle2.publicProperties = [color: 'green']
@@ -279,8 +276,6 @@ class NetworkCmProxyControllerSpec extends Specification {
cmHandle2.moduleSetTag = 'someModuleSetTag'
cmHandle2.dataProducerIdentifier = 'someDataProducerIdentifier'
mockNetworkCmProxyInventoryFacade.executeCmHandleSearch(_) >> [cmHandle1, cmHandle2]
- and: 'map for trust level per cmHandle has value for only one cm handle'
- trustLevelPerCmHandle.put('ch-1', TrustLevel.NONE)
when: 'the searches api is invoked'
def response = mvc.perform(post(searchesEndpoint).contentType(MediaType.APPLICATION_JSON).content(jsonString)).andReturn().response
then: 'response status returns OK'
@@ -297,11 +292,9 @@ class NetworkCmProxyControllerSpec extends Specification {
def dmiProperties = [prop: 'some DMI property']
def publicProperties = ["public prop": 'some public property']
def compositeState = compositeStateTestObject()
- def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dmiProperties: dmiProperties, publicProperties: publicProperties, compositeState: compositeState)
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dmiProperties: dmiProperties, publicProperties: publicProperties, compositeState: compositeState, currentTrustLevel: TrustLevel.COMPLETE)
and: 'the service method is invoked with the cm handle id'
1 * mockNetworkCmProxyInventoryFacade.getNcmpServiceCmHandle('some-cm-handle') >> ncmpServiceCmHandle
- and: 'map for trust level per cmHandle has values'
- trustLevelPerCmHandle.get('some-cm-handle') >> { TrustLevel.COMPLETE }
when: 'the cm handle details api is invoked'
def response = mvc.perform(
get(cmHandleDetailsEndpoint)).andReturn().response
@@ -350,16 +343,15 @@ class NetworkCmProxyControllerSpec extends Specification {
def searchesEndpoint = "$ncmpBasePathV1/ch/searches"
String jsonString = TestUtils.getResourceFileContent('invalid-cmhandle-search.json')
and: 'the service method is invoked with module names and returns two cm handles'
- def cmHandel1 = new NcmpServiceCmHandle()
- cmHandel1.cmHandleId = 'ch-1'
- cmHandel1.publicProperties = [color: 'yellow']
- def cmHandel2 = new NcmpServiceCmHandle()
- cmHandel2.cmHandleId = 'ch-2'
- cmHandel2.publicProperties = [color: 'green']
- mockNetworkCmProxyInventoryFacade.executeCmHandleSearch(_) >> [cmHandel1, cmHandel2]
- and: 'map for trust level per cmHandle has values'
- trustLevelPerCmHandle.put('ch-1', TrustLevel.COMPLETE)
- trustLevelPerCmHandle.put('ch-2', TrustLevel.NONE)
+ def cmHandle1 = new NcmpServiceCmHandle()
+ cmHandle1.cmHandleId = 'ch-1'
+ cmHandle1.publicProperties = [color: 'yellow']
+ cmHandle1.currentTrustLevel = TrustLevel.COMPLETE
+ def cmHandle2 = new NcmpServiceCmHandle()
+ cmHandle2.cmHandleId = 'ch-2'
+ cmHandle2.publicProperties = [color: 'green']
+ cmHandle2.currentTrustLevel = TrustLevel.NONE
+ mockNetworkCmProxyInventoryFacade.executeCmHandleSearch(_) >> [cmHandle1, cmHandle2]
when: 'the searches api is invoked'
def response = mvc.perform(post(searchesEndpoint).contentType(MediaType.APPLICATION_JSON).content(jsonString)).andReturn().response
then: 'an empty cm handle identifier is returned'