From 48c44edbec6adf3a9b5b49f147cb026b8251ce7b Mon Sep 17 00:00:00 2001 From: Priyadharshini Date: Thu, 20 Aug 2020 06:06:49 -0700 Subject: Implement Workflows to handle NSSMF Common functionalities Issue-ID: SO-3190 Signed-off-by: Priyadharshini Change-Id: I38ce91415fc5ced083e017ed4306873d17d5fa24 --- .../scripts/ActivateSliceSubnetTest.groovy | 68 +++++++++++ .../scripts/AllocateSliceSubnetTest.groovy | 135 +++++++++++++++++++++ .../scripts/DeAllocateSliceSubnetTest.groovy | 72 +++++++++++ .../scripts/ModifySliceSubnetTest.groovy | 72 +++++++++++ 4 files changed, 347 insertions(+) create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy (limited to 'bpmn/so-bpmn-infrastructure-common/src/test/groovy') diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy new file mode 100644 index 0000000000..adb83e7714 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnetTest.groovy @@ -0,0 +1,68 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class ActivateSliceSubnetTest { + @Before + void init() throws IOException { + super.init("ActivateSliceSubnet") + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + when(mockExecution.getVariable("requestAction")).thenReturn("activateInstance") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + ActivateSliceSubnet sliceSubnet = new ActivateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy new file mode 100644 index 0000000000..a9b4e095e7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnetTest.groovy @@ -0,0 +1,135 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2020, Wipro Limited. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + + +class AllocateSliceSubnetTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("AllocateSliceSubnet") + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("serviceInstanceID")).thenReturn("12345") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "name": "eMBB-001", + "modelInvariantUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX", + "modelUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX-UUID", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "networkType": "an/cn/tn", + "additionalProperties": { + "sliceProfile": { + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "ab9af40f13f721b5f13539d87484098", + "plmnIdList": [ + "460-00", + "460-01" + ], + "perfReq": { + "perfReqEmbbList ": [ + { + "activityFactor": 50 + } + ] + }, + "maxNumberofUEs": 200, + "coverageAreaTAList": [ + "1", + "2", + "3", + "4" + ], + "latency": 2, + "resourceSharingLevel": "non-shared" + }, + "endPoints": [ + { + "nodeId": "", + "additionalInfo": { + "xxx": "xxx" + } + } + ], + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("dummyServiceId")).thenReturn("12345") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + AllocateSliceSubnet sliceSubnet = new AllocateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy new file mode 100644 index 0000000000..a254a90576 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnetTest.groovy @@ -0,0 +1,72 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class DeAllocateSliceSubnetTest { + + @Before + void init() throws IOException { + super.init("DeAllocateSliceSubnet") + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "snssaiList": [ + "001-100001" + ], + "scriptName": "AN1", + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + DeAllocateSliceSubnet sliceSubnet = new DeAllocateSliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy new file mode 100644 index 0000000000..b7515a487c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnetTest.groovy @@ -0,0 +1,72 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.junit.Assert.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor + +class ModifySliceSubnetTest { + @Before + void init() throws IOException { + super.init("ModifySliceSubnet") + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "serviceInstanceID": "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX ", + "networkType": "an/cn/tn", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "additionalProperties": { + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + } +} +""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture() as String, captor.capture()) + List values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("54321") + when(mockExecution.getVariable("jobId")).thenReturn("54321") + when(mockExecution.getVariable("nsiId")).thenReturn("11111") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("initResourceOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("jobId")).thenReturn("123456") + ModifySliceSubnet sliceSubnet = new ModifySliceSubnet() + sliceSubnet.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + @Test + public void test() { + fail("Not yet implemented") + } + +} -- cgit 1.2.3-korg