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.
17 package org.onap.workflow.resources;
19 import static org.powermock.api.mockito.PowerMockito.mock;
21 import java.io.InputStream;
23 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
24 import org.junit.After;
25 import org.junit.AfterClass;
26 import org.junit.Before;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.onap.workflow.common.RestResponse;
31 import org.onap.workflow.entity.StartProcessRequest;
32 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiDeployResponse;
33 import org.onap.workflow.externalservice.entity.activitientitiy.ActivitiStartProcessRequest;
34 import org.onap.workflow.externalservice.service.activitiservice.ActivitiServiceConsumer;
35 import org.onap.workflow.wrapper.WorkflowInstanceWrapper;
36 import org.powermock.api.mockito.PowerMockito;
37 import org.powermock.core.classloader.annotations.PrepareForTest;
38 import org.powermock.modules.junit4.PowerMockRunner;
40 @PrepareForTest({ActivitiServiceConsumer.class})
41 @RunWith(PowerMockRunner.class)
42 public class WorkflowInstanceWrapperTest {
44 private WorkflowInstanceWrapper workflowInstanceWrapper;
47 public static void setUpBeforeClass() throws Exception {}
50 public static void tearDownAfterClass() throws Exception {}
53 public void setUp() throws Exception {
54 workflowInstanceWrapper = new WorkflowInstanceWrapper();
55 PowerMockito.mockStatic(ActivitiServiceConsumer.class);// 3
59 public void tearDown() throws Exception {}
62 public final void testGetInstance() {
63 // fail("Not yet implemented"); // TODO
67 public final void testDeployBpmnFile() throws Exception {
69 InputStream fileInputStream = mock(InputStream.class);
70 FormDataContentDisposition f = mock(FormDataContentDisposition.class);
71 String filename = "test";
72 ActivitiDeployResponse reponse = new ActivitiDeployResponse();
74 reponse.setUrl("http://url");
75 PowerMockito.mockStatic(ActivitiServiceConsumer.class);
76 PowerMockito.when(ActivitiServiceConsumer.deploybpmnfile(fileInputStream, filename))
78 workflowInstanceWrapper.deployBpmnFile(filename, fileInputStream, f);
79 // assertThat(, is(result));
83 public final void testUndeployBpmnFile() {
88 public final void testStartProcess() throws Exception {
89 ActivitiStartProcessRequest startProcessRequest = new ActivitiStartProcessRequest();
90 startProcessRequest.setProcessDefinitionKey("first");
91 StartProcessRequest tt = new StartProcessRequest();
92 tt.setProcessDefinitionKey("first");
93 RestResponse reponse = new RestResponse();
94 reponse.setResult("123");
95 PowerMockito.mockStatic(ActivitiServiceConsumer.class);
96 PowerMockito.when(ActivitiServiceConsumer.startBpmnProcess(startProcessRequest))
98 workflowInstanceWrapper.startProcess(tt);