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
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
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
23 class DoCustomDeleteE2EServiceInstanceTest extends GroovyTestBase {
25 private static String request
28 public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT)
30 String Prefix = "CVRCS_"
31 String RbType = "DCRENI_"
34 public static void setUpBeforeClass() {
35 request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json")
41 MockitoAnnotations.initMocks(this)
43 public DoCustomDeleteE2EServiceInstanceTest(){
44 super("DoCustomDeleteE2EServiceInstance")
48 public void preProcessRequestTest(){
50 ExecutionEntity mex = setupMock()
51 def map = setupMap(mex)
54 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
55 instance.preProcessRequest(mex)
56 verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/")
57 verify(mex).setVariable("siParamsXml", "")
61 public void postProcessAAIGETTest(){
62 ExecutionEntity mex = setupMock()
63 def map = setupMap(mex)
65 when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(true)
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")
76 public void preInitResourcesOperStatusTest(){
77 ExecutionEntity mex = setupMock()
78 def map = setupMap(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")
88 public void preResourceDeleteTest() {
89 ExecutionEntity mex = setupMock()
90 def map = setupMap(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")
100 public void postProcessSDNCDeleteTest(){
101 ExecutionEntity mex = setupMock()
102 def map = setupMap(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")
116 public void postProcessAAIDELTest() {
117 ExecutionEntity mex = setupMock()
118 def map = setupMap(mex)
120 when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true")
121 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
122 instance.postProcessAAIDEL(mex)
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")