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.resources;
\r
18 import static org.powermock.api.mockito.PowerMockito.mock;
\r
19 import static org.powermock.api.mockito.PowerMockito.when;
\r
21 import java.io.InputStream;
\r
23 import javax.ws.rs.core.Response;
\r
25 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
\r
26 import org.junit.Assert;
\r
27 import org.junit.Before;
\r
28 import org.junit.Test;
\r
29 import org.mockito.Mockito;
\r
30 import org.onap.workflow.common.RestClient;
\r
31 import org.onap.workflow.common.RestResponse;
\r
32 import org.onap.workflow.entity.StartProcessRequest;
\r
33 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
\r
34 import org.onap.workflow.wrapper.WorkflowInstanceWrapper;
\r
36 public class WorkflowInstanceWrapperTest {
\r
38 private WorkflowInstanceWrapper workflowInstanceWrapper;
\r
41 public void setUp() throws Exception {
\r
42 workflowInstanceWrapper = new WorkflowInstanceWrapper();
\r
46 public final void testDeployBpmnFile() throws Exception {
\r
47 RestClient.isTest = true;
\r
48 InputStream fileInputStream = mock(InputStream.class);
\r
49 FormDataContentDisposition f = mock(FormDataContentDisposition.class);
\r
50 String filename = "test";
\r
51 when(fileInputStream.read(Mockito.anyObject())).thenReturn(-21);
\r
52 Response reponse = workflowInstanceWrapper.deployBpmnFile(filename, fileInputStream, f);
\r
53 Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), reponse.getStatus());
\r
54 RestClient.isTest = false;
\r
58 public final void testUndeployBpmnFile() throws Exception {
\r
59 RestClient.isTest = true;
\r
60 RestResponse response = WorkflowInstanceWrapper.getInstance().undeployBpmnFile(null);
\r
61 if (response != null) {
\r
62 Assert.assertTrue(response.getResult() == null);
\r
64 RestClient.isTest = false;
\r
68 public final void testStartProcess() throws Exception {
\r
69 RestClient.isTest = true;
\r
70 ActivitiStartProcessRequest startProcessRequest = new ActivitiStartProcessRequest();
\r
71 startProcessRequest.setProcessDefinitionKey("first");
\r
72 StartProcessRequest tt = new StartProcessRequest();
\r
73 tt.setProcessDefinitionKey("first");
\r
74 Response reponse = workflowInstanceWrapper.startProcess(tt);
\r
75 Assert.assertEquals(Response.Status.OK.getStatusCode(), reponse.getStatus());
\r
76 RestClient.isTest = false;
\r