1 package org.openecomp.mso.bpmn.infrastructure.scripts
3 import com.github.tomakehurst.wiremock.junit.WireMockRule
4 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
5 import org.junit.Before
6 import org.junit.BeforeClass
7 import org.junit.Ignore
10 import org.mockito.MockitoAnnotations
11 import org.openecomp.mso.bpmn.infrastructure.scripts.DoCustomDeleteE2EServiceInstance
12 import org.openecomp.mso.bpmn.mock.FileUtil
13 import org.openecomp.mso.bpmn.vcpe.scripts.GroovyTestBase
15 import static org.mockito.Mockito.verify
16 import static org.mockito.Mockito.when
17 import static org.mockito.Mockito.when
18 import static org.mockito.Mockito.when
19 import static org.mockito.Mockito.when
20 import static org.mockito.Mockito.when
21 import static org.mockito.Mockito.when
22 import static org.mockito.Mockito.when
24 class DoCustomDeleteE2EServiceInstanceTest extends GroovyTestBase {
26 private static String request
29 public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT)
31 String Prefix = "CVRCS_"
32 String RbType = "DCRENI_"
35 public static void setUpBeforeClass() {
36 request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json")
42 MockitoAnnotations.initMocks(this)
44 public DoCustomDeleteE2EServiceInstanceTest(){
45 super("DoCustomDeleteE2EServiceInstance")
49 public void preProcessRequestTest(){
51 ExecutionEntity mex = setupMock()
52 def map = setupMap(mex)
55 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
56 instance.preProcessRequest(mex)
57 verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/")
58 verify(mex).setVariable("siParamsXml", "")
63 public void postProcessAAIGETTest(){
64 ExecutionEntity mex = setupMock()
65 def map = setupMap(mex)
67 when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(true)
69 String aaiGetResponse = FileUtil.readResourceFile("__files/GenericFlows/aaiGetResponse.xml")
70 when(mex.getVariable("GENGS_service")).thenReturn(aaiGetResponse)
71 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
72 instance.postProcessAAIGET(mex)
73 // TODO: what to test here?
74 // verify(mex).setVariable("subscriptionServiceType", "e2eserviceInstance/delete")
79 public void preInitResourcesOperStatusTest(){
80 ExecutionEntity mex = setupMock()
81 def map = setupMap(mex)
83 when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
84 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
85 instance.preInitResourcesOperStatus(mex)
86 // TODO: what to test here?
87 // verify(mex).setVariable("CVFMI_dbAdapterEndpoint", "http://localhost:8080/mso")
91 public void preResourceDeleteTest() {
92 ExecutionEntity mex = setupMock()
93 def map = setupMap(mex)
95 when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
96 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
97 instance.preResourceDelete(mex,"overlay")
98 verify(mex).setVariable("resourceType", "overlay")
103 public void postProcessSDNCDeleteTest(){
104 ExecutionEntity mex = setupMock()
105 def map = setupMap(mex)
107 when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn("true")
108 when(mex.getVariable("DDELSI_sdncResponseSuccess")).thenReturn("true")
109 when(mex.getVariable("prefix")).thenReturn("DDELSI_")
110 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
111 String response = FileUtil.readResourceFile("__files/GenericFlows/SDNCDeleteResponse.xml")
112 String method = "deleteE2E";
113 instance.postProcessSDNCDelete(mex, response, method)
114 // TODO: what to test here?
115 // verify(mex).setVariable("DDELSI_sdncRequestDataResponseCode", "0")
119 public void postProcessAAIDELTest() {
120 ExecutionEntity mex = setupMock()
121 def map = setupMap(mex)
123 when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true")
124 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
125 instance.postProcessAAIDEL(mex)
128 private void initPreProcess(ExecutionEntity mex) {
129 when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true")
130 when(mex.getVariable("bpmnRequest")).thenReturn(request)
131 when(mex.getVariable("mso-request-id")).thenReturn("mri")
132 when(mex.getVariable("serviceType")).thenReturn("VoLTE")
133 when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4")
134 when(mex.getVariable("requestAction")).thenReturn("ra")
135 when(mex.getVariable("operationId")).thenReturn("59960003992")
136 when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("/mso/sdncadapter/")
137 when(mex.getVariable("GENGS_FoundIndicator")).thenReturn("true")
138 when(mex.getVariable("GENGS_siResourceLink")).thenReturn("/service-subscription/e2eserviceInstance/delete/service-instances/")
139 when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123")
140 when(mex.getVariable("GENGS_service")).thenReturn("test3434")
141 when(mex.getVariable("URN_mso_openecomp_adapters_db_endpoint")).thenReturn("http://localhost:8080/mso")