2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.workflow.resources;
18 import static org.powermock.api.mockito.PowerMockito.mock;
20 import java.io.InputStream;
22 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
23 import org.junit.After;
24 import org.junit.AfterClass;
25 import org.junit.Before;
26 import org.junit.BeforeClass;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.onap.workflow.common.RestResponse;
30 import org.onap.workflow.entity.StartProcessRequest;
31 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiDeployResponse;
32 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
33 import org.onap.workflow.externalservice.service.activitiservice.ActivitiServiceConsumer;
34 import org.onap.workflow.wrapper.WorkflowInstanceWrapper;
35 import org.powermock.api.mockito.PowerMockito;
36 import org.powermock.core.classloader.annotations.PrepareForTest;
37 import org.powermock.modules.junit4.PowerMockRunner;
39 @PrepareForTest({ActivitiServiceConsumer.class})
40 @RunWith(PowerMockRunner.class)
41 public class WorkflowInstanceWrapperTest {
43 private WorkflowInstanceWrapper workflowInstanceWrapper;
46 public static void setUpBeforeClass() throws Exception {}
49 public static void tearDownAfterClass() throws Exception {}
52 public void setUp() throws Exception {
53 workflowInstanceWrapper = new WorkflowInstanceWrapper();
54 PowerMockito.mockStatic(ActivitiServiceConsumer.class);// 3
58 public void tearDown() throws Exception {}
61 public final void testDeployBpmnFile() throws Exception {
63 InputStream fileInputStream = mock(InputStream.class);
64 FormDataContentDisposition f = mock(FormDataContentDisposition.class);
65 String filename = "test";
66 ActivitiDeployResponse reponse = new ActivitiDeployResponse();
68 reponse.setUrl("http://url");
69 PowerMockito.mockStatic(ActivitiServiceConsumer.class);
70 PowerMockito.when(ActivitiServiceConsumer.deploybpmnfile(fileInputStream, filename))
72 workflowInstanceWrapper.deployBpmnFile(filename, fileInputStream, f);
73 // assertThat(, is(result));
77 public final void testUndeployBpmnFile() throws Exception {
78 WorkflowInstanceWrapper.getInstance().undeployBpmnFile(null);
82 public final void testStartProcess() throws Exception {
83 ActivitiStartProcessRequest startProcessRequest = new ActivitiStartProcessRequest();
84 startProcessRequest.setProcessDefinitionKey("first");
85 StartProcessRequest tt = new StartProcessRequest();
86 tt.setProcessDefinitionKey("first");
87 RestResponse reponse = new RestResponse();
88 reponse.setResult("123");
89 PowerMockito.mockStatic(ActivitiServiceConsumer.class);
90 PowerMockito.when(ActivitiServiceConsumer.startBpmnProcess(startProcessRequest))
92 workflowInstanceWrapper.startProcess(tt);