f8ecf0157917031bd6b8838e00099e67548c065c
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.bpmn.infrastructure.manualhandling.tasks;
22
23 import static org.mockito.Mockito.spy;
24 import static org.mockito.Mockito.times;
25 import static org.mockito.Mockito.verify;
26 import static org.mockito.Mockito.when;
27 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.mockito.Mock;
31 import org.onap.so.bpmn.BaseTaskTest;
32 import org.onap.so.bpmn.common.BuildingBlockExecution;
33 import org.onap.so.bpmn.common.DelegateExecutionImpl;
34 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
35 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
36 import org.onap.so.client.ticket.ExternalTicket;
37
38 public class ExternalTicketTasksTest extends BaseTaskTest {
39
40     @Mock
41     private BuildingBlockExecution buildingBlockExecution;
42
43     @Mock
44     private GeneralBuildingBlock generalBuildingBlock;
45
46     @Mock
47     private RequestContext requestContext;
48
49     @Mock
50     private ExternalTicket MOCK_externalTicket;
51
52     @Before
53     public void before() throws Exception {
54         delegateExecution = new DelegateExecutionFake();
55         buildingBlockExecution = new DelegateExecutionImpl(delegateExecution);
56         generalBuildingBlock = new GeneralBuildingBlock();
57         requestContext = new RequestContext();
58         requestContext.setRequestorId("someRequestorId");
59         generalBuildingBlock.setRequestContext(requestContext);
60         buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId"));
61         buildingBlockExecution.setVariable("vnfType", "testVnfType");
62         buildingBlockExecution.setVariable("gBBInput", generalBuildingBlock);
63         buildingBlockExecution.setVariable("rainyDayVnfName", "someVnfName");
64         buildingBlockExecution.setVariable("workStep", "someWorkstep");
65         buildingBlockExecution.setVariable("taskTimeout", "PT5M");
66     }
67
68     @Test
69     public void createExternalTicket_Test() throws Exception {
70         ExternalTicketTasks externalTicketTasksSpy = spy(new ExternalTicketTasks());
71         when(externalTicketTasksSpy.getExternalTicket()).thenReturn(MOCK_externalTicket);
72         externalTicketTasksSpy.createExternalTicket(buildingBlockExecution);
73         verify(MOCK_externalTicket, times(1)).createTicket();
74     }
75 }