summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org
diff options
context:
space:
mode:
authorgolabek <tomasz.golabek@nokia.com>2019-02-11 16:36:49 +0100
committergolabek <tomasz.golabek@nokia.com>2019-02-18 13:49:42 +0100
commite3f8c6d9b3ff4b9c9b82c795a791ea9b5a014c98 (patch)
tree24c174cedd41a9c9d5c5e7b780fbde6aa9e47f5e /vid-app-common/src/test/java/org
parent4b8ae0089f38ab06ba319ef439fffb59008e08e5 (diff)
Introduced mocked SO workflows in VID FE
Mocked SO workflows joined with list of workflows from VIDs DB. (Contains: Mocked BE service to return workflow list) Change-Id: I10336238cfeb8819e0a2b3e88cd86c338cab86fa Issue-ID: VID-399 Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'vid-app-common/src/test/java/org')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ExtWorkflowServiceImplTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ExtWorkflowServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ExtWorkflowServiceImplTest.java
new file mode 100644
index 000000000..1509637bb
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/services/ExtWorkflowServiceImplTest.java
@@ -0,0 +1,60 @@
+package org.onap.vid.services;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import io.joshworks.restclient.http.HttpResponse;
+import java.util.Collections;
+import java.util.List;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vid.model.SOWorkflow;
+import org.onap.vid.model.SOWorkflows;
+import org.onap.vid.mso.MsoResponseWrapper2;
+import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
+import org.onap.vid.services.ExtWorkflowsServiceImpl.BadResponseFromMso;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class ExtWorkflowServiceImplTest {
+
+ @Mock
+ private MockedWorkflowsRestClient client;
+ @Mock
+ private HttpResponse<SOWorkflows> response;
+
+ @BeforeMethod
+ public void init(){
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void shouldReturnWorkflowsOnValidResponse(){
+ // given
+ ExtWorkflowsService extWorkflowsService = new ExtWorkflowsServiceImpl(client);
+ Mockito.when(response.getStatus()).thenReturn(200);
+ Mockito.when(response.getBody()).thenReturn(new SOWorkflows(Collections.singletonList(new SOWorkflow(1L, "xyz"))));
+ MsoResponseWrapper2<SOWorkflows> msoResponseStub = new MsoResponseWrapper2<>(response);
+ Mockito.when(client.getWorkflows("test")).thenReturn(msoResponseStub);
+ // when
+ List<SOWorkflow> workflows = extWorkflowsService.getWorkflows("test");
+ // then
+ Mockito.verify(client).getWorkflows("test");
+ assertThat(workflows.get(0).getName(), is("xyz"));
+ }
+
+ @Test(expectedExceptions = BadResponseFromMso.class)
+ public void shouldThrowBadResponseOnInvalidResponse(){
+ // given
+ ExtWorkflowsService extWorkflowsService = new ExtWorkflowsServiceImpl(client);
+ Mockito.when(response.getStatus()).thenReturn(500);
+ Mockito.when(response.getBody()).thenReturn(new SOWorkflows(Collections.singletonList(new SOWorkflow(1L, "xyz"))));
+ MsoResponseWrapper2<SOWorkflows> msoResponseStub = new MsoResponseWrapper2<>(response);
+ Mockito.when(client.getWorkflows("test")).thenReturn(msoResponseStub);
+ // when
+ extWorkflowsService.getWorkflows("test");
+ // then throw exception
+ }
+
+}