Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / client / cds / AbstractCDSProcessingBBUtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2019 TechMahindra.
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.client.cds;
22
23 import static org.mockito.ArgumentMatchers.any;
24 import static org.mockito.ArgumentMatchers.anyInt;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.times;
27 import static org.mockito.Mockito.verify;
28 import static org.mockito.Mockito.when;
29 import java.util.UUID;
30 import org.camunda.bpm.engine.delegate.DelegateExecution;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.InjectMocks;
35 import org.mockito.Mock;
36 import org.mockito.junit.MockitoJUnitRunner;
37 import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
38 import org.onap.so.client.exception.ExceptionBuilder;
39
40 @RunWith(MockitoJUnitRunner.class)
41 public class AbstractCDSProcessingBBUtilsTest {
42     @InjectMocks
43     private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils = new AbstractCDSProcessingBBUtils();
44     @InjectMocks
45     AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
46     @Mock
47     ExceptionBuilder exceptionUtil;
48
49     @Before
50     public void init() {
51         String requestObject =
52                 "{\"config-assign-request\":{\"resolution-key\":\"resolutionKey\", \"config-assign-properties\":{\"service-instance-id\":\"serviceInstanceId\", \"vnf-id\":\"vnfId\", \"vnf-name\":\"vnfName\", \"service-model-uuid\":\"serviceModelUuid\", \"vnf-customization-uuid\":\"vnfCustomizationUuid\",\"Instance1\":\"Instance1Value\",\"Instance2\":\"Instance2Value\",\"Param3\":\"Param3Value\"}}}";
53         String blueprintName = "blueprintName";
54         String blueprintVersion = "blueprintVersion";
55         String actionName = "actionName";
56         String mode = "mode";
57         String requestId = "123456";
58         String originatorId = "originatorId";
59         String subRequestId = UUID.randomUUID().toString();
60
61         abstractCDSPropertiesBean.setActionName(actionName);
62         abstractCDSPropertiesBean.setBlueprintName(blueprintName);
63         abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
64         abstractCDSPropertiesBean.setMode(mode);
65         abstractCDSPropertiesBean.setOriginatorId(originatorId);
66         abstractCDSPropertiesBean.setRequestId(requestId);
67         abstractCDSPropertiesBean.setRequestObject(requestObject);
68         abstractCDSPropertiesBean.setSubRequestId(subRequestId);
69     }
70
71     @Test
72     public void preProcessRequestTest() throws Exception {
73
74         DelegateExecution execution = mock(DelegateExecution.class);
75         when(execution.getVariable("executionObject")).thenReturn(abstractCDSPropertiesBean);
76
77         abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution);
78         verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(),
79                 any(Exception.class));
80     }
81
82     @Test
83     public void sendRequestToCDSClientTest() {
84
85         DelegateExecution execution = mock(DelegateExecution.class);
86         when(execution.getVariable("executionServiceInput")).thenReturn(abstractCDSPropertiesBean);
87         abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution);
88         verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(),
89                 any(Exception.class));
90
91     }
92
93 }