3692153aa0f36de6d0ad10c525355f1b2708236f
[so.git] /
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.Rule
8 import org.junit.Test
9 import org.mockito.MockitoAnnotations
10 import org.openecomp.mso.bpmn.infrastructure.scripts.DoCustomDeleteE2EServiceInstance
11 import org.openecomp.mso.bpmn.mock.FileUtil
12 import org.openecomp.mso.bpmn.vcpe.scripts.GroovyTestBase
13
14 import static org.mockito.Mockito.verify
15 import static org.mockito.Mockito.when
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
23 class DoCustomDeleteE2EServiceInstanceTest extends GroovyTestBase {
24
25     private static String request
26
27     @Rule
28     public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT)
29
30     String Prefix = "CVRCS_"
31     String RbType = "DCRENI_"
32
33     @BeforeClass
34     public static void setUpBeforeClass() {
35         request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json")
36     }
37
38     @Before
39     public void init()
40     {
41         MockitoAnnotations.initMocks(this)
42     }
43     public DoCustomDeleteE2EServiceInstanceTest(){
44         super("DoCustomDeleteE2EServiceInstance")
45     }
46
47     @Test
48     public void preProcessRequestTest(){
49
50         ExecutionEntity mex = setupMock()
51         def map = setupMap(mex)
52         initPreProcess(mex)
53
54         DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
55         instance.preProcessRequest(mex)
56         verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/")
57         verify(mex).setVariable("siParamsXml", "")
58     }
59
60     @Test
61     public void postProcessAAIGETTest(){
62         ExecutionEntity mex = setupMock()
63         def map = setupMap(mex)
64         initPreProcess(mex)
65         when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(true)
66
67         String aaiGetResponse = FileUtil.readResourceFile("__files/GenericFlows/aaiGetResponse.xml")
68         when(mex.getVariable("GENGS_service")).thenReturn(aaiGetResponse)
69         DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
70         instance.postProcessAAIGET(mex)
71                 // TODO: what to test here?
72 //        verify(mex).setVariable("subscriptionServiceType", "e2eserviceInstance/delete")
73     }
74
75     @Test
76     public void preInitResourcesOperStatusTest(){
77         ExecutionEntity mex = setupMock()
78         def map = setupMap(mex)
79         initPreProcess(mex)
80         when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
81         DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
82         instance.preInitResourcesOperStatus(mex)
83                 // TODO: what to test here?
84 //        verify(mex).setVariable("CVFMI_dbAdapterEndpoint", "http://localhost:8080/mso")
85     }
86
87     @Test
88     public void preResourceDeleteTest() {
89         ExecutionEntity mex = setupMock()
90         def map = setupMap(mex)
91         initPreProcess(mex)
92         when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
93         DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
94         instance.preResourceDelete(mex,"overlay")
95         verify(mex).setVariable("resourceType", "overlay")
96     }
97
98
99     @Test
100     public void postProcessSDNCDeleteTest(){
101         ExecutionEntity mex = setupMock()
102         def map = setupMap(mex)
103         initPreProcess(mex)
104         when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn("true")
105         when(mex.getVariable("DDELSI_sdncResponseSuccess")).thenReturn("true")
106         when(mex.getVariable("prefix")).thenReturn("DDELSI_")
107         DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
108         String response = FileUtil.readResourceFile("__files/GenericFlows/SDNCDeleteResponse.xml")
109         String method = "deleteE2E";
110         instance.postProcessSDNCDelete(mex, response, method)
111                 // TODO: what to test here?
112 //        verify(mex).setVariable("DDELSI_sdncRequestDataResponseCode", "0")
113     }
114
115     @Test
116     public void postProcessAAIDELTest() {
117         ExecutionEntity mex = setupMock()
118         def map = setupMap(mex)
119         initPreProcess(mex)
120         when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true")
121         DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
122         instance.postProcessAAIDEL(mex)
123     }
124
125     private void initPreProcess(ExecutionEntity mex) {
126         when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true")
127         when(mex.getVariable("bpmnRequest")).thenReturn(request)
128         when(mex.getVariable("mso-request-id")).thenReturn("mri")
129         when(mex.getVariable("serviceType")).thenReturn("VoLTE")
130         when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4")
131         when(mex.getVariable("requestAction")).thenReturn("ra")
132         when(mex.getVariable("operationId")).thenReturn("59960003992")
133         when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("/mso/sdncadapter/")
134         when(mex.getVariable("GENGS_FoundIndicator")).thenReturn("true")
135         when(mex.getVariable("GENGS_siResourceLink")).thenReturn("/service-subscription/e2eserviceInstance/delete/service-instances/")
136         when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123")
137         when(mex.getVariable("GENGS_service")).thenReturn("test3434")
138         when(mex.getVariable("URN_mso_openecomp_adapters_db_endpoint")).thenReturn("http://localhost:8080/mso")
139     }
140 }