Add unit test for vfc-nfvo-wfengine
[vfc/nfvo/wfengine.git] / wfenginemgrservice / src / test / java / org / onap / workflow / resources / WorkflowInstanceWrapperTest.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.onap.workflow.resources;
18
19 import static org.powermock.api.mockito.PowerMockito.mock;
20
21 import java.io.InputStream;
22
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;
39
40 @PrepareForTest({ActivitiServiceConsumer.class})
41 @RunWith(PowerMockRunner.class)
42 public class WorkflowInstanceWrapperTest {
43
44   private WorkflowInstanceWrapper workflowInstanceWrapper;
45
46   @BeforeClass
47   public static void setUpBeforeClass() throws Exception {}
48
49   @AfterClass
50   public static void tearDownAfterClass() throws Exception {}
51
52   @Before
53   public void setUp() throws Exception {
54     workflowInstanceWrapper = new WorkflowInstanceWrapper();
55     PowerMockito.mockStatic(ActivitiServiceConsumer.class);// 3
56   }
57
58   @After
59   public void tearDown() throws Exception {}
60
61   @Test
62   public final void testGetInstance() {
63     // fail("Not yet implemented"); // TODO
64   }
65
66   @Test
67   public final void testDeployBpmnFile() throws Exception {
68     
69     InputStream fileInputStream = mock(InputStream.class);
70     FormDataContentDisposition f = mock(FormDataContentDisposition.class);
71     String filename = "test";
72     ActivitiDeployResponse reponse = new ActivitiDeployResponse();
73     reponse.setId("123");
74     reponse.setUrl("http://url");
75     PowerMockito.mockStatic(ActivitiServiceConsumer.class);
76     PowerMockito.when(ActivitiServiceConsumer.deploybpmnfile(fileInputStream, filename))
77         .thenReturn(reponse);
78     workflowInstanceWrapper.deployBpmnFile(filename, fileInputStream, f);
79     // assertThat(, is(result));
80   }
81
82   @Test
83   public final void testUndeployBpmnFile() {
84
85   }
86
87   @Test
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))
97         .thenReturn(reponse);
98     workflowInstanceWrapper.startProcess(tt);
99   }
100
101 }