summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhaoxing <meng.zhaoxing1@zte.com.cn>2017-08-09 10:33:38 +0800
committerZhaoxing <meng.zhaoxing1@zte.com.cn>2017-08-09 10:33:38 +0800
commit4120fc2a4448afdff8474f725f9c1d57f51ebe8f (patch)
treefc1a95c973e46efa11ac64ea6b71bf525a726034
parentc0604184b2aa8cff924ca783ec6b36f1f5988775 (diff)
added test code
Change-Id: I238e18501bcf8abe61add65c0383a44b3c7a8cbc Signed-off-by: Zhaoxing <meng.zhaoxing1@zte.com.cn>
-rw-r--r--wfenginemgrservice/.gitignore37
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java4
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java6
-rw-r--r--wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowResourceTest.java87
4 files changed, 133 insertions, 1 deletions
diff --git a/wfenginemgrservice/.gitignore b/wfenginemgrservice/.gitignore
new file mode 100644
index 0000000..7e2df70
--- /dev/null
+++ b/wfenginemgrservice/.gitignore
@@ -0,0 +1,37 @@
+### JAVA
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+### MAVEN
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+
+# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
+!/.mvn/wrapper/maven-wrapper.jar \ No newline at end of file
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java b/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java
index 23f6ac6..d5fcb59 100644
--- a/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowApp.java
@@ -34,9 +34,11 @@ public class WorkflowApp extends Application<WorkflowAppConfig> {
@Override
public void run(WorkflowAppConfig configuration, Environment environment) throws Exception {
- // TODO Auto-generated method stub
+
environment.jersey().register(MultiPartFeature.class);
+ environment.jersey().packages("org.onap.workflow.resources");
+
Config.setWorkflowAppConfig(configuration);
}
}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java b/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java
index 71985cc..f874bad 100644
--- a/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/WorkflowAppConfig.java
@@ -40,4 +40,10 @@ public class WorkflowAppConfig extends Configuration {
public MsbClientConfig getMsbClientConfig() {
return msbClientConfig;
}
+
+ public void setMsbClientConfig(MsbClientConfig msbClientConfig) {
+ this.msbClientConfig = msbClientConfig;
+ }
+
+
}
diff --git a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowResourceTest.java b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowResourceTest.java
new file mode 100644
index 0000000..c3cb392
--- /dev/null
+++ b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowResourceTest.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.workflow.resources;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+import java.io.InputStream;
+
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.workflow.common.RestResponse;
+import org.onap.workflow.entity.StartProcessRequest;
+import org.onap.workflow.wrapper.WorkflowInstanceWrapper;
+import org.powermock.reflect.Whitebox;
+
+public class WorkflowResourceTest {
+
+ private WorkflowResource workflowResource;
+ private WorkflowInstanceWrapper workflowInstanceWrapper;
+
+ @Before
+ public void setUp() {
+
+ workflowInstanceWrapper = mock(WorkflowInstanceWrapper.class);
+ Whitebox.setInternalState(WorkflowInstanceWrapper.class, "wrapper", workflowInstanceWrapper);
+
+ workflowResource = new WorkflowResource();
+ }
+
+ @Test
+ public void testDeployBpmnFile() {
+
+ InputStream fileInputStream = mock(InputStream.class);
+ FormDataContentDisposition fileDetail = mock(FormDataContentDisposition.class);
+
+ Response result = Response.ok("success").build();
+
+ when(workflowInstanceWrapper.deployBpmnFile(Mockito.anyString(), Mockito.anyObject(), Mockito.anyObject())).thenReturn(result);
+
+ assertThat(workflowResource.deployBpmnFile(fileInputStream,fileDetail), is(result));
+ }
+
+ @Test
+ public void testUndeployBpmnFile(){
+
+ String deployId = "40";
+
+ RestResponse result = new RestResponse();
+
+ when(workflowInstanceWrapper.undeployBpmnFile(Mockito.anyString())).thenReturn(result);
+
+ assertThat(workflowResource.undeployBpmnFile(deployId), is(result));
+ }
+
+ @Test
+ public void testStartProcess(){
+
+ StartProcessRequest request = new StartProcessRequest();
+
+ Response result = Response.ok("success").build();
+
+ when(workflowInstanceWrapper.startProcess(Mockito.anyObject())).thenReturn(result);
+
+ assertThat(workflowResource.startProcess(request), is(result));
+ }
+}