2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
23 import com.github.tomakehurst.wiremock.junit.WireMockRule
24 import org.camunda.bpm.engine.delegate.BpmnError
25 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
26 import org.junit.Before
27 import org.junit.BeforeClass
28 import org.junit.Ignore
31 import org.mockito.MockitoAnnotations
32 import org.onap.so.bpmn.infrastructure.scripts.DoCustomDeleteE2EServiceInstance
33 import org.onap.so.bpmn.mock.FileUtil
34 import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase
36 import static org.assertj.core.api.Assertions.assertThatThrownBy
37 import static org.mockito.Matchers.anyString
38 import static org.mockito.Mockito.verify
39 import static org.mockito.Mockito.when
40 import static org.mockito.Mockito.eq
42 class DoCustomDeleteE2EServiceInstanceTest extends GroovyTestBase {
44 private static String request
47 public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT)
49 String Prefix = "CVRCS_"
50 String RbType = "DCRENI_"
53 public static void setUpBeforeClass() {
54 request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json")
60 MockitoAnnotations.initMocks(this)
62 public DoCustomDeleteE2EServiceInstanceTest(){
63 super("DoCustomDeleteE2EServiceInstance")
67 public void preProcessRequestTest(){
69 ExecutionEntity mex = setupMock()
70 def map = setupMap(mex)
73 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
74 instance.preProcessRequest(mex)
75 verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/")
76 verify(mex).setVariable("siParamsXml", "")
80 public void postProcessAAIGETSuccessTest(){
81 ExecutionEntity mex = setupMock()
82 def map = setupMap(mex)
84 when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(true)
86 String aaiGetResponse = FileUtil.readResourceFile("__files/GenericFlows/aaiGetResponse.xml")
87 when(mex.getVariable("GENGS_service")).thenReturn(aaiGetResponse)
88 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
89 instance.postProcessAAIGET(mex)
91 verify(mex).setVariable(eq("serviceRelationShip"), anyString())
95 public void postProcessAAIGETFailureTest(){
96 ExecutionEntity mex = setupMock()
97 def map = setupMap(mex)
99 when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(false)
100 when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(false)
102 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
103 assertThatThrownBy { instance.postProcessAAIGET(mex) } isInstanceOf BpmnError.class
107 public void preInitResourcesOperStatusTest(){
108 ExecutionEntity mex = setupMock()
109 def map = setupMap(mex)
111 when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
112 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
113 instance.preInitResourcesOperStatus(mex)
115 verify(mex).setVariable(eq("CVFMI_initResOperStatusRequest"), anyString())
119 public void preResourceDeleteTest() {
120 ExecutionEntity mex = setupMock()
121 def map = setupMap(mex)
123 when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
124 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
125 instance.preResourceDelete(mex,"overlay")
126 verify(mex).setVariable("resourceType", "overlay")
130 public void postProcessSDNCDeleteTest(){
131 ExecutionEntity mex = setupMock()
132 def map = setupMap(mex)
134 when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn("true")
135 when(mex.getVariable("DDELSI_sdncResponseSuccess")).thenReturn("true")
136 when(mex.getVariable("prefix")).thenReturn("DDELSI_")
137 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
138 String response = FileUtil.readResourceFile("__files/GenericFlows/SDNCDeleteResponse.xml")
139 String method = "deleteE2E";
140 instance.postProcessSDNCDelete(mex, response, method)
141 // following method doesn't do anything currently -> nothing to check
145 public void postProcessAAIDELTest() {
146 ExecutionEntity mex = setupMock()
147 def map = setupMap(mex)
149 when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true")
150 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
151 instance.postProcessAAIDEL(mex)
154 private void initPreProcess(ExecutionEntity mex) {
155 when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true")
156 when(mex.getVariable("bpmnRequest")).thenReturn(request)
157 when(mex.getVariable("mso-request-id")).thenReturn("mri")
158 when(mex.getVariable("serviceType")).thenReturn("VoLTE")
159 when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4")
160 when(mex.getVariable("requestAction")).thenReturn("ra")
161 when(mex.getVariable("operationId")).thenReturn("59960003992")
162 when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/")
163 when(mex.getVariable("GENGS_FoundIndicator")).thenReturn("true")
164 when(mex.getVariable("GENGS_siResourceLink")).thenReturn("/service-subscription/e2eserviceInstance/delete/service-instances/")
165 when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123")
166 when(mex.getVariable("GENGS_service")).thenReturn("test3434")
167 when(mex.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://localhost:8080/mso")