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.common.scripts
23 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
24 import org.junit.Before
26 import org.junit.runner.RunWith
27 import org.mockito.MockitoAnnotations
28 import org.mockito.internal.debugging.MockitoDebuggerImpl
29 import org.mockito.runners.MockitoJUnitRunner
30 import org.onap.so.bpmn.mock.FileUtil
32 import static org.mockito.Mockito.*
33 import static org.junit.Assert.*;
35 @RunWith(MockitoJUnitRunner.class)
36 public class VnfAdapterRestV1Test {
41 MockitoAnnotations.initMocks(this)
46 public void testPreProcessRequest() {
48 String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfadapter_request.xml");
49 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
50 when(mockExecution.getVariable("prefix")).thenReturn("VNFREST_")
51 when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
52 when(mockExecution.getVariable("VNFREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
53 when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
54 when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
56 when(mockExecution.getVariable("mso.adapters.vnf.rest.endpoint")).thenReturn("http://localhost:18080/vnfs/rest/v1/vnfs")
58 when(mockExecution.getVariable("mso.adapters.sdnc.timeout")).thenReturn("PT5M")
60 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
61 when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
64 VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1()
65 vnfAdapterRestV1.preProcessRequest(mockExecution)
67 MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
68 //debugger.printInvocations(mockExecution)
71 verify(mockExecution).setVariable("prefix","VNFREST_")
73 verify(mockExecution).setVariable("VNFREST_SuccessIndicator",false)
74 verify(mockExecution).setVariable("VNFREST_requestType","createVfModuleRequest")
75 verify(mockExecution).setVariable("VNFAResponse_CORRELATOR","8892cffa-3514-45d4-b2b0-0fde9a96e323-1511813289000")
76 verify(mockExecution).setVariable("VNFREST_vnfAdapterMethod","POST")
77 verify(mockExecution).setVariable("VNFREST_notificationUrl","http://localhost:18080/mso/WorkflowMessage/VNFAResponse/8892cffa-3514-45d4-b2b0-0fde9a96e323-1511813289000")
78 verify(mockExecution).setVariable("VNFREST_vnfAdapterUrl","http://localhost:18080/vnfs/rest/v1/vnfs/6d2e2469-8708-47c3-a0d4-73fa28a8a50b/vf-modules")
83 <rollbackVolumeGroupRequest>
85 <volumeGroupId>8a07b246-155e-4b08-b56e-76e98a3c2d66</volumeGroupId>
86 <volumeGroupStackId>phmaz401me6-vpevre-VOLUMEGROUP/dbd560b6-b03f-4a17-92e7-8942459a60c1</volumeGroupStackId>
87 <cloudSiteId>mtrnj1b</cloudSiteId>
88 <tenantId>cfb5e0a790374c9a98a1c0d2044206a7</tenantId>
89 <volumeGroupCreated>true</volumeGroupCreated>
91 <requestId>1e1a72ca-7300-4ac4-b718-30351f3b6845</requestId>
92 <serviceInstanceId>15eb2c68-f771-4030-b185-cff179fdad44</serviceInstanceId>
94 <messageId>683ca1ac-2145-4a00-9484-20d48bd701aa</messageId>
95 </volumeGroupRollback>
96 <skipAAI>true</skipAAI>
97 <notificationUrl>http://localhost:8080/mso/WorkflowMessage/VNFAResponse/683ca1ac-2145-4a00-9484-20d48bd701aa</notificationUrl>
98 </rollbackVolumeGroupRequest>
102 public void testGetVolumeGroupId() {
103 Node root = new XmlParser().parseText(rollbackReq)
104 VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1()
105 def volGrpId = vnfAdapterRestV1.getVolumeGroupIdFromRollbackRequest(root)
106 assertEquals('8a07b246-155e-4b08-b56e-76e98a3c2d66', volGrpId)
111 public void testGetMessageId() {
112 Node root = new XmlParser().parseText(rollbackReq)
114 VnfAdapterRestV1 p = new VnfAdapterRestV1()
115 def messageId = p.getMessageIdForVolumeGroupRollback(root)
116 assertEquals('683ca1ac-2145-4a00-9484-20d48bd701aa', messageId)