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 verify(mex).setVariable("subscriptionServiceType", "e2eserviceInstance/delete")
75 public void preInitResourcesOperStatusTest(){
76 ExecutionEntity mex = setupMock()
77 def map = setupMap(mex)
79 when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
80 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
81 instance.preInitResourcesOperStatus(mex)
82 verify(mex).setVariable("CVFMI_dbAdapterEndpoint", "http://localhost:8080/mso")
86 public void preResourceDeleteTest() {
87 ExecutionEntity mex = setupMock()
88 def map = setupMap(mex)
90 when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
91 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
92 instance.preResourceDelete(mex,"overlay")
93 verify(mex).setVariable("resourceType", "overlay")
98 public void postProcessSDNCDeleteTest(){
99 ExecutionEntity mex = setupMock()
100 def map = setupMap(mex)
102 when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn("true")
103 when(mex.getVariable("DDELSI_sdncResponseSuccess")).thenReturn("true")
104 when(mex.getVariable("prefix")).thenReturn("DDELSI_")
105 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
106 String response = FileUtil.readResourceFile("__files/GenericFlows/SDNCDeleteResponse.xml")
107 String method = "deleteE2E";
108 instance.postProcessSDNCDelete(mex, response, method)
109 verify(mex).setVariable("DDELSI_sdncRequestDataResponseCode", "0")
113 public void postProcessAAIDELTest() {
114 ExecutionEntity mex = setupMock()
115 def map = setupMap(mex)
117 when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true")
118 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
119 instance.postProcessAAIDEL(mex)
122 private void initPreProcess(ExecutionEntity mex) {
123 when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true")
124 when(mex.getVariable("bpmnRequest")).thenReturn(request)
125 when(mex.getVariable("mso-request-id")).thenReturn("mri")
126 when(mex.getVariable("serviceType")).thenReturn("VoLTE")
127 when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4")
128 when(mex.getVariable("requestAction")).thenReturn("ra")
129 when(mex.getVariable("operationId")).thenReturn("59960003992")
130 when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("/mso/sdncadapter/")
131 when(mex.getVariable("GENGS_FoundIndicator")).thenReturn("true")
132 when(mex.getVariable("GENGS_siResourceLink")).thenReturn("/service-subscription/e2eserviceInstance/delete/service-instances/")
133 when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123")
134 when(mex.getVariable("GENGS_service")).thenReturn("test3434")
135 when(mex.getVariable("URN_mso_openecomp_adapters_db_endpoint")).thenReturn("http://localhost:8080/mso")