Fix the docker build error for vfc-nfvo-wfengine
[vfc/nfvo/wfengine.git] / wfenginemgrservice / src / test / java / org / onap / workflow / resources / WorkflowInstanceWrapperTest.java
1 /**\r
2  * Copyright 2017 ZTE Corporation.\r
3  *\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  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\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.resources;\r
17 \r
18 import static org.powermock.api.mockito.PowerMockito.mock;\r
19 \r
20 import java.io.InputStream;\r
21 \r
22 import javax.ws.rs.core.Response;\r
23 \r
24 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;\r
25 import org.junit.Assert;\r
26 import org.junit.Before;\r
27 import org.junit.Test;\r
28 import org.onap.workflow.common.RestClient;\r
29 import org.onap.workflow.common.RestResponse;\r
30 import org.onap.workflow.entity.StartProcessRequest;\r
31 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;\r
32 import org.onap.workflow.wrapper.WorkflowInstanceWrapper;\r
33 \r
34 public class WorkflowInstanceWrapperTest {\r
35 \r
36   private WorkflowInstanceWrapper workflowInstanceWrapper;\r
37 \r
38   @Before\r
39   public void setUp() throws Exception {\r
40     workflowInstanceWrapper = new WorkflowInstanceWrapper();\r
41   }\r
42 \r
43   @Test\r
44   public final void testDeployBpmnFile() throws Exception {\r
45     RestClient.isTest = true;\r
46     InputStream fileInputStream = mock(InputStream.class);\r
47     FormDataContentDisposition f = mock(FormDataContentDisposition.class);\r
48     String filename = "test";\r
49     Response reponse = workflowInstanceWrapper.deployBpmnFile(filename, fileInputStream, f);\r
50     Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), reponse.getStatus());\r
51     RestClient.isTest = false;\r
52   }\r
53 \r
54   @Test\r
55   public final void testUndeployBpmnFile() throws Exception {\r
56     RestClient.isTest = true;\r
57     RestResponse response = WorkflowInstanceWrapper.getInstance().undeployBpmnFile(null);\r
58     if (response != null) {\r
59       Assert.assertTrue(response.getResult() == null);\r
60     }\r
61     RestClient.isTest = false;\r
62   }\r
63 \r
64   @Test\r
65   public final void testStartProcess() throws Exception {\r
66     RestClient.isTest = true;\r
67     ActivitiStartProcessRequest startProcessRequest = new ActivitiStartProcessRequest();\r
68     startProcessRequest.setProcessDefinitionKey("first");\r
69     StartProcessRequest tt = new StartProcessRequest();\r
70     tt.setProcessDefinitionKey("first");\r
71     Response reponse = workflowInstanceWrapper.startProcess(tt);\r
72     Assert.assertEquals(Response.Status.OK.getStatusCode(), reponse.getStatus());\r
73     RestClient.isTest = false;\r
74   }\r
75 \r
76 }\r