summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2024-08-23 16:33:44 +0100
committermpriyank <priyank.maheshwari@est.tech>2024-08-27 12:44:15 +0100
commit9718417885caa9581a9115ba07e2060bd38ec9b8 (patch)
treefe718fcfef86d3f7174966ffa4d0659dec828c87
parent102127e47d8ce02a73ccadbd4c60498b59241925 (diff)
Support for alternate-id CPS-E05 composite state
- Added support for alternate id for the composite state API for CPS-E05#15 Issue-ID: CPS-2377 Change-Id: I1af41efb8cec762be68250cae7c1e98fbc61a4f5 Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
-rw-r--r--cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java3
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java6
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy9
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy22
5 files changed, 30 insertions, 17 deletions
diff --git a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java
index 11adc84a1f..183698c4f5 100644
--- a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java
+++ b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/src/main/java/org/onap/cps/ncmp/rest/stub/controller/NetworkCmProxyStubController.java
@@ -165,7 +165,8 @@ public class NetworkCmProxyStubController implements NetworkCmProxyApi {
}
@Override
- public ResponseEntity<RestOutputCmHandleCompositeState> getCmHandleStateByCmHandleId(final String cmHandle) {
+ public ResponseEntity<RestOutputCmHandleCompositeState> getCmHandleStateByCmHandleId(
+ final String cmHandleReference) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
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 af5f226a4f..c339a05c71 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
@@ -317,13 +317,13 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
/**
* Get Cm Handle State by Cm Handle Id.
*
- * @param cmHandleId cm-handle identifier
+ * @param cmHandleReference cm-handle or alternate identifier
* @return cm handle state
*/
@Override
public ResponseEntity<RestOutputCmHandleCompositeState> getCmHandleStateByCmHandleId(
- final String cmHandleId) {
- final CompositeState cmHandleState = networkCmProxyInventoryFacade.getCmHandleCompositeState(cmHandleId);
+ final String cmHandleReference) {
+ final CompositeState cmHandleState = networkCmProxyInventoryFacade.getCmHandleCompositeState(cmHandleReference);
final RestOutputCmHandleCompositeState restOutputCmHandleCompositeState =
new RestOutputCmHandleCompositeState();
restOutputCmHandleCompositeState.setState(
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 9f5331dbc3..92b47c6c8b 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
@@ -32,7 +32,6 @@ import groovy.json.JsonSlurper
import org.mapstruct.factory.Mappers
import org.onap.cps.TestUtils
import org.onap.cps.events.EventsPublisher
-import org.onap.cps.ncmp.api.data.models.CmResourceAddress
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
@@ -95,7 +94,7 @@ class NetworkCmProxyControllerSpec extends Specification {
NetworkCmProxyInventoryFacade mockNetworkCmProxyInventoryFacade = Mock()
@SpringBean
- AlternateIdMatcher mockalternateIdMatcher = Mock()
+ AlternateIdMatcher mockAlternateIdMatcher = Mock()
@SpringBean
ObjectMapper objectMapper = new ObjectMapper()
@@ -324,13 +323,13 @@ class NetworkCmProxyControllerSpec extends Specification {
assertContainsPublicProperties(response)
}
- def 'Get Cm Handle composite state by Cm Handle id.'() {
+ def 'Get Cm Handle composite state by Cm Handle Reference.'() {
given: 'a cm handle state endpoint'
- def cmHandlePropertiesEndpoint = "$ncmpBasePathV1/ch/some-cm-handle/state"
+ def cmHandlePropertiesEndpoint = "$ncmpBasePathV1/ch/some-cm-handle-reference/state"
and: 'some cm handle composite state'
def compositeState = compositeStateTestObject()
and: 'the service method is invoked with the cm handle id returning the cm handle composite state'
- 1 * mockNetworkCmProxyInventoryFacade.getCmHandleCompositeState('some-cm-handle') >> compositeState
+ 1 * mockNetworkCmProxyInventoryFacade.getCmHandleCompositeState('some-cm-handle-reference') >> compositeState
when: 'the cm handle state api is invoked'
def response = mvc.perform(get(cmHandlePropertiesEndpoint)).andReturn().response
then: 'the correct response is returned'
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
index 6f51a8d011..1acd937a31 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
@@ -44,6 +44,7 @@ import org.onap.cps.ncmp.impl.inventory.models.CmHandleQueryConditions;
import org.onap.cps.ncmp.impl.inventory.models.InventoryQueryConditions;
import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
import org.onap.cps.ncmp.impl.inventory.trustlevel.TrustLevelManager;
+import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher;
import org.onap.cps.ncmp.impl.utils.YangDataConverter;
import org.onap.cps.spi.model.ModuleDefinition;
import org.onap.cps.spi.model.ModuleReference;
@@ -61,6 +62,7 @@ public class NetworkCmProxyInventoryFacade {
private final InventoryPersistence inventoryPersistence;
private final JsonObjectMapper jsonObjectMapper;
private final TrustLevelManager trustLevelManager;
+ private final AlternateIdMatcher alternateIdMatcher;
/**
* Registration of Created, Removed, Updated or Upgraded CM Handles.
@@ -198,10 +200,11 @@ public class NetworkCmProxyInventoryFacade {
/**
* Get cm handle composite state for a given cm handle id.
*
- * @param cmHandleId cm handle identifier
+ * @param cmHandleReference cm handle or alternate identifier
* @return cm handle state
*/
- public CompositeState getCmHandleCompositeState(final String cmHandleId) {
+ public CompositeState getCmHandleCompositeState(final String cmHandleReference) {
+ final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
return inventoryPersistence.getYangModelCmHandle(cmHandleId).getCompositeState();
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
index d85dfe47ee..1fed453fa5 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
@@ -36,6 +36,7 @@ import org.onap.cps.ncmp.impl.inventory.models.CmHandleState
import org.onap.cps.ncmp.impl.inventory.models.LockReasonCategory
import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
import org.onap.cps.ncmp.impl.inventory.trustlevel.TrustLevelManager
+import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher
import org.onap.cps.spi.model.ConditionProperties
import org.onap.cps.utils.JsonObjectMapper
import spock.lang.Specification
@@ -48,8 +49,9 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification {
def spiedJsonObjectMapper = Spy(new JsonObjectMapper(new ObjectMapper()))
def mockInventoryPersistence = Mock(InventoryPersistence)
def mockTrustLevelManager = Mock(TrustLevelManager)
-
- def objectUnderTest = new NetworkCmProxyInventoryFacade(mockCmHandleRegistrationService, mockCmHandleQueryService, mockParameterizedCmHandleQueryService, mockInventoryPersistence, spiedJsonObjectMapper, mockTrustLevelManager)
+ def mockAlternateIdMatcher = Mock(AlternateIdMatcher)
+ def objectUnderTest = new NetworkCmProxyInventoryFacade(mockCmHandleRegistrationService, mockCmHandleQueryService, mockParameterizedCmHandleQueryService, mockInventoryPersistence, spiedJsonObjectMapper, mockTrustLevelManager, mockAlternateIdMatcher)
+ def trustLevelPerCmHandle = [:]
def 'Update DMI Registration'() {
given: 'an (updated) dmi plugin registration'
@@ -145,7 +147,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification {
assert result == [ 'public prop' : 'some public prop' ]
}
- def 'Get cm handle composite state'() {
+ def 'Get cm handle composite state using #scenario'() {
given: 'a yang modelled cm handle'
def compositeState = new CompositeState(cmHandleState: CmHandleState.ADVISED,
lockReason: CompositeState.LockReason.builder().lockReasonCategory(LockReasonCategory.MODULE_SYNC_FAILED).details("lock details").build(),
@@ -154,13 +156,21 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification {
dataStores: dataStores())
def dmiProperties = [new YangModelCmHandle.Property('prop', 'some DMI property')]
def publicProperties = [new YangModelCmHandle.Property('public prop', 'some public prop')]
- def yangModelCmHandle = new YangModelCmHandle(id:'some-cm-handle', dmiServiceName: 'some service name', dmiProperties: dmiProperties, publicProperties: publicProperties, compositeState: compositeState)
+ def cmHandleId = 'some-cm-handle'
+ def alternateId = 'some-alternate-id'
+ def yangModelCmHandle = new YangModelCmHandle(id:cmHandleId, alternateId: alternateId, dmiServiceName: 'some service name', dmiProperties: dmiProperties, publicProperties: publicProperties, compositeState: compositeState)
+ and: 'we have corresponding cm handle for the cm handle reference'
+ 1 * mockAlternateIdMatcher.getCmHandleId(cmHandleRef) >> cmHandleId
and: 'the system returns this yang modelled cm handle'
- 1 * mockInventoryPersistence.getYangModelCmHandle('some-cm-handle') >> yangModelCmHandle
+ 1 * mockInventoryPersistence.getYangModelCmHandle(cmHandleId) >> yangModelCmHandle
when: 'getting cm handle composite state for a given cm handle id from ncmp service'
- def result = objectUnderTest.getCmHandleCompositeState('some-cm-handle')
+ def result = objectUnderTest.getCmHandleCompositeState(cmHandleRef)
then: 'the result returns the correct data'
assert result == compositeState
+ where: 'following cm handle reference is used'
+ scenario | cmHandleRef
+ 'Cm Handle Reference as cm handle-id' | 'some-cm-handle'
+ 'Cm Handle Reference as alternate-id' | 'some-alternate-id'
}
def 'Execute cm handle id search'() {