diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test')
20 files changed, 2995 insertions, 12 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy new file mode 100644 index 0000000000..3eefd31e63 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy @@ -0,0 +1,224 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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 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 + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class ActivateCommunicationServiceTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("ActivateCommunicationService") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + + String req = """ + { + "globalSubscriberId": "5GCustomer", + "serviceType": "5G", + "operationId": "test123" + } + """ + when(mockExecution.getVariable("bpmnRequest")).thenReturn(req) + when(mockExecution.getVariable("mso-request-id")).thenReturn("54321") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationType")).thenReturn("activation") + + ActivateCommunicationService service = new ActivateCommunicationService() + service.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(6)).setVariable(captor.capture(), captor.capture()) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + ActivateCommunicationService service = new ActivateCommunicationService() + + service.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("operationId")).thenReturn("123456") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + ActivateCommunicationService service = new ActivateCommunicationService() + service.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + @Test + void testPreRequestSend2NSMF() { + when(mockExecution.getVariable("e2e_service-instance.service-instance-id")).thenReturn("12333") + when(mockExecution.getVariable("requestParam")).thenReturn("activate") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("test111") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5GConsumer") + ActivateCommunicationService service = new ActivateCommunicationService() + service.preRequestSend2NSMF(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("CSMF_NSMFRequest"), captor.capture()) + String resultSuccess = captor.getValue() + + String expect = """ + { + "globalSubscriberId":"test111", + "serviceType":"5GConsumer" + } + """ + assertEquals(expect.replaceAll("\\s+", ""), resultSuccess.replaceAll("\\s+", "")) + } + + @Test + void testProcessNSMFResponseSuccess() { + when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(202) + when(mockExecution.getVariable("CSMF_NSMFResponse")).thenReturn(""" + { + "operationId": "e3819a23-3777-4172-a834-35ee78acf3f4" + } + """) + + ActivateCommunicationService service = new ActivateCommunicationService() + service.processNSMFResponse(mockExecution) + Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("e2eOperationId") + expect.add("e3819a23-3777-4172-a834-35ee78acf3f4") + expect.add("ProcessNsmfSuccess") + expect.add("OK") + assertEquals(expect, resultSuccess) + } + + @Test + void testProcessNSMFResponseError() { + when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(500) + ActivateCommunicationService service = new ActivateCommunicationService() + service.processNSMFResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("ProcessNsmfSuccess"), captor.capture()) + String resultSuccess = captor.getValue() + assertEquals("ERROR", resultSuccess) + } + + @Test + void testPrepareUpdateOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + when(mockExecution.getVariable("operationType")).thenReturn("activate") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")) + .thenReturn("http://localhost:28090/dbadapters/RequestsDbAdapter") + ActivateCommunicationService service = new ActivateCommunicationService() + + service.prepareUpdateOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "processing", "20", + "communication service activate operation processing: waiting nsmf service create finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + + private static getExpectPayload = { String type, String result, String progress, String operationContent -> + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:${type} xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>activate</operationType> + <userId>11111</userId> + <result>${result}</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:${type}> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + @Test + void testPrepareCallCheckProcessStatus() { + ActivateCommunicationService service = new ActivateCommunicationService() + service.prepareCallCheckProcessStatus(mockExecution) + Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + assertNotNull(resultSuccess) + } + + @Test + void testPrepareCompleteStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + when(mockExecution.getVariable("operationType")).thenReturn("activate") + when(mockExecution.getVariable("operationContent")) + .thenReturn("communication service activate operation finished") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("operationStatus")) + .thenReturn("deactivated") + ActivateCommunicationService service = new ActivateCommunicationService() + + service.prepareCompleteStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "deactivated", "100", + "communication service activate operation finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + +} + + diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy new file mode 100644 index 0000000000..f3c61dd628 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy @@ -0,0 +1,118 @@ +package org.onap.so.bpmn.infrastructure.scripts + +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 + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class ActivateSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("ActivateSliceService") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + + String req = """ + { + "globalSubscriberId": "5GCustomer", + "serviceType": "5G", + "operationId": "test123" + } + """ + when(mockExecution.getVariable("bpmnRequest")).thenReturn(req) + when(mockExecution.getVariable("mso-request-id")).thenReturn("54321") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationType")).thenReturn("activation") + + + ActivateSliceService service = new ActivateSliceService() + service.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture()) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + ActivateSliceService service = new ActivateSliceService() + + service.prepareInitServiceOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("operationId")).thenReturn("123456") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + ActivateSliceService service = new ActivateSliceService() + service.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + private static getExpectPayload = { String type, String result, String progress, String operationContent -> + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:${type} xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>activate</operationType> + <userId>11111</userId> + <result>${result}</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:${type}> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + @Test + void testPrepareCompleteStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + when(mockExecution.getVariable("operationType")).thenReturn("activate") + when(mockExecution.getVariable("operationContent")) + .thenReturn("slice service activate operation finished") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("operationStatus")) + .thenReturn("deactivated") + ActivateSliceService service = new ActivateSliceService() + + service.prepareCompletionRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "finished", "100", + "slice service activate operation finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy new file mode 100644 index 0000000000..f066f9e878 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy @@ -0,0 +1,344 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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 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 + +import static org.junit.Assert.assertEquals +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class CheckServiceProcessStatusTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("CheckServiceProcessStatus") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + + @Test + void testPreProcessRequest () { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture()) + } + + + @Test + void testPreCheckServiceStatusReq() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.preCheckServiceStatusReq(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("getOperationStatus"), captor.capture()) + String res = captor.getValue() + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:getServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + </ns:getServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + + + @Test + void testHandlerServiceStatusRespSuccess() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("finished")) + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("finished") + expect.add("operationContent") + expect.add("communication service create operation finished success") + expect.add("orchestrationStatus") + expect.add("deactivated") + expect.add("isAllFinished") + expect.add("true") + + assertEquals(expect, resultSuccess) + } + + + @Test + void testHandlerServiceStatusRespError() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("error")) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("error") + expect.add("operationContent") + expect.add("communication service create operation finished with error") + expect.add("orchestrationStatus") + expect.add("error") + expect.add("isAllFinished") + expect.add("true") + + assertEquals(expect, resultSuccess) + } + + + @Test + void testHandlerServiceStatusRespProcessingNo() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("processing")) + when(mockExecution.getVariable("progress")).thenReturn(50) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("isNeedUpdateDB") + expect.add("false") + expect.add("isAllFinished") + expect.add("false") + + assertEquals(expect as String, resultSuccess as String) + } + + + @Test + void testHandlerServiceStatusRespProcessingYes() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("processing")) + when(mockExecution.getVariable("progress")).thenReturn(60) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("progress") + expect.add("50") + expect.add("isNeedUpdateDB") + expect.add("true") + expect.add("isAllFinished") + expect.add("false") + + assertEquals(expect as String, resultSuccess as String) + } + + + @Test + void testTimeWaitDelayNo() { + mockData() + when(mockExecution.getVariable("startTime")).thenReturn(System.currentTimeMillis()) + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.timeWaitDelay(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("isTimeOut"), captor.capture()) + def res = captor.getValue() + + assertEquals("NO", res) + } + + + @Test + void testTimeWaitDelayYes() { + mockData() + when(mockExecution.getVariable("startTime")).thenReturn(1000000) + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.timeWaitDelay(mockExecution) + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def res = captor.getAllValues() + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("error") + expect.add("operationContent") + expect.add("communication service create operation finished with timeout") + expect.add("orchestrationStatus") + expect.add("error") + expect.add("isTimeOut") + expect.add("YES") + + assertEquals(expect, res) + } + + + @Test + void testPreUpdateOperationProgress() { + mockData() + when(mockExecution.getVariable("progress")).thenReturn(50) + when(mockExecution.getVariable("initProgress")).thenReturn(20) + when(mockExecution.getVariable("endProgress")).thenReturn(90) + when(mockExecution.getVariable("operationType")).thenReturn("CREATE") + when(mockExecution.getVariable("processServiceType")).thenReturn("communication service") + when(mockExecution.getVariable("parentServiceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("parentOperationId")).thenReturn("54321") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.preUpdateOperationProgress(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("55", + "communication service CREATE operation processing 55") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + + + } + + + private static String getExpectPayload(String progress, String operationContent) { + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:updateServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>CREATE</operationType> + <userId>11111</userId> + <result>processing</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:updateServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + + private static String getDBResponse(String result) { + String response = + """<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <ns2:getServiceOperationStatusResponse xmlns:ns2="http://org.onap.so/requestsdb"> + <return><operation>CREATE</operation> + <operationContent>Prepare service creation</operationContent> + <operationId>077995e3-eb32-44ae-b35d-491fc6983a44</operationId> + <progress>50</progress> + <reason></reason> + <result>${result}</result> + <serviceId>3324f117-696d-4518-b8b5-b01fcc127a03</serviceId> + <userId>5GCustomer</userId> + </return></ns2:getServiceOperationStatusResponse> + </soap:Body> + </soap:Envelope> + """ + return response + } + + + private mockData() { + when(mockExecution.getVariable("processServiceType")).thenReturn("communication service") + when(mockExecution.getVariable("operationType")).thenReturn("create") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationServiceTest.groovy new file mode 100644 index 0000000000..3622cc0062 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationServiceTest.groovy @@ -0,0 +1,456 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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 org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.json.JSONObject +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 +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInfo +import org.onap.so.bpmn.core.domain.ServiceProxy + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class CreateCommunicationServiceTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("CreateCommunicationService") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "requestDetails": { + "modelInfo": { + "modelInvariantId": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "modelType": "service", + "modelNameVersionId": "8ee5926d-720b-4bb2-86f9-d20e921c143b", + "modelName": "voLTE", + "modelVersion": "1.0", + "modelVersionId": "8ee5926d-720b-4bb2-86f9-d20e921c143b", + "modelUuid": "8ee5926d-720b-4bb2-86f9-d20e921c143b", + "modelInvariantUuid": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51" + }, + "requestInfo": { + "source": "UUI", + "instanceName": "CSMFService", + "suppressRollback": true + }, + "subscriberInfo": { + "globalSubscriberId": "5GCustomer" + }, + "requestParameters": { + "subscriptionServiceType": "MOG", + "userParams": [{ + "ServiceInstanceName": "CSMFService", + "UUIRequest": "{\\r\\n \\ + "service\\":{\\r\\n \\"name\\":\\"CSMFService\\",\\r\\n + \\"description\\":\\"CSMFService\\",\\r\\n + \\"serviceInvariantUuid\\":\\"e75698d9-925a-4cdd-a6c0-edacbe6a0b51\\",\\r\\n + \\"serviceUuid\\":\\"8ee5926d-720b-4bb2-86f9-d20e921c143b\\",\\r\\n + \\"globalSubscriberId\\":\\"5GCustomer\\",\\r\\n + \\"serviceType\\":\\"5G\\",\\r\\n + \\"parameters\\":{\\r\\n + \\"requestInputs\\":{\\r\\n + \\"expDataRateDL\\":10,\\r\\n + \\"expDataRateUL\\":30,\\r\\n + \\"latency\\":20,\\r\\n + \\"maxNumberofUEs\\":300,\\r\\n + \\"uemobilityLevel\\":\\"stationary\\",\\r\\n + \\"resourceSharingLevel\\":\\"shared\\",\\r\\n + \\"coverageAreaList\\": \\"01001\\",\\r\\n + \\"useInterval\\":\\"3\\"\\r\\n + }\\r\\n + }\\r\\n }\\r\\n}\\r\\n" + }], + "aLaCarte": true, + "usePreload": true + } + }, + "serviceInstanceId": null, + "vnfInstanceId": null, + "networkInstanceId": null, + "volumeGroupInstanceId": null, + "vfModuleInstanceId": null, + "configurationId": null, + "instanceGroupId": null + }""".replaceAll("\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e") + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(14)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + CreateCommunicationService communicationService = new CreateCommunicationService() + + communicationService.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("operationId")).thenReturn("123456") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + + @Test + void testPrepareDoComposeE2E() { + ServiceDecomposition serviceDecomposition = new ServiceDecomposition() + ServiceProxy serviceProxy = new ServiceProxy() + serviceProxy.setSourceModelUuid("f2f5967e-72d3-4c5c-b880-e214e71dba4e") + serviceDecomposition.setServiceProxy(Arrays.asList(serviceProxy)) + when(mockExecution.getVariable("csServiceDecomposition")).thenReturn(serviceDecomposition) + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.prepareDoComposeE2E(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("e2eServiceModelInfo"), captor.capture()) + String e2eServiceModelInfo = captor.getValue() + assertEquals(e2eServiceModelInfo.trim().replaceAll(" ", ""), + """{"modelUuid":"f2f5967e-72d3-4c5c-b880-e214e71dba4e"}""") + } + + @Test + void testParseCSParamsFromReq() { + mockData() + when(mockExecution.getVariable("csServiceModelInfo")).thenReturn(""" + { + "modelInvariantUuid":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "modelName":"voLTE", + "modelNameVersionId":"8ee5926d-720b-4bb2-86f9-d20e921c143b", + "modelVersion":"1.0", + "modelVersionId":"8ee5926d-720b-4bb2-86f9-d20e921c143b", + "modelInvariantId":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "modelType":"service", + "modelUuid":"8ee5926d-720b-4bb2-86f9-d20e921c143b" + }""") + + ServiceDecomposition decomposition = new ServiceDecomposition() + decomposition.setServiceType("embb") + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.setServiceProperties(""" + [{"name":"useInterval","type":"string","required":false}, + {"default":"39-00","name":"plmnIdList","type":"string","required":false}, + {"name":"maxNumberofUEs","type":"integer","required":false}, + {"name":"latency","type":"integer","required":false}, + {"name":"uEMobilityLevel","type":"string","required":false}, + {"name":"expDataRateUL","type":"integer","required":false}, + {"name":"expDataRateDL","type":"integer","required":false}, + {"name":"coverageAreaList","type":"string","required":false}, + {"name":"sNSSAI","type":"string","required":false}, + {"name":"resourceSharingLevel","type":"string","required":false}] + """) + decomposition.setServiceInfo(serviceInfo) + + when(mockExecution.getVariable("csServiceDecomposition")).thenReturn(decomposition) + + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.parseCSParamsFromReq(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("csInputMap"), captor.capture()) + def csInputMap = captor.getValue() + assertEquals(getExpectCsInputMap(), csInputMap) + + } + + private static Map<String, Object> getExpectCsInputMap() { + Map<String, Object> csInputMap = new HashMap<>() + csInputMap.put("expDataRateDL", 10) + csInputMap.put("expDataRateUL", 30) + csInputMap.put("latency", 20) + csInputMap.put("maxNumberofUEs", 300) + csInputMap.put("uEMobilityLevel", "stationary") + csInputMap.put("resourceSharingLevel", "shared") + csInputMap.put("coverageAreaTAList", "01001") + csInputMap.put("useInterval", "3") + csInputMap.put("coverageAreaList", null) + csInputMap.put("plmnIdList", "39-00") + csInputMap.put("sNSSAI", null) + return csInputMap + } + + @Test + void testGenerateE2EServiceProfile() { + ServiceDecomposition decomposition = new ServiceDecomposition() + decomposition.setServiceType("embb") + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.setServiceProperties(""" + [{"name":"nstar0_allottedresource0_providing_service_uuid","type":"string","required":true}, + {"name":"areaTrafficCapDL","type":"integer","required":false}, + {"name":"maxNumberofUEs","type":"integer","required":false}, + {"name":"latency","type":"integer","required":false}, + {"name":"expDataRateUL","type":"integer","required":false}, + {"name":"sNSSAI","type":"string","required":false}, + {"name":"plmnIdList","type":"string","required":false}, + {"name":"sST","type":"integer","required":false}, + {"name":"areaTrafficCapUL","type":"integer","required":false}, + {"name":"uEMobilityLevel","type":"string","required":false}, + {"name":"expDataRateDL","type":"integer","required":false}, + {"name":"nstar0_allottedresource0_providing_service_invariant_uuid","type":"string","required":true}, + {"name":"coverageAreaTAList","type":"string","required":false}, + {"name":"activityFactor","type":"integer","required":false}, + {"name":"resourceSharingLevel","type":"string","required":false}] + """) + decomposition.setServiceInfo(serviceInfo) + + ModelInfo modelInfo = new ModelInfo() + modelInfo.setModelInvariantUuid("e75698d9-925a-4cdd-a6c0-edacbe6a0b51") + modelInfo.setModelUuid("8ee5926d-720b-4bb2-86f9-d20e921c143b") + decomposition.setModelInfo(modelInfo) + + when(mockExecution.getVariable("e2eServiceDecomposition")).thenReturn(decomposition) + when(mockExecution.getVariable("csInputMap")).thenReturn(getExpectCsInputMap()) + + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.generateE2EServiceProfile(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(eq("e2eInputMap"), captor.capture()) + def csInputMap = captor.getValue() + assertEquals(csInputMap, getExpectE2eInputMap()) + } + + private static Map<String, Object> getExpectE2eInputMap() { + Map<String, Object> e2eInputMap = new HashMap<>() + e2eInputMap.put("nstar0_allottedresource0_providing_service_uuid", null) + e2eInputMap.put("nstar0_allottedresource0_providing_service_invariant_uuid", null) + e2eInputMap.put("areaTrafficCapDL", 100) + e2eInputMap.put("areaTrafficCapUL", 100) + e2eInputMap.put("expDataRateDL", 10) + e2eInputMap.put("expDataRateUL", 30) + e2eInputMap.put("latency", 20) + e2eInputMap.put("maxNumberofUEs", 300) + e2eInputMap.put("uEMobilityLevel", "stationary") + e2eInputMap.put("resourceSharingLevel", "shared") + e2eInputMap.put("coverageAreaTAList", "01001") + e2eInputMap.put("sST", null) + e2eInputMap.put("activityFactor", 0) + e2eInputMap.put("plmnIdList", "39-00") + e2eInputMap.put("sNSSAI", null) + + return e2eInputMap + } + + @Test + void testPreRequestSend2NSMF() { + when(mockExecution.getVariable("e2eInputMap")).thenReturn(getExpectE2eInputMap()) + when(mockExecution.getVariable("csServiceName")).thenReturn("testName") + when(mockExecution.getVariable("modelUuid")).thenReturn("12345") + when(mockExecution.getVariable("e2eModelInvariantUuid")).thenReturn("54321") + when(mockExecution.getVariable("e2eModelUuid")).thenReturn("11111") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("test111") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5GConsumer") + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.preRequestSend2NSMF(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("CSMF_NSMFRequest"), captor.capture()) + String resultSuccess = captor.getValue() + + def expectMap = getExpectE2eInputMap() + expectMap.put("nstar0_allottedresource0_providing_service_uuid", null) + expectMap.put("nstar0_allottedresource0_providing_service_invariant_uuid", null) + + String expect = """ + { + "service":{ + "name": "testName", + "description": "e2eService of 12345", + "serviceInvariantUuid": "54321", + "serviceUuid": "11111", + "globalSubscriberId": "test111", + "serviceType": "5GConsumer", + "parameters":{ + "requestInputs": ${expectMap as JSONObject} + } + } + } + """ + assertEquals(expect.replaceAll("\\s+", ""), resultSuccess.replaceAll("\\s+", "")) + } + + @Test + void testProcessNSMFResponseSuccess() { + when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(202) + when(mockExecution.getVariable("CSMF_NSMFResponse")).thenReturn(""" + { + "service": { + "serviceId": "945063ff-1a01-4944-9232-8e7999e0d5e4", + "operationId": "e3819a23-3777-4172-a834-35ee78acf3f4" + } + } + """) + + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.processNSMFResponse(mockExecution) + Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("e2eServiceInstanceId") + expect.add("945063ff-1a01-4944-9232-8e7999e0d5e4") + expect.add("e2eOperationId") + expect.add("e3819a23-3777-4172-a834-35ee78acf3f4") + expect.add("ProcessNsmfSuccess") + expect.add("OK") + assertEquals(expect, resultSuccess) + } + + @Test + void testProcessNSMFResponseError() { + when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(500) + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.processNSMFResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("ProcessNsmfSuccess"), captor.capture()) + String resultSuccess = captor.getValue() + assertEquals("ERROR", resultSuccess) + } + + @Test + void testPrepareUpdateOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")) + .thenReturn("http://localhost:28090/dbadapters/RequestsDbAdapter") + CreateCommunicationService communicationService = new CreateCommunicationService() + + communicationService.prepareUpdateOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "processing", "20", + "communication service create operation processing: waiting nsmf service create finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + + + @Test + void testPrepareCallCheckProcessStatus() { + CreateCommunicationService communicationService = new CreateCommunicationService() + communicationService.prepareCallCheckProcessStatus(mockExecution) + Mockito.verify(mockExecution, times(10)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + assertNotNull(resultSuccess) + } + + + @Test + void testPrepareCompleteStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + when(mockExecution.getVariable("operationContent")) + .thenReturn("communication service create operation finished") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("operationStatus")) + .thenReturn("processing") + CreateCommunicationService communicationService = new CreateCommunicationService() + + communicationService.prepareCompleteStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "processing", "100", + "communication service create operation finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + + private static String getExpectPayload(String type, String result, String progress, String operationContent) { + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:${type} xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>CREATE</operationType> + <userId>11111</userId> + <result>${result}</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:${type}> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + private void mockData() { + when(mockExecution.getVariable("uuiRequest")).thenReturn("""{ + "service":{ + "name":"CSMFService", + "description":"CSMFService", + "serviceInvariantUuid":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "serviceUuid":"8ee5926d-720b-4bb2-86f9-d20e921c143b", + "globalSubscriberId":"5GCustomer", + "serviceType":"5G", + "parameters":{ + "requestInputs":{ + "expDataRateDL":10, + "expDataRateUL":30, + "latency":20, + "maxNumberofUEs":300, + "uemobilityLevel":"stationary", + "resourceSharingLevel":"shared", + "coverageAreaList": "01001", + "useInterval":"3" + } + } + } + }""") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy new file mode 100644 index 0000000000..6b7944cc6e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * 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 org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.json.JSONObject +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.beans.nsmf.SliceTaskParams +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInfo +import org.onap.so.bpmn.core.domain.ServiceProxy + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class CreateSliceServiceTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("CreateSliceService") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + final String bpmnRequest = """ + { + "requestDetails": { + "modelInfo": { + "modelInvariantId": "123456", + "modelType": "service", + "modelNameVersionId": "123456", + "modelName": "Service Profile", + "modelVersion": "1.0", + "modelVersionId": "123456", + "modelUuid": "123456", + "modelInvariantUuid": "123456" + }, + "requestInfo": { + "source": "UUI", + "instanceName": "NSMF", + "suppressRollback": true + }, + "subscriberInfo": { + "globalSubscriberId": "5GCustomer" + }, + "requestParameters": { + "subscriptionServiceType": "MOG", + "userParams": [{ + "ServiceInstanceName": "NSMF", + "UUIRequest": { + "service":{ + "name": "NSMF", + "description": "CSMFService", + "serviceInvariantUuid": "123456", + "serviceUuid": "123456", + "globalSubscriberId": "5GCustomer", + "serviceType": "5G", + "parameters": {}, + "requestInputs": { + "sST": "embb", + "sNSSAI": "1-10101", + "uEMobilityLevel": "stationary", + "areaTrafficCapDL": 123, + "maxNumberofUEs": 1000, + "expDataRateUL": 2000, + "plmnIdList": "39-00|39-01", + "areaTrafficCapUL": 456, + "latency": 300, + "expDataRateDL": 400, + "coverageAreaTAList": 101001, + "activityFactor": 99, + "resourceSharingLevel": "shared" + } + } + } + }], + "aLaCarte": true, + "usePreload": true + } + }, + "serviceInstanceId": null, + "vnfInstanceId": null, + "networkInstanceId": null, + "volumeGroupInstanceId": null, + "vfModuleInstanceId": null, + "configurationId": null, + "instanceGroupId": null + }""".replaceAll("\\s+", "") + + final String uuiRequest = """ + "service":{ + "name": "NSMF", + "description": "CSMFService", + "serviceInvariantUuid": "123456", + "serviceUuid": "123456", + "globalSubscriberId": "5GCustomer", + "serviceType": "5G", + "parameters": {}, + "requestInputs": { + "sST": "embb", + "sNSSAI": "1-10101", + "uEMobilityLevel": "stationary", + "areaTrafficCapDL": 123, + "maxNumberofUEs": 1000, + "expDataRateUL": 2000, + "plmnIdList": "39-00|39-01", + "areaTrafficCapUL": 456, + "latency": 300, + "expDataRateDL": 400, + "coverageAreaTAList": 101001, + "activityFactor": 99, + "resourceSharingLevel": "shared" + } + }""".replaceAll("\\s+", "") + + final def serviceProfile = ["sST": "embb", "sNSSAI": "1-10101", "uEMobilityLevel": "stationary", "areaTrafficCapDL": 123, + "maxNumberofUEs": 1000, "expDataRateUL": 2000, "plmnIdList": "39-00|39-01", "areaTrafficCapUL": 456, + "latency": 300, "expDataRateDL": 400, "coverageAreaTAList": 101001, "activityFactor": 99, + "resourceSharingLevel": "shared"] + + final def nstSolution = ["UUID": "aaaaaa", "NSTName": "test NST", "invariantUUID": "bbbbbb", "matchLevel": "100%"] + + @Test + void testPreProcessRequest() { + when(mockExecution.getVariable("bpmnRequest")).thenReturn(bpmnRequest) + when(mockExecution.getVariable("mso-request-id")).thenReturn("123456") + CreateSliceService sliceService = new CreateSliceService() + sliceService.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(14)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy new file mode 100644 index 0000000000..8c08e51efe --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy @@ -0,0 +1,308 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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 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.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DeleteCommunicationServiceTest extends MsoGroovyTest { + + private HttpClientFactory httpClientFactoryMock + private HttpClient httpClientMock + + @Before + void init() throws IOException { + super.init("DeleteCommunicationServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "globalSubscriberId ":"5GCustomer", + "serviceType ":"5G" + }""".replaceAll("\\\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + + DeleteCommunicationService delCS = new DeleteCommunicationService() + delCS.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPreInitUpdateOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("processing") + when(mockExecution.getVariable("progress")).thenReturn("0") + when(mockExecution.getVariable("operationContent")).thenReturn("delete communication service operation start") + + DeleteCommunicationService delCS = new DeleteCommunicationService() + delCS.preInitUpdateOperationStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testQueryCommunicationSeriveFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.queryCommunicationSeriveFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("e2eSliceServiceInstanceId"), captor.capture()) + String e2eSliceServiceInstanceId = captor.getValue() + assertNotNull(e2eSliceServiceInstanceId) + } + + @Test + void testPrepareCallCheckProcessStatus(){ + DeleteCommunicationService dcs = new DeleteCommunicationService() + dcs.prepareCallCheckProcessStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("endProgress"), captor.capture()) + int endProgress = captor.getValue() + assertEquals(90,endProgress) + } + + @Test + void testDelCSProfileFromAAI() + { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceProfile()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-111111") + + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + doNothing().when(client).delete(profileUri) + obj.delCSProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testPrepareFailureStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("finished") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure.") + + DeleteCommunicationService dcs = new DeleteCommunicationService() + dcs.prepareFailureStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelCSFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.delCSFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testPreFailedOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("error") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure") + + DeleteCommunicationService deleteCommunicationService = new DeleteCommunicationService() + WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure") + when(mockExecution.getVariable("WorkflowException")).thenReturn(exception) + deleteCommunicationService.preFailedOperationStatus(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testSendRequest2NSMFWF(){ + httpClientMock = mock(HttpClient.class) + httpClientFactoryMock = mock(HttpClientFactory.class) + String url ="http://so.onap:8080/onap/so/infra/e2eServiceInstances/v3/5G-777" + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("progress")).thenReturn("20") + when(mockExecution.getVariable("operationContent")).thenReturn("waiting nsmf service delete finished") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://so.onap:8080/onap/so/infra") + when(mockExecution.getVariable("e2eSliceServiceInstanceId")).thenReturn("5G-777") + when(mockExecution.getVariable("e2eOperationId")).thenReturn("e151059a-d924-4629-845f-264db19e50b3") + when(httpClientFactoryMock.newJsonClient(new URL(url), ONAPComponents.SO)).thenReturn(httpClientMock) + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + + Response responseMock = mock(Response.class) + when(responseMock.getStatus()).thenReturn(200) + when(responseMock.hasEntity()).thenReturn(true) + when(responseMock.getEntity()).thenReturn(getNSSMFResponse()) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + when(httpClientMock.delete(anyString())).thenReturn(responseMock) + + obj.sendRequest2NSMFWF(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + private String getNSSMFResponse(){ + String response = """{ + "service":{ + "serviceId":"e151059a-d924-4629-845f-264db19e50b4", + "operationId":"e151059a-d924-4629-845f-264db19e50b3" + } + }""" + return response + } + + + + + private String mockQueryCommunicationServiceReturn() + { + String expect = + """{ + "service-instance-id": "5G-666", + "service-instance-name": "eMBB_Slice_Communication_Service_5GCustomer", + "service-type": "eMBB", + "service-role": "communication-service", + "environment-context": "01-010101", + "workload-context": "12", + "created-at": "2019-12-11 19:56:00", + "description": "", + "model-invariant-id": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "model-version-id": "8ee5926d-720b-4bb2-86f9-d20e921c143b", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1582623470778", + "orchestration-status": "created", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-777" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + }""" + return expect + } + + private String mockQueryCommunicationServiceProfile() + { + String expect = + """{ + "communication-service-profile": [ + { + "profile-id": "5G-111111", + "max-number-of-UEs": 50, + "coverage-area-list": "longgang,futian", + "latency": 20, + "exp-data-rate-UL": 300, + "exp-data-rate-DL": 500, + "ue-mobility-level": "stationary", + "resource-sharing-level": "Non-Shared", + "resource-version": "1577454950460" + } + ] + }""" + return expect + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy new file mode 100644 index 0000000000..fb50fcc43b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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 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 +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when + +class DeleteSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("result")).thenReturn("processing") + when(mockExecution.getVariable("progress")).thenReturn("0") + when(mockExecution.getVariable("operationContent")).thenReturn("Delete Slice service operation start") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "globalSubscriberId ":"5GCustomer", + "serviceType ":"5G" + }""".replaceAll("\\\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + + DeleteSliceService delSS = new DeleteSliceService() + delSS.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus = captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDeleteSliceServiceInstance(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + when(mockExecution.getVariable("result")).thenReturn("finished") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("NSMF completes slicing service termination.") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteSliceService obj = spy(DeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.deleteSliceServiceInstance(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelServiceProfileFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceProfile()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-2222222") + + DeleteSliceService obj = spy(DeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + doNothing().when(client).delete(profileUri) + obj.delServiceProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testPrepareEndOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("error") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure") + + DeleteSliceService deleteSliceService = new DeleteSliceService() + WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure") + when(mockExecution.getVariable("WorkflowException")).thenReturn(exception) + deleteSliceService.prepareEndOperationStatus(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + + } + + private String mockQuerySliceServiceProfile(){ + String expect = + """{ + "service-profile": [ + { + "profile-id": "5G-2222222", + "latency": 50, + "max-number-of-UEs": 500, + "coverage-area-TA-list": "longgang,futian", + "ue-mobility-level": "stationary", + "resource-sharing-level": "Non-Shared", + "exp-data-rate-UL": 10, + "exp-data-rate-DL": 30, + "area-traffic-cap-UL": 100, + "area-traffic-cap-DL": 100, + "activity-factor": 80, + "jitter": 10, + "survival-time": 30, + "cs-availability": 95.5, + "reliability": 99.9, + "exp-data-rate": 80, + "traffic-density": 100, + "conn-density": 80, + "resource-version": "1577454958647" + } + ] + }""" + return expect + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationServiceTest.groovy new file mode 100644 index 0000000000..37207f8022 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationServiceTest.groovy @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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 org.camunda.bpm.engine.delegate.BpmnError +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.aai.domain.yang.CommunicationServiceProfile +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.client.aai.AAIResourcesClient + +import static com.shazam.shazamcrest.MatcherAssert.assertThat +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DoCreateCommunicationServiceTest extends MsoGroovyTest { + + private DoCreateCommunicationService communicationService = new DoCreateCommunicationService() + + @Before + public void setUp() throws Exception { + super.init("DoCreateCommunicationService") + communicationService.client = spy(AAIResourcesClient.class) + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPreProcessRequest(){ + mockData() + DoCreateCommunicationService communicationService = new DoCreateCommunicationService() + communicationService.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + assertNotNull(captor.getAllValues()) + } + + @Test + public void testCreateCommunicationService() { + mockData() + ServiceInstance expectedServiceInstanceData = getExpectedServiceInstance() + + try { + communicationService.createCommunicationService(mockExecution) + } catch (Exception e) { + + assertEquals(e.class, BpmnError.class) + } + + + Mockito.verify(mockExecution).setVariable(eq("communicationServiceInstance"), captor.capture()) + ServiceInstance resData = captor.getValue() + resData.setCreatedAt("") + resData.setEnvironmentContext("") + assertThat(resData, sameBeanAs(expectedServiceInstanceData)) + } + + @Test + public void testCreateCommunicationServiceProfile() { + mockData() + DoCreateCommunicationService communicationService = new DoCreateCommunicationService() + + CommunicationServiceProfile expectedServiceInstanceData = getExpectedServiceInstanceProfile() + + try { + communicationService.createCommunicationServiceProfile(mockExecution) + } catch (Exception e) { + assertEquals(e.class, BpmnError.class) + } + + Mockito.verify(mockExecution).setVariable(eq("communicationServiceInstanceProfile"), captor.capture()) + CommunicationServiceProfile resData = captor.getValue() + resData.setProfileId("") + assertThat(resData, sameBeanAs(expectedServiceInstanceData)) + } + + private static CommunicationServiceProfile getExpectedServiceInstanceProfile() { + CommunicationServiceProfile expectedServiceInstanceData = new CommunicationServiceProfile() + expectedServiceInstanceData.setProfileId("") + expectedServiceInstanceData.setLatency(20) + expectedServiceInstanceData.setMaxNumberOfUEs(300) + expectedServiceInstanceData.setUeMobilityLevel("stationary") + expectedServiceInstanceData.setResourceSharingLevel("shared") + expectedServiceInstanceData.setExpDataRateUL(30) + expectedServiceInstanceData.setExpDataRateDL(10) + expectedServiceInstanceData.setCoverageAreaList("01001") + return expectedServiceInstanceData + } + + private static ServiceInstance getExpectedServiceInstance() { + ServiceInstance expectedServiceInstanceData = new ServiceInstance() + expectedServiceInstanceData.setServiceInstanceName("CSMFService") + expectedServiceInstanceData.setServiceRole("communication-service") + expectedServiceInstanceData.setOrchestrationStatus("processing") + expectedServiceInstanceData.setModelInvariantId("e75698d9-925a-4cdd-a6c0-edacbe6a0b51") + expectedServiceInstanceData.setModelVersionId("8ee5926d-720b-4bb2-86f9-d20e921c143b") + expectedServiceInstanceData.setInputParameters("""{ + "service":{ + "name":"CSMFService", + "description":"CSMFService", + "serviceInvariantUuid":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "serviceUuid":"8ee5926d-720b-4bb2-86f9-d20e921c143b", + "globalSubscriberId":"5GCustomer", + "serviceType":"5G", + "parameters":{ + "requestInputs":{ + "expDataRateDL":10, + "expDataRateUL":30, + "latency":20, + "maxNumberofUEs":300, + "uemobilityLevel":"stationary", + "resourceSharingLevel":"shared", + "coverageAreaList": "01001", + "useInterval":"3" + } + } + } + }""") + expectedServiceInstanceData.setWorkloadContext("3") + expectedServiceInstanceData.setCreatedAt("") + expectedServiceInstanceData.setEnvironmentContext("") + return expectedServiceInstanceData + } + + private void mockData() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("CSMFService") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("uuiRequest")).thenReturn("""{ + "service":{ + "name":"CSMFService", + "description":"CSMFService", + "serviceInvariantUuid":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "serviceUuid":"8ee5926d-720b-4bb2-86f9-d20e921c143b", + "globalSubscriberId":"5GCustomer", + "serviceType":"5G", + "parameters":{ + "requestInputs":{ + "expDataRateDL":10, + "expDataRateUL":30, + "latency":20, + "maxNumberofUEs":300, + "uemobilityLevel":"stationary", + "resourceSharingLevel":"shared", + "coverageAreaList": "01001", + "useInterval":"3" + } + } + } + }""") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + Map<String, Object> csInputMap = new HashMap<>() + csInputMap.put("expDataRateDL", 10) + csInputMap.put("expDataRateUL", 30) + csInputMap.put("latency", 20) + csInputMap.put("maxNumberofUEs", 300) + csInputMap.put("uEMobilityLevel", "stationary") + csInputMap.put("resourceSharingLevel", "shared") + csInputMap.put("coverageAreaTAList", "01001") + csInputMap.put("useInterval", "3") + + when(mockExecution.getVariable("csInputMap")).thenReturn(csInputMap) + + when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("e75698d9-925a-4cdd-a6c0-edacbe6a0b51") + when(mockExecution.getVariable("modelUuid")).thenReturn("8ee5926d-720b-4bb2-86f9-d20e921c143b") + when(mockExecution.getVariable("useInterval")).thenReturn("3") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy index dd18049b5f..7107d15602 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy @@ -45,6 +45,7 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.mock.FileUtil import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException @@ -168,7 +169,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ fqdnList.add("test") when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) uri.queryParam("network-policy-fqdn", "test") NetworkPolicies networkPolicies = new NetworkPolicies(); NetworkPolicy networkPolicy = new NetworkPolicy(); @@ -198,7 +199,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ fqdnList.add("test") when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) uri.queryParam("network-policy-fqdn", "test") NetworkPolicies networkPolicies = new NetworkPolicies(); NetworkPolicy networkPolicy = new NetworkPolicy(); @@ -228,7 +229,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ fqdnList.add("test") when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) uri.queryParam("network-policy-fqdn", "test") NetworkPolicies networkPolicies = new NetworkPolicies(); NetworkPolicy networkPolicy = new NetworkPolicy(); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy index 5c68cc7fc1..8941a24ebc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy @@ -27,6 +27,7 @@ import org.onap.aai.domain.yang.VolumeGroup import org.onap.aai.domain.yang.VolumeGroups; import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.client.aai.AAIObjectPlurals +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults @@ -50,7 +51,7 @@ public class DoCreateVfModuleVolumeRollbackTest extends MsoGroovyTest { String cloudRegionId = "cloudRegionId" when(mockExecution.getVariable("DCVFMODVOLRBK_volumeGroupName")).thenReturn(volumeGroupName) when(mockExecution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId")).thenReturn(cloudRegionId) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegionId).queryParam("volume-group-name", volumeGroupName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegionId).queryParam("volume-group-name", volumeGroupName) VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("volumeGroupId") VolumeGroups groups = new VolumeGroups(); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy index ddb1fbade4..22414b770e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy @@ -40,6 +40,7 @@ import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.core.RollbackData import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults @@ -160,7 +161,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { String lcpCloudRegionId = "lcpCloudRegionId" when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName) when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName) VolumeGroups volumeGroups = new VolumeGroups(); VolumeGroup volumeGroup = new VolumeGroup() volumeGroup.setVolumeGroupId("volumeGroupId") @@ -176,7 +177,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { String lcpCloudRegionId = "lcpCloudRegionId" when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName) when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName) when(client.get(VolumeGroup.class,uri)).thenReturn(Optional.empty()) thrown.expect(BpmnError.class) doCreateVfModuleVolumeV2.callRESTQueryAAIVolGrpName(mockExecution,null) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy new file mode 100644 index 0000000000..493e2c9e1e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy @@ -0,0 +1,258 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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 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.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.JobStatusResponse +import org.onap.so.beans.nsmf.NssiResponse +import org.onap.so.beans.nsmf.ResponseDescriptor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.domain.ServiceArtifact +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInfo +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.core.Response + +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.anyString +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class DoDeallocateNSSITest extends MsoGroovyTest { + + private HttpClientFactory httpClientFactoryMock + private HttpClient httpClientMock + + @Before + void init() throws IOException { + super.init("DoDeallocateNSSITest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + + @Test + void testPreProcessRequest(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI") + } + + @Test + void testPrepareDecomposeService(){ + def currentNSSI = [:] + currentNSSI.put("modelInvariantId", "21d57d4b-52ad-4d3c-a798-248b5bb9124b") + currentNSSI.put("modelVersionId", "bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.prepareDecomposeService(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("serviceModelInfo"), captor.capture()) + String serviceModelInfo = captor.getValue() + assertNotNull(serviceModelInfo) + } + + @Test + void testProcessDecomposition(){ + def currentNSSI = [:] + ServiceArtifact artifact = new ServiceArtifact() + artifact.setContent(getArtifactContent()) + ServiceInfo serviceInfo = new ServiceInfo() + List<ServiceArtifact> artifactList = new ArrayList<>() + artifactList.add(artifact) + serviceInfo.setServiceArtifact(artifactList) + ServiceDecomposition decomposition = new ServiceDecomposition() + decomposition.setServiceInfo(serviceInfo) + when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.processDecomposition(mockExecution) + String vendor = currentNSSI.get("vendor") + assertNotNull(vendor) + } + + @Test + void testHandleJobStatus(){ + def currentNSSI = [:] + currentNSSI.put("jobProgress", 10) + currentNSSI.put("proportion", 90) + currentNSSI.put("statusDescription","") + currentNSSI.put("e2eServiceInstanceId","21d57d4b-52ad-4d3c-a798-248b5bb9124b") + currentNSSI.put("operationId","4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.handleJobStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelSliceProfileFromAAI(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId", "5G-999") + currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + currentNSSI.put("globalSubscriberId","5GCustomer") + currentNSSI.put("serviceType","5G") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, "5GCustomer", "5G", "5G-999", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(profileUri)).thenReturn(true) + doNothing().when(client).delete(profileUri) + + obj.delSliceProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testSendRequestToNSSMF(){ + httpClientFactoryMock = mock(HttpClientFactory.class) + httpClientMock = mock(HttpClient.class) + + def currentNSSI = [:] + currentNSSI.put("snssai", "01-010101") + currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + currentNSSI.put("nssiServiceInstanceId","5G-999") + currentNSSI.put("nsiServiceInstanceId","5G-888") + + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088") + String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/SliceProfiles/ddf57704-fe8d-417b-882d-2f2a12ddb225" + + when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock) + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + Response responseMock = mock(Response.class) + NssiResponse response = new NssiResponse() + response.setNssiId("NSSI-C-004-HDBHZ-NSSMF-01-A-HW") + response.setJobId("a5c5913d-448a-bcb1-9b800a944d84") + when(httpClientMock.post(anyString())).thenReturn(responseMock) + when(responseMock.getStatus()).thenReturn(202) + when(responseMock.readEntity(NssiResponse.class)) thenReturn(response) + when(responseMock.hasEntity()).thenReturn(true) + + obj.sendRequestToNSSMF(mockExecution) + String jobId = currentNSSI['jobId'] + assertNotNull(jobId) + } + + @Test + void testGetJobStatus(){ + httpClientFactoryMock = mock(HttpClientFactory.class) + httpClientMock = mock(HttpClient.class) + + def currentNSSI = [:] + currentNSSI.put("jobId", "a5c5913d-448a-bcb1-9b800a944d84") + currentNSSI.put("nssiServiceInstanceId","5G-999") + currentNSSI.put("nsiServiceInstanceId","5G-888") + currentNSSI.put("jobProgress",60) + + when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false) + when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088") + String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/jobs/a5c5913d-448a-bcb1-9b800a944d84" + + when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock) + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + Response responseMock = mock(Response.class) + ResponseDescriptor descriptor = new ResponseDescriptor() + descriptor.setProgress(100) + descriptor.setStatusDescription("finished deallocate nssi") + JobStatusResponse jobStatusResponse = new JobStatusResponse() + jobStatusResponse.setResponseDescriptor(descriptor) + when(httpClientMock.post(anyString())).thenReturn(responseMock) + when(responseMock.getStatus()).thenReturn(202) + when(responseMock.readEntity(JobStatusResponse.class)) thenReturn(jobStatusResponse) + when(responseMock.hasEntity()).thenReturn(true) + + obj.getJobStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("isNSSIDeAllocated"), captor.capture()) + boolean value = captor.getValue() + assertTrue(value) + } + + + private String getArtifactContent(){ + String content = + """ + { + "metadata":{ + "id":"NSST-C-001-HDBNJ-NSSMF-01-A-HW", + "vendor":"HW", + "version":"1.0", + "name":"eMBB_demo", + "description":"eMBB for demo", + "type":"embb", + "domainType":"cn" + }, + "capabilities":{ + "latency":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"20" + }, + "areaTrafficCapDL":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + }, + "areaTrafficCapUL":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + }, + "maxNumberofUEs":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + } + } + } + """ + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy new file mode 100644 index 0000000000..8a18376819 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy @@ -0,0 +1,460 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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 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.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when + +class DoDeleteSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DoDeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("e2a747a0-2ca6-476d-ac28-de999cf3fbfe") + + DoDeleteSliceService doDeleteSliceService = new DoDeleteSliceService() + doDeleteSliceService.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testQueryE2ESliceSeriveFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.queryE2ESliceSeriveFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("snssai"), captor.capture()) + String snssai = captor.getValue() + assertNotNull(snssai) + } + + @Test + void testGetAllottedResFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryAllottedResource()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getAllottedResFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nsiId"), captor.capture()) + String nsiId = captor.getValue() + assertNotNull(nsiId) + } + + @Test + void testGetNSIFromAAI(){ + when(mockExecution.getVariable("nsiId")).thenReturn("5G-888") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-888") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockNSIReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getNSIFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiIdList"), captor.capture()) + List<String> nssiIdList = captor.getValue() + assertNotNull(nssiIdList) + } + + @Test + void testGetNSSIListFromAAI(){ + List<String> nssiIdList = [] + nssiIdList.add("5G-999") + + when(mockExecution.getVariable("nssiIdList")).thenReturn(nssiIdList) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-999") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockNSSIReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getNSSIListFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiInstanceList"), captor.capture()) + List<ServiceInstance> nssiInstanceList = captor.getValue() + assertNotNull(nssiInstanceList) + } + + @Test + void testGetCurrentNSSI(){ + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId("5G-999") + nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124a") + nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + List<ServiceInstance> nssiInstanceList = [] + nssiInstanceList.add(nssi) + when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0) + when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList) + when(mockExecution.getVariable("snssai")).thenReturn("01-010101") + when(mockExecution.getVariable("nsiId")).thenReturn("5G-888") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5G-777") + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("proportion")).thenReturn("90") + + DoDeleteSliceService ddss = new DoDeleteSliceService() + ddss.getCurrentNSSI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture()) + Map currentNSSI = captor.getValue() + assertTrue(currentNSSI.size()>0) + } + + @Test + void testQuerySliceProfileFromAAI(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockSliceProfile()) + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE_ALL, "5GCustomer", "5G", "5G-999") + + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(profileUri, NotFoundException.class)).thenReturn(wrapper) + obj.querySliceProfileFromAAI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture()) + Map value = captor.getValue() + assertNotNull(currentNSSI.get('profileId')) + } + + @Test + void parseNextNSSI(){ + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId("5G-999") + nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124b") + nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + List<ServiceInstance> nssiInstanceList = [] + nssiInstanceList.add(nssi) + when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0) + when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList) + + DoDeleteSliceService ddss = new DoDeleteSliceService() + ddss.parseNextNSSI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("isAllNSSIFinished"), captor.capture()) + boolean isAllNSSIFinished = captor.getValue() + assertTrue(isAllNSSIFinished) + } + + private String mockSliceProfile(){ + String expect = + """{ + "slice-profile": [ + { + "profile-id": "ddf57704-fe8d-417b-882d-2f2a12ddb225", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\\"province\\":\\"??\\",\\"city\\":\\"???\\",\\"county\\":\\"???\\",\\"street\\":\\"?????\\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01003", + "resource-version": "1580800791373" + } + ] + } + """ + return expect + } + + private String mockNSSIReturn(){ + String expect = + """ + { + "service-instance-id": "5G-999", + "service-instance-name": "eMBB_Slice_NSSI_5GCustomer", + "service-type": "eMBB", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a", + "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1578449638032", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-888" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + } + """ + return expect + } + + private String mockNSIReturn(){ + String expect = + """ + { + "service-instance-id": "5G-888", + "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer", + "service-type": "embb", + "service-role": "nsi", + "model-invariant-id": "0e9bcb9a-c832-433b-a0c1-74866768f608", + "model-version-id": "2c5fd79d-0f84-4057-9222-952cb6f27036", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1579691104911", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-999", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-999" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_Slice_NSSI_5GCustomer" + } + ] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777/allotted-resources/allotted-resource/5G-1234", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-777" + }, + { + "relationship-key": "allotted-resource.id", + "relationship-value": "5G-1234" + } + ], + "related-to-property": [ + { + "property-key": "allotted-resource.description" + }, + { + "property-key": "allotted-resource.allotted-resource-name" + } + ] + } + ] + } + } + """ + return expect + } + + private String mockQueryAllottedResource(){ + String expect = + """{ + "allotted-resource": [ + { + "id": "5G-1234", + "resource-version": "1577454983471", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-888" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + } + ] + } + """ + return expect + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "5G-777", + "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer", + "service-type": "embb", + "service-role": "e2eslice-service", + "environment-context": "01-010101", + "model-invariant-id": "e65d737a-41e0-4ad1-958f-56defdf2e907", + "model-version-id": "f2f5967e-72d3-4c5c-b880-e214e71dba4e", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1578449638436", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-666", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-666" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_Slice_Communication_Service_5GCustomer" + } + ] + } + ] + } + } + """ + return expect + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy index f356845a1e..a8d07b696c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy @@ -44,6 +44,7 @@ import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.core.WorkflowException import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth @@ -105,7 +106,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest { List fqdnList = new ArrayList() fqdnList.add("test") when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) uri.queryParam("network-policy-fqdn", "test") NetworkPolicies networkPolicies = new NetworkPolicies(); NetworkPolicy networkPolicy = new NetworkPolicy(); @@ -127,7 +128,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest { List fqdnList = new ArrayList() fqdnList.add("test") when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) uri.queryParam("network-policy-fqdn", "test") when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.empty()) deleteVfModuleFromVnf.deleteNetworkPoliciesFromAAI(mockExecution) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy index b56e108faf..815b3a389c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy @@ -47,6 +47,7 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.mock.FileUtil import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory @@ -104,7 +105,7 @@ class DoDeleteVfModuleTest extends MsoGroovyTest{ NetworkPolicy networkPolicy = new NetworkPolicy() networkPolicy.setNetworkPolicyId("NP1") networkPolicies.getNetworkPolicy().add(networkPolicy) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) uri.queryParam("network-policy-fqdn", "test") when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies)) doDeleteVfModule.deleteNetworkPoliciesFromAAI(mockExecution) @@ -120,7 +121,7 @@ class DoDeleteVfModuleTest extends MsoGroovyTest{ NetworkPolicy networkPolicy = new NetworkPolicy() networkPolicy.setNetworkPolicyId("NP1") networkPolicies.getNetworkPolicy().add(networkPolicy) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) uri.queryParam("network-policy-fqdn", "test") when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies)) AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "NP1") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java index 289d97108f..05b0db5d25 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java @@ -33,8 +33,6 @@ import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java new file mode 100644 index 0000000000..3c568ffc83 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.RequestParameters; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.io.IOException; +import java.util.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + + +@RunWith(SpringJUnit4ClassRunner.class) +public class NfSoftwareUpgradeDispatcherTest { + + private static final String TEST_PROCESS_KEY = "processKey1"; + private static final String PROCESS_KEY = "testProcessKey"; + private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource"; + private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap"; + private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1"; + private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144"; + private static final String TEST_PNF_CORRELATION_ID = "PNFDemo"; + private static final String TEST_PNF_UUID = "FakeID"; + private static final String TEST_PRC_CONTROLLER_ACTOR = "cds"; + private static final String TEST_TARGET_SOFTWARE_VERSION = "demo-sw-ver2.0.0"; + + private static final String TEST_BPMN_REQUEST = "{\"requestDetails\":{" + "\"requestInfo\":{" + + "\"source\":\"VID\"," + "\"suppressRollback\":false," + "\"requestorId\":\"demo\"," + + "\"productFamilyId\":\"SWUPid\"}," + "\"modelInfo\":{" + + "\"modelType\":\"service\",\"modelInvariantUuid\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\"," + + "\"modelInvariantId\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\"," + + "\"modelUuid\":\"42daaac6-5017-4e1e-96c8-6a27dfbe1421\",\"modelName\":\"PNF_int_service_2\"," + + "\"modelVersion\":\"1.0\"},\"requestParameters\":{\"userParams\":[{\"name\":\"aic_zone\"," + + "\"value\":\"nova\"},{\"name\":\"pnfId\",\"value\":\"PNFDemo\"},{\"name\":\"targetSoftwareVersion\",\"value\":\"demo-sw-ver2.0.0\"}]," + + "\"subscriptionServiceType\":\"SWUP\",\"aLaCarte\":false,\"pnfCorrelationId\":\"PNFDemo\"}," + + "\"cloudConfiguration\":{\"lcpCloudRegionId\":\"regionOne\",\"tenantId\":\"09a63533072f4a579d5c99c3b8fe94c6\"}," + + "\"subscriberInfo\":{\"globalSubscriberId\":\"ADemoCustomerInEric\"},\"project\":{\"projectName\":\"Project-Demonstration\"}," + + "\"owningEntity\":{\"owningEntityId\":\"5eae949c-1c50-4780-b8b5-7cbeb08856b4\",\"owningEntityName\":\"OE-Demonstration\"}}}"; + /** + * Testing model UUID, should be the same as specified in the TEST_SERVICE_MODEL_INFO. + */ + private static final String TEST_MODEL_UUID = "42daaac6-5017-4e1e-96c8-6a27dfbe1421"; + + @InjectMocks + private NfSoftwareUpgradeDispatcher nfSoftwareUpgradeDispatcher; + + @Mock + private PnfManagement pnfManagement; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private ObjectMapper mapper; + + private DelegateExecution execution = new DelegateExecutionFake(); + + @Before + public void setUp() throws IOException { + List<PnfResourceCustomization> pnfResourceCustomizations = new ArrayList<>(); + pnfResourceCustomizations.add(buildPnfResourceCustomization()); + given(catalogDbClient.getPnfResourceCustomizationByModelUuid(TEST_MODEL_UUID)) + .willReturn(pnfResourceCustomizations); + execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY); + execution.setVariable("bpmnRequest", TEST_BPMN_REQUEST); + mockMapper(); + mockAai(); + + } + + + @Test + public void testExecution_validCatalogDb_skipVariableSet() { + try { + nfSoftwareUpgradeDispatcher.execute(execution); + assertThat(execution.getVariable(MODEL_UUID)).isEqualTo(TEST_MODEL_UUID); + assertThat(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION)).isEqualTo(TEST_TARGET_SOFTWARE_VERSION); + assertThat(execution.getVariable(PRC_BLUEPRINT_NAME)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME); + assertThat(execution.getVariable(PRC_BLUEPRINT_VERSION)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION); + assertThat(execution.getVariable(PRC_CUSTOMIZATION_UUID)).isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID); + assertThat(execution.getVariable(PRC_INSTANCE_NAME)).isEqualTo(TEST_PNF_RESOURCE_INSTANCE_NAME); + assertThat(execution.getVariable(PNF_CORRELATION_ID)).isEqualTo(TEST_PNF_CORRELATION_ID); + assertThat(execution.getVariable(PNF_UUID)).isEqualTo(TEST_PNF_UUID); + assertThat(execution.getVariable(PRC_CONTROLLER_ACTOR)).isEqualTo(TEST_PRC_CONTROLLER_ACTOR); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception thrown" + e.getMessage()); + } + } + + private void mockAai() throws IOException { + Pnf pnf = new Pnf(); + pnf.setPnfId(TEST_PNF_UUID); + when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.of(pnf)); + } + + private PnfResourceCustomization buildPnfResourceCustomization() { + PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); + pnfResourceCustomization.setSkipPostInstConf(true); + pnfResourceCustomization.setBlueprintName(TEST_PNF_RESOURCE_BLUEPRINT_NAME); + pnfResourceCustomization.setBlueprintVersion(TEST_PNF_RESOURCE_BLUEPRINT_VERSION); + pnfResourceCustomization.setModelInstanceName(TEST_PNF_RESOURCE_INSTANCE_NAME); + pnfResourceCustomization.setModelCustomizationUUID(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID); + pnfResourceCustomization.setControllerActor(TEST_PRC_CONTROLLER_ACTOR); + return pnfResourceCustomization; + } + + private void mockMapper() throws IOException { + RequestDetails bpmnRequestDetails = new RequestDetails(); + + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("demo"); + bpmnRequestDetails.setRequestInfo(requestInfo); + + RequestParameters requestParameters = new RequestParameters(); + List<Map<String, Object>> userParams = new ArrayList<>(); + Map<String, Object> map = new HashMap<>(); + map.put("name", "targetSoftwareVersion"); + map.put("value", TEST_TARGET_SOFTWARE_VERSION); + userParams.add(map); + map = new HashMap<>(); + map.put("name", "pnfName"); + map.put("value", "PNFDemo"); + userParams.add(map); + requestParameters.setUserParams(userParams); + + bpmnRequestDetails.setRequestParameters(requestParameters); + + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantUuid("439b7a2f-9524-4dbf-9eee-f2e05521df3f"); + modelInfo.setModelInvariantId("439b7a2f-9524-4dbf-9eee-f2e05521df3f"); + modelInfo.setModelUuid("42daaac6-5017-4e1e-96c8-6a27dfbe1421"); + modelInfo.setModelName("PNF_int_service_2"); + modelInfo.setModelVersion("1.0"); + + bpmnRequestDetails.setModelInfo(modelInfo); + + + doReturn(bpmnRequestDetails).when(mapper).readValue( + JsonUtils.getJsonValue(String.valueOf(execution.getVariable("bpmnRequest")), "requestDetails"), + RequestDetails.class); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index 8577d9555b..b93902d9f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -50,6 +50,11 @@ public class PnfManagementTestImpl implements PnfManagement { } @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException { + created.put(pnfCorrelationId, entry); + } + + @Override public void createRelation(String serviceInstanceId, String pnfName) {} public Map<String, Pnf> getCreated() { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java index f9b467c650..77377db9d9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java @@ -38,6 +38,11 @@ public class PnfManagementThrowingException implements PnfManagement { } @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException { + throw new IOException(); + } + + @Override public void createRelation(String serviceInstanceId, String pnfName) throws IOException { throw new IOException(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java new file mode 100644 index 0000000000..bddfe5b180 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.*; +import java.io.IOException; +import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + +@RunWith(SpringJUnit4ClassRunner.class) +public class UpdatePnfEntryInAaiTest { + + @InjectMocks + private UpdatePnfEntryInAai updatePnfEntryInAai; + + @Mock + private PnfManagement pnfManagementTest; + + private DelegateExecution execution; + + + + @Test + public void shouldSetSwVersion() throws Exception { + // given + setupPnf(); + setupExecution(); + + // when + updatePnfEntryInAai.execute(execution); + + // verify + Optional<Pnf> modifiedEntry = pnfManagementTest.getEntryFor("testPnfCorrelationId"); + assertNotNull(modifiedEntry.get()); + assertThat(modifiedEntry.get().getPnfId()).isEqualTo("testtest"); + assertThat(modifiedEntry.get().getPnfName()).isEqualTo("testPnfCorrelationId"); + assertThat(modifiedEntry.get().getSwVersion()).isEqualTo("demo-1.2"); + verify(pnfManagementTest, times(2)).getEntryFor(anyString()); + } + + private void setupPnf() { + try { + Pnf pnf = new Pnf(); + pnf.setSwVersion("1"); + pnf.setPnfId("testtest"); + pnf.setPnfName("testPnfCorrelationId"); + doReturn(Optional.of(pnf)).when(pnfManagementTest).getEntryFor(anyString()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void setupExecution() { + execution = mock(DelegateExecution.class); + given(execution.getVariable(eq(PNF_CORRELATION_ID))).willReturn("testPnfCorrelationId"); + given(execution.getVariable(eq(PNF_UUID))).willReturn("testtest"); + given(execution.getVariable(eq(PRC_TARGET_SOFTWARE_VERSION))).willReturn("demo-1.2"); + } +} |