diff options
Diffstat (limited to 'wfenginemgrservice/src/test/java/org')
3 files changed, 17 insertions, 1 deletions
diff --git a/wfenginemgrservice/src/test/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumerTest.java b/wfenginemgrservice/src/test/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumerTest.java index e644626..af90c41 100644 --- a/wfenginemgrservice/src/test/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumerTest.java +++ b/wfenginemgrservice/src/test/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumerTest.java @@ -16,13 +16,16 @@ package org.onap.workflow.externalservice.service.activitiservice;
import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.client.ClientProtocolException;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.workflow.WorkflowAppConfig;
import org.onap.workflow.common.Config;
import org.onap.workflow.common.RestClient;
@@ -95,6 +98,8 @@ public class ActivitiServiceConsumerTest { workflowAppConfig.setMsbClientConfig(msbClientConfig);
Config.setWorkflowAppConfig(workflowAppConfig);
InputStream ins = mock(InputStream.class);
+ // Byte b[]=(Byte) mock(Byte.class);
+ when(ins.read(Mockito.anyObject())).thenReturn(-21);
ActivitiDeployResponse result = ActivitiServiceConsumer.deploybpmnfile(ins, "result");
Assert.assertTrue(result == null);
RestClient.isTest = false;
diff --git a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowInstanceWrapperTest.java b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowInstanceWrapperTest.java index ea84226..487051f 100644 --- a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowInstanceWrapperTest.java +++ b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowInstanceWrapperTest.java @@ -16,6 +16,7 @@ package org.onap.workflow.resources;
import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
import java.io.InputStream;
@@ -25,6 +26,7 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.workflow.common.RestClient;
import org.onap.workflow.common.RestResponse;
import org.onap.workflow.entity.StartProcessRequest;
@@ -46,6 +48,7 @@ public class WorkflowInstanceWrapperTest { InputStream fileInputStream = mock(InputStream.class);
FormDataContentDisposition f = mock(FormDataContentDisposition.class);
String filename = "test";
+ when(fileInputStream.read(Mockito.anyObject())).thenReturn(-21);
Response reponse = workflowInstanceWrapper.deployBpmnFile(filename, fileInputStream, f);
Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), reponse.getStatus());
RestClient.isTest = false;
diff --git a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowResourceTest.java b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowResourceTest.java index e7d6523..7d8b194 100644 --- a/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowResourceTest.java +++ b/wfenginemgrservice/src/test/java/org/onap/workflow/resources/WorkflowResourceTest.java @@ -21,6 +21,7 @@ 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.IOException;
import java.io.InputStream;
import javax.ws.rs.core.Response;
@@ -55,7 +56,14 @@ public class WorkflowResourceTest { FormDataContentDisposition fileDetail = mock(FormDataContentDisposition.class);
Response result = Response.ok("success").build();
-
+ // when(fileInputStream.read()).thenReturn(-1);
+ try {
+ when(fileInputStream.read(Mockito.anyObject())).thenReturn(-21);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
when(workflowInstanceWrapper.deployBpmnFile(Mockito.anyString(), Mockito.anyObject(), Mockito.anyObject())).thenReturn(result);
assertThat(workflowResource.deployBpmnFile(fileInputStream,fileDetail), is(result));
|