2cf09fe144d5f49473d203c19c483c35e6a84623
[so.git] / bpmn / MSOInfrastructureBPMN / src / test / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / DoCustomDeleteE2EServiceInstanceTest.groovy
1 package org.openecomp.mso.bpmn.infrastructure.scripts
2
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
8 import org.junit.Rule
9 import org.junit.Test
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
14
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
23
24 class DoCustomDeleteE2EServiceInstanceTest extends GroovyTestBase {
25
26     private static String request
27
28     @Rule
29     public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT)
30
31     String Prefix = "CVRCS_"
32     String RbType = "DCRENI_"
33
34     @BeforeClass
35     public static void setUpBeforeClass() {
36         request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json")
37     }
38
39     @Before
40     public void init()
41     {
42         MockitoAnnotations.initMocks(this)
43     }
44     public DoCustomDeleteE2EServiceInstanceTest(){
45         super("DoCustomDeleteE2EServiceInstance")
46     }
47
48     @Test
49     public void preProcessRequestTest(){
50
51         ExecutionEntity mex = setupMock()
52         def map = setupMap(mex)
53         initPreProcess(mex)
54
55         DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
56         instance.preProcessRequest(mex)
57         verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/")
58         verify(mex).setVariable("siParamsXml", "")
59     }
60
61     @Ignore
62     @Test
63     public void postProcessAAIGETTest(){
64         ExecutionEntity mex = setupMock()
65         def map = setupMap(mex)
66         initPreProcess(mex)
67         when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(true)
68
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")
75     }
76
77     @Ignore
78     @Test
79     public void preInitResourcesOperStatusTest(){
80         ExecutionEntity mex = setupMock()
81         def map = setupMap(mex)
82         initPreProcess(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")
88     }
89
90     @Test
91     public void preResourceDeleteTest() {
92         ExecutionEntity mex = setupMock()
93         def map = setupMap(mex)
94         initPreProcess(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")
99     }
100
101     @Ignore
102     @Test
103     public void postProcessSDNCDeleteTest(){
104         ExecutionEntity mex = setupMock()
105         def map = setupMap(mex)
106         initPreProcess(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")
116     }
117
118     @Test
119     public void postProcessAAIDELTest() {
120         ExecutionEntity mex = setupMock()
121         def map = setupMap(mex)
122         initPreProcess(mex)
123         when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true")
124         DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
125         instance.postProcessAAIDEL(mex)
126     }
127
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")
142     }
143 }