2 * ============LICENSE_START=======================================================
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
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.client.cds;
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;
30 import java.util.UUID;
32 import org.camunda.bpm.engine.delegate.DelegateExecution;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.InjectMocks;
37 import org.mockito.Mock;
38 import org.mockito.junit.MockitoJUnitRunner;
39 import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
40 import org.onap.so.client.exception.ExceptionBuilder;
42 @RunWith(MockitoJUnitRunner.class)
43 public class AbstractCDSProcessingBBUtilsTest {
45 private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils = new AbstractCDSProcessingBBUtils();
47 AbstractCDSPropertiesBean abstractCDSPropertiesBean = new AbstractCDSPropertiesBean();
49 ExceptionBuilder exceptionUtil;
53 String requestObject = "{\"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\"}}}";
54 String blueprintName = "blueprintName";
55 String blueprintVersion = "blueprintVersion";
56 String actionName = "actionName";
58 String requestId = "123456";
59 String originatorId = "originatorId";
60 String subRequestId = UUID.randomUUID().toString();
62 abstractCDSPropertiesBean.setActionName(actionName);
63 abstractCDSPropertiesBean.setBlueprintName(blueprintName);
64 abstractCDSPropertiesBean.setBlueprintVersion(blueprintVersion);
65 abstractCDSPropertiesBean.setMode(mode);
66 abstractCDSPropertiesBean.setOriginatorId(originatorId);
67 abstractCDSPropertiesBean.setRequestId(requestId);
68 abstractCDSPropertiesBean.setRequestObject(requestObject);
69 abstractCDSPropertiesBean.setSubRequestId(subRequestId);
73 public void preProcessRequestTest() throws Exception {
75 DelegateExecution execution = mock(DelegateExecution.class);
76 when(execution.getVariable("executionObject")).thenReturn(abstractCDSPropertiesBean);
78 abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution);
79 verify(exceptionUtil, times(0))
80 .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(Exception.class));
84 public void sendRequestToCDSClientTest() {
86 DelegateExecution execution = mock(DelegateExecution.class);
87 when(execution.getVariable("executionServiceInput")).thenReturn(abstractCDSPropertiesBean);
88 abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution);
89 verify(exceptionUtil, times(1))
90 .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(Exception.class));