2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
23 import com.github.tomakehurst.wiremock.junit.WireMockRule
24 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
25 import org.junit.Before
26 import org.junit.BeforeClass
29 import org.mockito.MockitoAnnotations
30 import org.onap.so.bpmn.mock.FileUtil
31 import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase
33 import static org.mockito.Mockito.verify
34 import static org.mockito.Mockito.when
36 class DeleteCustomE2EServiceInstanceTest extends GroovyTestBase {
38 private static String request
41 public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT)
43 String Prefix = "CVRCS_"
44 String RbType = "DCRENI_"
47 public static void setUpBeforeClass() {
48 request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json")
54 MockitoAnnotations.initMocks(this)
57 public DeleteCustomE2EServiceInstanceTest(){
58 super("DeleteCustomE2EServiceInstance")
61 public void preProcessRequestTest () {
62 ExecutionEntity mex = setupMock()
63 def map = setupMap(mex)
65 DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance()
66 mex.setVariable("isDebugLogEnabled","true")
67 instance.preProcessRequest(mex);
69 verify(mex).getVariable(GroovyTestBase.DBGFLAG)
71 Map<String,String> userParams = new HashMap<>()
72 userParams.put("someUserParam","someValue")
74 verify(mex).setVariable("prefix", "DELSI_")
75 verify(mex).setVariable("msoRequestId", "mri")
76 verify(mex).setVariable("source", "CCD")
77 verify(mex).setVariable("operationType", "DELETE")
78 verify(mex).setVariable("globalSubscriberId", "38829939920000")
79 verify(mex).setVariable("serviceInputParams",userParams)
83 public void sendSyncResponseTest() {
84 ExecutionEntity mex = setupMock()
85 def map = setupMap(mex)
87 DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance()
88 instance.sendSyncResponse(mex)
89 verify(mex).setVariable("DeleteCustomE2EServiceInstanceWorkflowResponseSent", "true")
93 public void prepareCompletionRequestTest(){
94 ExecutionEntity mex = setupMock()
95 def map = setupMap(mex)
97 DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance()
98 instance.prepareCompletionRequest(mex)
99 String msoComplitionRequest = FileUtil.readResourceFile("__files/GenericFlows/MsoCompletionRequest.xml")
100 //verify(mex).setVariable("completionRequest", msoComplitionRequest)
104 public void sendSyncErrorTest(){
105 ExecutionEntity mex = setupMock()
106 def map = setupMap(mex)
108 DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance()
109 instance.sendSyncError(mex)
114 public void prepareFalloutRequest(){
115 ExecutionEntity mex = setupMock()
116 def map = setupMap(mex)
118 DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance()
119 instance.prepareFalloutRequest(mex)
121 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
122 <request-id>null</request-id>
123 <action>DELETE</action>
124 <source>null</source>
126 //verify(mex).setVariable("falloutRequest", requestInfo)
130 public void processJavaExceptionTest(){
131 ExecutionEntity mex = setupMock()
132 def map = setupMap(mex)
134 DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance()
135 instance.processJavaException()
139 private void initPreProcess(ExecutionEntity mex) {
140 when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true")
141 when(mex.getVariable("bpmnRequest")).thenReturn(request)
142 when(mex.getVariable("mso-request-id")).thenReturn("mri")
143 when(mex.getVariable("serviceType")).thenReturn("VoLTE")
144 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
145 when(mex.getVariable("requestAction")).thenReturn("ra")
146 when(mex.getVariable("operationId")).thenReturn("59960003992")