aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/test
diff options
context:
space:
mode:
authorAlex <alexander.borovitzky@guest.telecomitalia.it>2021-08-23 19:36:36 +0300
committerAlex <alexander.borovitzky@guest.telecomitalia.it>2021-08-23 19:39:17 +0300
commit9fa22d016a6aa0d818831119c6bf2108449d9aba (patch)
tree3820a2caace60145a326d6139d9e66811543d4ef /bpmn/so-bpmn-infrastructure-common/src/test
parent9e597da1e74ab81a27879f6100335e6815ff1702 (diff)
Changes in Modify and Deallocate Core NSSI flows
Issue-ID: SO-3703 Change-Id: I22391ae0ff142fd6923cb62621fb537708a3cd19 Signed-off-by: Alex <alexander.borovitzky@guest.telecomitalia.it>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy206
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy236
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy161
3 files changed, 453 insertions, 150 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
index 9707dd2242..13edfee893 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
@@ -33,16 +33,23 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.aaiclient.client.aai.entities.uri.ServiceInstanceUri
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.bpmn.common.scripts.CatalogDbUtils
+import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
import org.onap.so.serviceinstancebeans.RequestDetails
import javax.ws.rs.core.Response
import java.time.Instant
import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertNull
import static org.junit.Assert.assertTrue
import static org.mockito.Mockito.*
@@ -54,37 +61,6 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
@Test
- void testPreProcessRequest() {
-
- String nssiId = "5G-999"
- when(mockExecution.getVariable("serviceInstanceID")).thenReturn(nssiId)
-
- String nsiId = "5G-777"
- when(mockExecution.getVariable("nsiId")).thenReturn(nsiId)
-
- String snssai = "S-NSSAI"
- String snssaiList = "[ \"${snssai}\" ]"
- String sliceProfileId = "slice-profile-id"
- String sliceParams = "{\n" +
- "\"sliceProfile\":{\"sliceProfileId\":\"${sliceProfileId}\",\"snssaiList\":${snssaiList}}\n" +
- "}"
- when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams)
-
- DoCommonCoreNSSI dcnssi = new DoCommonCoreNSSI()
- dcnssi.preProcessRequest(mockExecution)
-
- def currentNSSI = [:]
- currentNSSI.put("nssiId", nssiId)
- currentNSSI.put("nsiId", nsiId)
- currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"]}")
- currentNSSI.put("S-NSSAI", snssai)
- currentNSSI.put("sliceProfileId", sliceProfileId)
- Mockito.verify(mockExecution,times(1)).setVariable("currentNSSI", currentNSSI)
-
- }
-
-
- @Test
void testGetNetworkServiceInstance() {
def currentNSSI = [:]
currentNSSI.put("nssiId","5G-999")
@@ -182,69 +158,6 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
@Test
- void testGetNSSIAssociatedProfiles() {
- def currentNSSI = [:]
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
-
- String nssiId = "5G-999"
- ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId(nssiId)
- currentNSSI.put("nssiId", nssiId)
-
- SliceProfiles sliceProfiles = new SliceProfiles()
-
- List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
- slProfiles.add(new SliceProfile())
- slProfiles.add(new SliceProfile())
-
- //nssi.setSliceProfiles(sliceProfiles)
- currentNSSI.put("nssi", nssi)
-
- DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
- when(spy.getAAIClient()).thenReturn(client)
-
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
-
- AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
- Relationships rsMock = mock(Relationships.class)
- Optional<Relationships> orsMock = Optional.of(rsMock)
- List<AAIResourceUri> allottedUris = new ArrayList<>()
- AAIResourceUri allottedUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment("allotted-id"))
- allottedUris.add(allottedUri)
-
- when(client.get(nssiUri)).thenReturn(wrapperMock)
- when(wrapperMock.getRelationships()).thenReturn(orsMock)
- when(rsMock.getRelatedUris(Types.ALLOTTED_RESOURCE)).thenReturn(allottedUris)
-
- String sliceProfileInstanceId = "slice-profile-instance-id"
- ServiceInstance sliceProfileInstance = new ServiceInstance()
- sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
- sliceProfileInstance.setServiceRole("slice-profile-instance")
-
- List<AAIResourceUri> sliceProfileInstanceUris = new ArrayList<>()
- AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstance.getServiceInstanceId()))
- sliceProfileInstanceUris.add(sliceProfileInstanceUri)
-
- Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
-
- when(client.get(allottedUri)).thenReturn(wrapperMock)
- when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(sliceProfileInstanceUris)
- when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
-
-
- SliceProfiles sps = new SliceProfiles()
- sps.getSliceProfile().addAll(slProfiles)
- sliceProfileInstance.setSliceProfiles(sps)
-
- spy.getNSSIAssociatedProfiles(mockExecution)
-
- List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
- assertTrue("sliceProfileInstanceUri not found in contect Map", currentNSSI.get("sliceProfileInstanceUri") != null)
- assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
- }
-
-
- @Test
void testInvokePUTServiceInstance() {
def currentNSSI = [:]
@@ -263,13 +176,18 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
- when(spy.encryptBasicAuth("mso.infra.endpoint.auth", "mso.msoKey")).thenReturn("auth-value")
+ GenericVnf genericVnf = new GenericVnf()
+ genericVnf.setServiceId("service-id")
+ genericVnf.setVnfName("vnf-name")
+ genericVnf.setModelInvariantId("model-invariant-id")
+ genericVnf.setModelCustomizationId("model-customization-id")
+ genericVnf.setVnfName("vnf-name")
+ genericVnf.setVnfId("vnf-id")
- String authHeaderResponse = "auth-header"
+ currentNSSI.put("constituteVnf", genericVnf)
- when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse)
- String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s", networkServiceInstance.getServiceInstanceId())
+ String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), genericVnf.getVnfId())
String callPUTServiceInstanceResponse = "put"
@@ -279,13 +197,36 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
when(spy.prepareRequestDetails(mockExecution)).thenReturn(requestDetailsStr)
- when(spy.callPUTServiceInstance(urlString, "auth-header", requestDetailsStr)).thenReturn(callPUTServiceInstanceResponse)
+ MsoUtils msoUtilsMock = mock(MsoUtils.class)
+ String basicAuth = "basicAuth"
+ when(msoUtilsMock.getBasicAuth(anyString(), anyString())).thenReturn(basicAuth)
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class)
+ when(spy.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
+ Response responseMock = mock(Response.class)
+
+ HttpClient httpClientMock = mock(HttpClient.class)
+
+ when(httpClientFactoryMock.newJsonClient(any(), any())).thenReturn(httpClientMock)
+
+ when(httpClientMock.put(requestDetailsStr)).thenReturn(responseMock)
+
+ when(responseMock.getStatus()).thenReturn(200)
+ when(responseMock.hasEntity()).thenReturn(true)
+
+ String macroOperationId = "request-id"
+ String requestSelfLink = "request-self-link"
+ String entity = "{\"requestReferences\":{\"requestId\": \"${macroOperationId}\",\"requestSelfLink\":\"${requestSelfLink}\"}}"
+ when(responseMock.readEntity(String.class)).thenReturn(entity)
spy.invokePUTServiceInstance(mockExecution)
+
+ Mockito.verify(mockExecution,times(1)).setVariable("macroOperationId", macroOperationId)
+ Mockito.verify(mockExecution,times(1)).setVariable("requestSelfLink", requestSelfLink)
}
- @Test
+ @Test(expected = Test.None.class)
void testRemoveSPAssociationWithNSSI() {
def currentNSSI = [:]
@@ -349,7 +290,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
spy.removeSPAssociationWithNSSI(mockExecution)
- assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("sliceProfileInstance")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
+ // assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("sliceProfileInstance")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
}
@@ -471,6 +412,15 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
prepareProject(cloudRegionAAIUri)
+ CatalogDbUtilsFactory catalogDbUtilsFactoryMock = mock(CatalogDbUtilsFactory.class)
+ when(spy.getCatalogDbUtilsFactory()).thenReturn(catalogDbUtilsFactoryMock)
+
+ CatalogDbUtils catalogDbUtilsMock = mock(CatalogDbUtils.class)
+ when(catalogDbUtilsFactoryMock.create()).thenReturn(catalogDbUtilsMock)
+
+ String json = "{\"serviceResources\":{\"serviceVnfs\": [{\"modelInfo\": {\"modelCustomizationUuid\":\"model-customization-uuid\",\"modelId\":\"model-id\"},\"vfModules\":[{\"modelInfo\": {\"modelCustomizationUuid\":\"model-customization-uuid\",\"modelId\":\"model-id\"}}]}]}}"
+ when(catalogDbUtilsMock.getServiceResourcesByServiceModelInvariantUuidString(mockExecution, networkServiceInstance.getModelInvariantId())).thenReturn(json)
+
String prepareRequestDetailsResponse = spy.prepareRequestDetails(mockExecution)
JsonUtils jsonUtil = new JsonUtils()
@@ -492,11 +442,16 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
String nssiId = "5G-999"
String nsiId = "5G-777"
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId(nssiId)
+ nssi.setModelVersionId(UUID.randomUUID().toString())
+
currentNSSI.put("nssiId", nssiId)
currentNSSI.put("nsiId", nsiId)
currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
currentNSSI.put("operationId", "operationId")
currentNSSI.put("operationType", "operationType")
+ currentNSSI.put("nssi", nssi)
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
@@ -515,11 +470,16 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
String nssiId = "5G-999"
String nsiId = "5G-777"
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId(nssiId)
+ nssi.setModelVersionId(UUID.randomUUID().toString())
+
currentNSSI.put("nssiId", nssiId)
currentNSSI.put("nsiId", nsiId)
currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
currentNSSI.put("operationId", "operationId")
currentNSSI.put("operationType", "operationType")
+ currentNSSI.put("nssi", nssi)
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
@@ -539,7 +499,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
@Test
void testGetPUTServiceInstanceProgressInProgress() {
- executePUTServiceInstanceProgress("INPROGRESS")
+ executePUTServiceInstanceProgress("IN_PROGRESS")
Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "processing")
}
@@ -547,7 +507,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
@Test
void testGetPUTServiceInstanceProgressCompleted() {
- executePUTServiceInstanceProgress("COMPLETED")
+ executePUTServiceInstanceProgress("COMPLETE")
Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "completed")
}
@@ -567,6 +527,21 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
}
+ @Test
+ void testPostProcessRequest() {
+
+ def currentNSSI = [:]
+ mockExecution.setVariable("currentNSSI", currentNSSI)
+
+ DoCommonCoreNSSI dcnssi = new DoCommonCoreNSSI()
+ dcnssi.postProcessRequest(mockExecution)
+
+ currentNSSI = mockExecution.getVariable("currentNSSI")
+ assertNull("currentNSSI is not null", currentNSSI)
+
+ }
+
+
void executePUTServiceInstanceProgress(String state) {
def currentNSSI = [:]
@@ -575,23 +550,37 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
String url = "http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/5G-777"
- currentNSSI.put("putServiceInstanceURL", url)
+ currentNSSI['requestSelfLink'] = url
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class)
when(spy.getExternalAPIUtilFactory()).thenReturn(externalAPIUtilFactoryMock)
- ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class)
+ // ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class)
- when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock)
+ // when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock)
+ MsoUtils msoUtilsMock = mock(MsoUtils.class)
+ String basicAuth = "basicAuth"
+ when(msoUtilsMock.getBasicAuth(anyString(), anyString())).thenReturn(basicAuth)
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class)
+ when(spy.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
Response responseMock = mock(Response.class)
- when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock)
+
+ HttpClient httpClientMock = mock(HttpClient.class)
+
+
+ when(httpClientFactoryMock.newJsonClient(any(), any())).thenReturn(httpClientMock)
+
+ when(httpClientMock.get()).thenReturn(responseMock)
+// when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock)
when(responseMock.getStatus()).thenReturn(200)
+ when(responseMock.hasEntity()).thenReturn(true)
- String entity = "{\"state\":\"ACCEPTED\",\"orderItem\":[{\"service\":{\"id\":\"5G-999\"},\"state\":\"${state}\"}]}"
+ String entity = "{\"request\":{\"requestStatus\":{\"requestState\":\"${state}\"}},\"state\":\"ACCEPTED\"}"
when(responseMock.readEntity(String.class)).thenReturn(entity)
spy.getPUTServiceInstanceProgress(mockExecution)
@@ -750,4 +739,5 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(vfModule.getModelInvariantId()).modelVer(vfModule.getModelVersionId()))
when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)
}
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
index 26b96a0a4a..5bf4f40e50 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
@@ -20,17 +20,26 @@
package org.onap.so.bpmn.infrastructure.scripts
+import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito
import org.onap.aai.domain.yang.v19.*
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.Relationships
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
+import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.common.scripts.MsoUtils
+import org.onap.so.bpmn.common.scripts.OofUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.serviceinstancebeans.RequestDetails
import javax.ws.rs.core.Response
@@ -47,10 +56,44 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
@Test
+ void testPreProcessRequest() {
+
+ String nssiId = "5G-999"
+ when(mockExecution.getVariable("serviceInstanceID")).thenReturn(nssiId)
+
+ String nsiId = "5G-777"
+ when(mockExecution.getVariable("nsiId")).thenReturn(nsiId)
+
+ String snssai = "S-NSSAI"
+ String snssaiList = "[ \"${snssai}\" ]"
+ String sliceProfileId = "slice-profile-id"
+ String modifyAction = "allocate"
+ String sliceParams = "{\n" +
+ "\"sliceProfileId\":\"${sliceProfileId}\",\"snssaiList\":${snssaiList}\n" +
+ "}"
+ when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams)
+
+ DoDeallocateCoreNSSI obj = new DoDeallocateCoreNSSI()
+ obj.preProcessRequest(mockExecution)
+
+ def currentNSSI = [:]
+ currentNSSI.put("nssiId", nssiId)
+ currentNSSI.put("nsiId", nsiId)
+ currentNSSI.put("sliceProfile", sliceParams)
+ currentNSSI.put("S-NSSAI", snssai)
+ currentNSSI.put("sliceProfileId", sliceProfileId)
+ Mockito.verify(mockExecution,times(1)).setVariable("currentNSSI", currentNSSI)
+
+ }
+
+
+ @Test
void testExecuteTerminateNSSIQuery() {
def currentNSSI = [:]
- currentNSSI.put("nssiId","5G-999")
+
+ String nssiId = "5G-999"
+ currentNSSI.put("nssiId", nssiId)
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
@@ -62,6 +105,9 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
+ OofUtils oofUtilsMock = mock(OofUtils.class)
+ when(spy.getOofUtils()).thenReturn(oofUtilsMock)
+
when(spy.encryptBasicAuth("mso.oof.auth", "mso.msoKey")).thenReturn("auth-value")
String authHeaderResponse = "auth-header"
@@ -73,6 +119,14 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse)
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId("5G-999")
+ Optional<ServiceInstance> nssiOpt = Optional.of(nssi)
+
+ when(client.get(ServiceInstance.class, nssiUri)).thenReturn(nssiOpt)
+
String urlString = "http://oof.onap:8088"
String httpRequest = "{\n" +
@@ -85,7 +139,16 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
" }\n" +
"}"
- boolean terminateResponse = true
+ String requestId = "request-id"
+ String nxlId = nssi.getServiceInstanceId()
+ String nxlType = "NSSI"
+ String messageType = "cn"
+ String serviceInstanceId = nssi.getServiceInstanceId()
+
+ when(mockExecution.getVariable("msoRequestId")).thenReturn(requestId)
+ when(oofUtilsMock.buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, serviceInstanceId)).thenReturn(httpRequest)
+
+ String terminateResponse = "false"
String oofResponse = "{\n" +
" \"requestId\": \"mso-request-id\",\n" +
@@ -96,18 +159,28 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
" \"reason\": \"\"\n" +
" }\n"
- String oofCallResponse = oofResponse
+ String apiPath = "/api/oof/terminate/nxi/v1"
- /* String oofCallResponse = "{\n" +
- " \"errorCode\": \"401\",\n" +
- " \"errorMessage\": \"Exception during the call\"\n" +
- "}" */
+ urlString = urlString + apiPath
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class)
+ when(spy.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
+ Response responseMock = mock(Response.class)
+
+ HttpClient httpClientMock = mock(HttpClient.class)
+
+ when(httpClientFactoryMock.newJsonClient(any(), any())).thenReturn(httpClientMock)
- when(spy.callOOF(urlString, "auth-header", httpRequest)).thenReturn(oofCallResponse)
+ when(httpClientMock.post(httpRequest)).thenReturn(responseMock)
+
+ when(responseMock.getStatus()).thenReturn(200)
+ when(responseMock.hasEntity()).thenReturn(true)
+
+ when(responseMock.readEntity(String.class)).thenReturn(oofResponse)
spy.executeTerminateNSSIQuery(mockExecution)
- verify(mockExecution).setVariable("isTerminateNSSI", terminateResponse)
+ Mockito.verify(mockExecution,times(1)).setVariable("isTerminateNSSI", terminateResponse)
}
@@ -125,56 +198,101 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("networkServiceInstance", networkServiceInstance)
- when(mockExecution.getVariable("nbi.endpoint.url")).thenReturn("http://nbi.onap:8088")
+ when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://mso.onap:8088")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("mso.msoKey")
when(mockExecution.getVariable("mso.infra.endpoint.auth")).thenReturn("mso.infra.endpoint.auth")
DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
- when(spy.encryptBasicAuth("mso.infra.endpoint.auth", "mso.msoKey")).thenReturn("auth-value")
+ GenericVnf genericVnf = new GenericVnf()
+ genericVnf.setServiceId("service-id")
+ genericVnf.setVnfName("vnf-name")
+ genericVnf.setModelInvariantId("model-invariant-id")
+ genericVnf.setModelCustomizationId("model-customization-id")
+ genericVnf.setVnfName("vnf-name")
+ genericVnf.setVnfId("vnf-id")
- String authHeaderResponse = "auth-header"
+ currentNSSI.put("constituteVnf", genericVnf)
- /* String authHeaderResponse = "{\n" +
- " \"errorCode\": \"401\",\n" +
- " \"errorMessage\": \"Bad request\"\n" +
- "}" */
+ String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), genericVnf.getVnfId())
- when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse)
+ RequestDetails requestDetails = new RequestDetails()
+ ObjectMapper mapper = new ObjectMapper()
+ String requestDetailsStr = mapper.writeValueAsString(requestDetails)
+
+ when(spy.prepareRequestDetails(mockExecution)).thenReturn(requestDetailsStr)
+
+ MsoUtils msoUtilsMock = mock(MsoUtils.class)
+ String basicAuth = "basicAuth"
+ when(msoUtilsMock.getBasicAuth(anyString(), anyString())).thenReturn(basicAuth)
+
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class)
+ when(spy.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
+ Response responseMock = mock(Response.class)
- String urlString = String.format("http://nbi.onap:8088/api/v4/serviceOrder/%s", networkServiceInstance.getServiceInstanceId())
+ HttpClient httpClientMock = mock(HttpClient.class)
- String callDeleteServiceOrderResponse = "deleted"
+ when(httpClientFactoryMock.newJsonClient(any(), any())).thenReturn(httpClientMock)
- when(spy.callDeleteServiceOrder(mockExecution, urlString, "auth-header")).thenReturn(callDeleteServiceOrderResponse)
+ when(httpClientMock.delete()).thenReturn(responseMock)
+
+ when(responseMock.getStatus()).thenReturn(200)
+ when(responseMock.hasEntity()).thenReturn(true)
+
+ String macroOperationId = "request-id"
+ String requestSelfLink = "request-self-link"
+ String entity = "{\"requestReferences\":{\"requestId\": \"${macroOperationId}\",\"requestSelfLink\":\"${requestSelfLink}\"}}"
+ when(responseMock.readEntity(String.class)).thenReturn(entity)
spy.deleteServiceOrder(mockExecution)
+
+ Mockito.verify(mockExecution,times(1)).setVariable("macroOperationId", macroOperationId)
+ Mockito.verify(mockExecution,times(1)).setVariable("requestSelfLink", requestSelfLink)
+
+ assertTrue(currentNSSI['requestSelfLink'].equals(requestSelfLink))
}
@Test
- void testCalculateSNSSAI() {
+ void testCalculateSNSSAITerminateNSSI() {
+ invokeCalculateSNSSAI("true")
+ }
+
+ @Test
+ void testCalculateSNSSAINotTerminateNSSI() {
+ invokeCalculateSNSSAI("false")
+ }
+
+ void invokeCalculateSNSSAI(String isTerminateNSSI) {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ when(mockExecution.getVariable("isTerminateNSSI")).thenReturn(isTerminateNSSI)
+
String theSNSSAI = "theS-NSSAI"
currentNSSI.put("S-NSSAI", theSNSSAI)
+ String theSliceProfileId = "the-slice-profile-id"
+ currentNSSI['sliceProfileId'] = theSliceProfileId
+
List<SliceProfile> associatedProfiles = new ArrayList<>()
SliceProfile sliceProfile1 = new SliceProfile()
- sliceProfile1.setSNssai("snssai1")
+ sliceProfile1.setProfileId(theSliceProfileId)
+ sliceProfile1.setSNssai(theSNSSAI)
SliceProfile sliceProfile2 = new SliceProfile()
- sliceProfile2.setSNssai(theSNSSAI)
+ sliceProfile2.setSNssai("snssai2")
SliceProfile sliceProfile3 = new SliceProfile()
sliceProfile3.setSNssai("snssai3")
- associatedProfiles.add(sliceProfile1)
- associatedProfiles.add(sliceProfile2)
- associatedProfiles.add(sliceProfile3)
+ if(isTerminateNSSI.equals("false")) {
+ associatedProfiles.add(sliceProfile1)
+ associatedProfiles.add(sliceProfile2)
+ associatedProfiles.add(sliceProfile3)
+ }
int sizeBefore = associatedProfiles.size()
@@ -186,9 +304,14 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
List<SliceProfile> snssais = (List<SliceProfile>)currentNSSI.get("S-NSSAIs")
SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI.get("sliceProfileS-NSSAI")
- assertTrue("Either snssais doesn't exist or size is incorrect", (snssais != null && snssais.size() == (sizeBefore - 1)))
- assertNotNull("Slice Profile which contains given S-NSSAI not found", sliceProfileContainsSNSSAI)
- assertTrue("Wrong Slice Profile", sliceProfileContainsSNSSAI.getSNssai().equals(theSNSSAI))
+ if(isTerminateNSSI.equals("false")) {
+ assertTrue("Either snssais doesn't exist or size is incorrect", (snssais != null && snssais.size() == (sizeBefore - 1)))
+ assertNotNull("Slice Profile which contains given S-NSSAI not found", sliceProfileContainsSNSSAI)
+ assertTrue("Wrong Slice Profile", sliceProfileContainsSNSSAI.getSNssai().equals(theSNSSAI))
+ }
+ else {
+ assertTrue("Either snssais doesn't exist or size is incorrect", (snssais != null && snssais.size() == 0))
+ }
}
@@ -212,6 +335,10 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
ServiceInstance nssi = new ServiceInstance()
nssi.setServiceInstanceId(nssiId)
+ ServiceInstance nsi = new ServiceInstance()
+ nsi.setServiceInstanceId(nsiId)
+ nsi.setServiceRole("nsi")
+
AllottedResources allottedResources = new AllottedResources()
AllottedResource allottedResource = new AllottedResource()
allottedResource.setId(UUID.randomUUID().toString())
@@ -222,7 +349,26 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId))
- doNothing().when(client).update(nssiUri, nssi)
+ AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
+ when(client.get(nssiUri)).thenReturn(wrapperMock)
+ Relationships rsMock = mock(Relationships.class)
+ Optional<Relationships> orsMock = Optional.of(rsMock)
+ when(wrapperMock.getRelationships()).thenReturn(orsMock)
+
+ List<AAIResourceUri> allottedUris = new ArrayList<>()
+ AAIResourceUri allottedUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment("allotted-id"))
+ allottedUris.add(allottedUri)
+
+ when(rsMock.getRelatedUris(Types.ALLOTTED_RESOURCE)).thenReturn(allottedUris)
+
+ List<AAIResourceUri> nsiUris = new ArrayList<>()
+ nsiUris.add(nsiUri)
+
+ Optional<ServiceInstance> nsiOpt = Optional.of(nsi)
+
+ when(client.get(allottedUri)).thenReturn(wrapperMock)
+ when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(nsiUris)
+ when(client.get(ServiceInstance.class, nsiUri)).thenReturn(nsiOpt)
String globalSubscriberId = "globalSubscriberId"
String subscriptionServiceType = "subscription-service-type"
@@ -231,7 +377,7 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResource.getId()))
- doNothing().when(client).disconnect(nsiUri, allottedResourceUri)
+ doNothing().when(client).disconnect(nssiUri, nsiUri)
spy.removeNSSIAssociationWithNSI(mockExecution)
@@ -270,7 +416,7 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
@Test
void testDeleteServiceOrderProgressInProgress() {
- executeDeleteServiceOrderProgress("INPROGRESS")
+ executeDeleteServiceOrderProgress("IN_PROGRESS")
Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "processing")
}
@@ -278,7 +424,7 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
@Test
void testDeleteServiceOrderProgressCompleted() {
- executeDeleteServiceOrderProgress("COMPLETED")
+ executeDeleteServiceOrderProgress("COMPLETE")
Mockito.verify(mockExecution,times(1)).setVariable("deleteStatus", "completed")
}
@@ -290,23 +436,37 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
String url = "http://nbi.onap:8088/api/v4/serviceOrder/NS-777"
- currentNSSI.put("deleteServiceOrderURL", url)
+ currentNSSI['requestSelfLink'] = url
DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class)
- ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class)
+ /*ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class)
when(spy.getExternalAPIUtilFactory()).thenReturn(externalAPIUtilFactoryMock)
ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class)
- when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock)
+ when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock) */
+
+ MsoUtils msoUtilsMock = mock(MsoUtils.class)
+ String basicAuth = "basicAuth"
+ when(msoUtilsMock.getBasicAuth(anyString(), anyString())).thenReturn(basicAuth)
+ HttpClientFactory httpClientFactoryMock = mock(HttpClientFactory.class)
+ when(spy.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
Response responseMock = mock(Response.class)
- when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock)
+
+ HttpClient httpClientMock = mock(HttpClient.class)
+
+
+ when(httpClientFactoryMock.newJsonClient(any(), any())).thenReturn(httpClientMock)
+
+ when(httpClientMock.get()).thenReturn(responseMock)
+// when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock)
when(responseMock.getStatus()).thenReturn(200)
+ when(responseMock.hasEntity()).thenReturn(true)
- String entity = "{\"state\":\"ACCEPTED\",\"orderItem\":[{\"service\":{\"id\":\"5G-999\"},\"state\":\"${state}\"}]}"
+ String entity = "{\"request\":{\"requestStatus\":{\"requestState\":\"${state}\"}},\"state\":\"ACCEPTED\"}"
when(responseMock.readEntity(String.class)).thenReturn(entity)
spy.getDeleteServiceOrderProgress(mockExecution)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
index ac6f897dfa..7293a2389e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
@@ -29,11 +29,14 @@ import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aai.domain.yang.v19.SliceProfile
import org.onap.aai.domain.yang.v19.SliceProfiles
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.Relationships
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.springframework.data.domain.Slice
import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertTrue
@@ -48,6 +51,40 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
@Test
+ void testPreProcessRequest() {
+
+ String nssiId = "5G-999"
+ when(mockExecution.getVariable("serviceInstanceID")).thenReturn(nssiId)
+
+ String nsiId = "5G-777"
+ when(mockExecution.getVariable("nsiId")).thenReturn(nsiId)
+
+ String snssai = "S-NSSAI"
+ String snssaiList = "[ \"${snssai}\" ]"
+ String sliceProfileId = "slice-profile-id"
+ String modifyAction = "allocate"
+ String sliceParams = "{\n" +
+ "\"sliceProfileId\":\"${sliceProfileId}\",\"snssaiList\":${snssaiList}\n" +
+ ",\"modifyAction\":\"${modifyAction}\"\n" +
+ "}"
+ when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams)
+
+ DoModifyCoreNSSI obj = new DoModifyCoreNSSI()
+ obj.preProcessRequest(mockExecution)
+
+ def currentNSSI = [:]
+ currentNSSI.put("nssiId", nssiId)
+ currentNSSI.put("nsiId", nsiId)
+ currentNSSI.put("sliceProfile", sliceParams)
+ currentNSSI.put("S-NSSAI", snssai)
+ currentNSSI.put("sliceProfileId", sliceProfileId)
+
+ Mockito.verify(mockExecution,times(1)).setVariable("currentNSSI", currentNSSI)
+
+ }
+
+
+ @Test
void testCalculateSNSSAISliceProfileInstanceHasToBeDeleted() {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
@@ -58,31 +95,37 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("S-NSSAI", theSNSSAI)
+ String sliceProfileId = "the-slice-profile-id"
+ currentNSSI['sliceProfileId'] = sliceProfileId
+
List<SliceProfile> associatedProfiles = new ArrayList<>()
SliceProfile sliceProfile1 = new SliceProfile()
- sliceProfile1.setSNssai("snssai1")
+ sliceProfile1.setProfileId(sliceProfileId)
+ sliceProfile1.setSNssai(theSNSSAI)
SliceProfile sliceProfile2 = new SliceProfile()
+ sliceProfile2.setProfileId("sp-2")
sliceProfile2.setSNssai(theSNSSAI)
SliceProfile sliceProfile3 = new SliceProfile()
+ sliceProfile3.setProfileId("sp-3")
sliceProfile3.setSNssai("snssai2")
associatedProfiles.add(sliceProfile1)
associatedProfiles.add(sliceProfile2)
associatedProfiles.add(sliceProfile3)
- int sizeBefore = associatedProfiles.size()
-
currentNSSI.put("associatedProfiles", associatedProfiles)
+ when(mockExecution.getVariable("isCreateSliceProfileInstance" )).thenReturn(false)
+
DoModifyCoreNSSI obj = new DoModifyCoreNSSI()
obj.calculateSNSSAI(mockExecution)
List<SliceProfile> snssais = (List<SliceProfile>)currentNSSI.get("S-NSSAIs")
SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI.get("sliceProfileS-NSSAI")
- assertTrue("Either snssais doesn't exist or size is incorrect", (snssais != null && snssais.size() == (sizeBefore - 1)))
+ assertTrue("Either snssais doesn't exist or size is incorrect", (snssais != null && snssais.size() == (associatedProfiles.size() - 1)))
assertNotNull("Slice Profile which contains given S-NSSAI not found", sliceProfileContainsSNSSAI)
assertTrue("Wrong Slice Profile", sliceProfileContainsSNSSAI.getSNssai().equals(theSNSSAI))
}
@@ -233,4 +276,114 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
}
+
+ @Test
+ void testGetNSSIAssociatedProfilesCreateSLiceProfileEmptySLiceProfiles() {
+ invokeGetNSSIAssociatedProfiles("true", true)
+ }
+
+ @Test
+ void testGetNSSIAssociatedProfilesCreateSLiceProfileNonEmptySliceProfiles() {
+ invokeGetNSSIAssociatedProfiles("true", false)
+ }
+
+ @Test
+ void testGetNSSIAssociatedProfilesDeleteSLiceProfile() {
+ invokeGetNSSIAssociatedProfiles("false", false)
+ }
+
+ void invokeGetNSSIAssociatedProfiles(String isCreateSliceProfileInstance, boolean isEmptySliceProfiles) {
+ def currentNSSI = [:]
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ String globalSubscriberId = "5GCustomer"
+ String subscriptionServiceType = "5G"
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
+
+ when(mockExecution.getVariable("isCreateSliceProfileInstance")).thenReturn(isCreateSliceProfileInstance)
+
+ String nssiId = "5G-999"
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId(nssiId)
+ currentNSSI.put("nssiId", nssiId)
+
+ String theSLiceProfileId = "slice-profile-id"
+ currentNSSI.put("sliceProfileId", theSLiceProfileId)
+
+ SliceProfiles sliceProfiles = new SliceProfiles()
+
+ List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
+
+ if(!isEmptySliceProfiles) {
+ SliceProfile sp1 = new SliceProfile()
+ sp1.setProfileId(theSLiceProfileId)
+ slProfiles.add(sp1)
+ slProfiles.add(new SliceProfile())
+ }
+
+ //nssi.setSliceProfiles(sliceProfiles)
+ currentNSSI.put("nssi", nssi)
+
+ DoModifyCoreNSSI spy = spy(DoModifyCoreNSSI.class)
+ when(spy.getAAIClient()).thenReturn(client)
+
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
+ Relationships rsMock = mock(Relationships.class)
+ Optional<Relationships> orsMock = Optional.of(rsMock)
+ List<AAIResourceUri> allottedUris = new ArrayList<>()
+ AAIResourceUri allottedUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment("allotted-id"))
+ allottedUris.add(allottedUri)
+
+ when(client.get(nssiUri)).thenReturn(wrapperMock)
+ when(wrapperMock.getRelationships()).thenReturn(orsMock)
+ when(rsMock.getRelatedUris(Types.ALLOTTED_RESOURCE)).thenReturn(allottedUris)
+
+ String sliceProfileInstanceId = "slice-profile-instance-id"
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ sliceProfileInstance.setServiceRole("slice-profile-instance")
+
+ List<AAIResourceUri> sliceProfileInstanceUris = new ArrayList<>()
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstance.getServiceInstanceId()))
+ sliceProfileInstanceUris.add(sliceProfileInstanceUri)
+
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(allottedUri)).thenReturn(wrapperMock)
+ when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(sliceProfileInstanceUris)
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+
+
+ SliceProfiles sps = new SliceProfiles()
+ sps.getSliceProfile().addAll(slProfiles)
+ sliceProfileInstance.setSliceProfiles(sps)
+
+ Optional<SliceProfiles> sliceProfilesOpt = Optional.of(sps)
+
+ org.onap.aaiclient.client.generated.fluentbuilders.SliceProfiles sliceProfilesType =
+ AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstance.getServiceInstanceId()).sliceProfiles()
+
+ def sliceProfilesUri = AAIUriFactory.createResourceUri(sliceProfilesType)
+ when(client.exists(sliceProfilesUri)).thenReturn(true)
+
+ when(client.get(sliceProfilesUri)).thenReturn(wrapperMock)
+
+ when(wrapperMock.asBean(SliceProfiles.class)).thenReturn(sliceProfilesOpt)
+
+ spy.getNSSIAssociatedProfiles(mockExecution)
+
+ List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
+ int expectedSize = sps.getSliceProfile().size()
+
+ if(!isEmptySliceProfiles) {
+ assertTrue("sliceProfileInstanceUri not found in contect Map", currentNSSI.get("sliceProfileInstanceUri") != null)
+ }
+
+ assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == expectedSize))
+ }
+
+
}