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