1 package org.openecomp.mso.bpmn.infrastructure.scripts
3 import com.github.tomakehurst.wiremock.junit.WireMockRule
4 import org.camunda.bpm.engine.delegate.BpmnError
5 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
6 import org.junit.Before
7 import org.junit.BeforeClass
8 import org.junit.Ignore
11 import org.mockito.MockitoAnnotations
12 import org.openecomp.mso.bpmn.mock.FileUtil
13 import org.openecomp.mso.bpmn.vcpe.scripts.GroovyTestBase
15 import static org.assertj.core.api.Assertions.assertThatThrownBy
16 import static org.mockito.Matchers.anyString
17 import static org.mockito.Mockito.verify
18 import static org.mockito.Mockito.when
19 import static org.mockito.Mockito.eq
21 class DoCustomDeleteE2EServiceInstanceTest extends GroovyTestBase {
23 private static String request
26 public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT)
28 String Prefix = "CVRCS_"
29 String RbType = "DCRENI_"
32 public static void setUpBeforeClass() {
33 request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json")
39 MockitoAnnotations.initMocks(this)
41 public DoCustomDeleteE2EServiceInstanceTest(){
42 super("DoCustomDeleteE2EServiceInstance")
46 public void preProcessRequestTest(){
48 ExecutionEntity mex = setupMock()
49 def map = setupMap(mex)
52 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
53 instance.preProcessRequest(mex)
54 verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/")
55 verify(mex).setVariable("siParamsXml", "")
59 public void postProcessAAIGETSuccessTest(){
60 ExecutionEntity mex = setupMock()
61 def map = setupMap(mex)
63 when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(true)
65 String aaiGetResponse = FileUtil.readResourceFile("__files/GenericFlows/aaiGetResponse.xml")
66 when(mex.getVariable("GENGS_service")).thenReturn(aaiGetResponse)
67 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
68 instance.postProcessAAIGET(mex)
70 verify(mex).setVariable(eq("serviceRelationShip"), anyString())
74 public void postProcessAAIGETFailureTest(){
75 ExecutionEntity mex = setupMock()
76 def map = setupMap(mex)
78 when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(false)
79 when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(false)
81 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
82 assertThatThrownBy { instance.postProcessAAIGET(mex) } isInstanceOf BpmnError.class
86 public void preInitResourcesOperStatusTest(){
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.preInitResourcesOperStatus(mex)
94 verify(mex).setVariable(eq("CVFMI_initResOperStatusRequest"), anyString())
98 public void preResourceDeleteTest() {
99 ExecutionEntity mex = setupMock()
100 def map = setupMap(mex)
102 when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]")
103 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
104 instance.preResourceDelete(mex,"overlay")
105 verify(mex).setVariable("resourceType", "overlay")
109 public void postProcessSDNCDeleteTest(){
110 ExecutionEntity mex = setupMock()
111 def map = setupMap(mex)
113 when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn("true")
114 when(mex.getVariable("DDELSI_sdncResponseSuccess")).thenReturn("true")
115 when(mex.getVariable("prefix")).thenReturn("DDELSI_")
116 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
117 String response = FileUtil.readResourceFile("__files/GenericFlows/SDNCDeleteResponse.xml")
118 String method = "deleteE2E";
119 instance.postProcessSDNCDelete(mex, response, method)
120 // following method doesn't do anything currently -> nothing to check
124 public void postProcessAAIDELTest() {
125 ExecutionEntity mex = setupMock()
126 def map = setupMap(mex)
128 when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true")
129 DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance()
130 instance.postProcessAAIDEL(mex)
133 private void initPreProcess(ExecutionEntity mex) {
134 when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true")
135 when(mex.getVariable("bpmnRequest")).thenReturn(request)
136 when(mex.getVariable("mso-request-id")).thenReturn("mri")
137 when(mex.getVariable("serviceType")).thenReturn("VoLTE")
138 when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4")
139 when(mex.getVariable("requestAction")).thenReturn("ra")
140 when(mex.getVariable("operationId")).thenReturn("59960003992")
141 when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("/mso/sdncadapter/")
142 when(mex.getVariable("GENGS_FoundIndicator")).thenReturn("true")
143 when(mex.getVariable("GENGS_siResourceLink")).thenReturn("/service-subscription/e2eserviceInstance/delete/service-instances/")
144 when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123")
145 when(mex.getVariable("GENGS_service")).thenReturn("test3434")
146 when(mex.getVariable("URN_mso_adapters_openecomp_db_endpoint")).thenReturn("http://localhost:8080/mso")