2 * Copyright 2017 ZTE Corporation.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 package org.onap.workflow.externalservice.service.activitiservice;
\r
18 import static org.mockito.Mockito.mock;
\r
20 import java.io.IOException;
\r
21 import java.io.InputStream;
\r
23 import org.apache.http.client.ClientProtocolException;
\r
24 import org.junit.Assert;
\r
25 import org.junit.Test;
\r
26 import org.onap.workflow.WorkflowAppConfig;
\r
27 import org.onap.workflow.common.Config;
\r
28 import org.onap.workflow.common.RestClient;
\r
29 import org.onap.workflow.common.RestResponse;
\r
30 import org.onap.workflow.entity.MsbClientConfig;
\r
31 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiDeployResponse;
\r
32 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
\r
34 public class ActivitiServiceConsumerTest {
\r
36 public void undeploybpmnfile() throws ClientProtocolException, IOException {
\r
37 RestClient.isTest = true;
\r
38 RestResponse response = ActivitiServiceConsumer.undeploybpmnfile("22");
\r
39 Assert.assertTrue(response != null);
\r
40 RestClient.isTest = false;
\r
44 public void startBpmnProcess() throws Exception {
\r
45 RestClient.isTest = true;
\r
46 RestResponse response =
\r
47 ActivitiServiceConsumer.startBpmnProcess(mock(ActivitiStartProcessRequest.class));
\r
48 Assert.assertTrue(response != null);
\r
49 RestClient.isTest = false;
\r
53 public void testDeleteDeployProcess() throws Exception {
\r
54 RestClient.isTest = true;
\r
55 RestResponse response = ActivitiServiceConsumer.deleteDeployProcess("22");
\r
56 Assert.assertTrue(response != null);
\r
57 RestClient.isTest = false;
\r
61 public void testDeleteDeployProcessReturnNull() throws Exception {
\r
62 RestClient.isTest = false;
\r
63 RestResponse response = ActivitiServiceConsumer.deleteDeployProcess("22");
\r
64 if (response != null) {
\r
65 Assert.assertTrue(response.getResult() == null);
\r
67 Assert.assertTrue(response == null);
\r
72 public void testStartProcessShouldReturnResponse() throws Exception {
\r
73 RestClient.isTest = true;
\r
74 RestResponse response =
\r
75 ActivitiServiceConsumer.startProcess(mock(ActivitiStartProcessRequest.class));
\r
76 Assert.assertTrue(response != null);
\r
77 RestClient.isTest = false;
\r
81 public void testStartProcessShouldReturnNull() {
\r
82 RestClient.isTest = false;
\r
83 RestResponse response =
\r
84 ActivitiServiceConsumer.startProcess(mock(ActivitiStartProcessRequest.class));
\r
85 Assert.assertTrue(response.getResult() == null);
\r
89 public void deploybpmnfile() throws Exception {
\r
90 RestClient.isTest = true;
\r
91 WorkflowAppConfig workflowAppConfig = new WorkflowAppConfig();
\r
92 MsbClientConfig msbClientConfig = new MsbClientConfig();
\r
93 msbClientConfig.setMsbSvrPort(2);
\r
94 msbClientConfig.setMsbSvrIp("127.0.0.1");
\r
95 workflowAppConfig.setMsbClientConfig(msbClientConfig);
\r
96 Config.setWorkflowAppConfig(workflowAppConfig);
\r
97 InputStream ins = mock(InputStream.class);
\r
98 ActivitiDeployResponse result = ActivitiServiceConsumer.deploybpmnfile(ins, "result");
\r
99 Assert.assertTrue(result == null);
\r
100 RestClient.isTest = false;
\r