Fix the docker build error for vfc-nfvo-wfengine
[vfc/nfvo/wfengine.git] / wfenginemgrservice / src / test / java / org / onap / workflow / externalservice / service / activitiservice / ActivitiServiceConsumerTest.java
1 /**\r
2  * Copyright 2017 ZTE Corporation.\r
3  * <p>\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
7  * <p>\r
8  * http://www.apache.org/licenses/LICENSE-2.0\r
9  * <p>\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
15  */\r
16 package org.onap.workflow.externalservice.service.activitiservice;\r
17 \r
18 import static org.mockito.Mockito.mock;\r
19 \r
20 import java.io.IOException;\r
21 import java.io.InputStream;\r
22 \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
33 \r
34 public class ActivitiServiceConsumerTest {\r
35   @Test\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
41   }\r
42 \r
43   @Test\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
50   }\r
51 \r
52   @Test\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
58   }\r
59 \r
60   @Test\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
66     } else {\r
67       Assert.assertTrue(response == null);\r
68     }\r
69   }\r
70 \r
71   @Test\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
78   }\r
79 \r
80   @Test\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
86   }\r
87 \r
88   @Test\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
101   }\r
102 \r
103 }