2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 CMCC All rights reserved. *
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.so.bpmn.infrastructure.scripts
22 import com.github.tomakehurst.wiremock.junit.WireMockRule
23 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
24 import org.junit.Before
25 import org.junit.BeforeClass
28 import org.mockito.MockitoAnnotations
29 import org.onap.so.bpmn.mock.FileUtil
30 import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase
32 import static org.mockito.Mockito.verify
33 import static org.mockito.Mockito.when
35 class DoScaleE2EServiceInstanceTest extends GroovyTestBase {
37 private static String request
40 public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT)
42 String Prefix = "CVRCS_"
45 public static void setUpBeforeClass() {
46 request = FileUtil.readResourceFile("__files/InfrastructureFlows/DoScaleE2EServiceInstance.json")
52 MockitoAnnotations.initMocks(this)
54 public DoScaleE2EServiceInstanceTest(){
55 super("DoScaleE2EServiceInstance")
59 public void preProcessRequestTest(){
61 ExecutionEntity mex = setupMock()
62 def map = setupMap(mex)
65 DoScaleE2EServiceInstance instance = new DoScaleE2EServiceInstance()
66 instance.preProcessRequest(mex)
67 verify(mex).setVariable("resourceTemplateUUIDs", "ns111:ns333:")
71 public void preInitResourcesOperStatusTest(){
72 ExecutionEntity mex = setupMock()
73 def map = setupMap(mex)
75 DoScaleE2EServiceInstance instance = new DoScaleE2EServiceInstance()
76 instance.preInitResourcesOperStatus(mex)
78 verify(mex).setVariable("serviceInstanceId","e151059a-d924-4629-845f-264db19e50b4")
79 verify(mex).setVariable("operationId", "59960003992")
80 verify(mex).setVariable("operationType", "SCALE")
81 verify(mex).setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
84 """<soapenv:Envelope xmlns:ns="http://org.onap.so/requestsdb"
85 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
88 <ns:initResourceOperationStatus>
89 <serviceId>e151059a-d924-4629-845f-264db19e50b4</serviceId>
90 <operationId>59960003992</operationId>
91 <operationType>SCALE</operationType>
92 <resourceTemplateUUIDs>ns111:ns333:</resourceTemplateUUIDs>
93 </ns:initResourceOperationStatus>
95 </soapenv:Envelope>"""
96 verify(mex).setVariable("CVFMI_initResOperStatusRequest", payload)
99 private void initPreProcess(ExecutionEntity mex) {
100 when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true")
101 when(mex.getVariable("bpmnRequest")).thenReturn(request)
102 when(mex.getVariable("msoRequestId")).thenReturn("mri")
103 when(mex.getVariable("serviceType")).thenReturn("VoLTE")
104 when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4")
105 when(mex.getVariable("serviceInstanceName")).thenReturn("ra")
106 when(mex.getVariable("operationId")).thenReturn("59960003992")
107 when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123")
108 when(mex.getVariable("resourceTemplateUUIDs")).thenReturn("ns111:ns333:")