summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-02-13 10:38:09 +0100
committerWojciech Sliwka <wojciech.sliwka@nokia.com>2019-02-21 15:27:45 +0100
commitc79087597e1861d12b691d1db4011641a78ab3c1 (patch)
tree18ddd459a96d2c92dfd52735c4253231d8013ffd /vid-app-common/src/test/java/org
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
workflow parameters API
Change-Id: If79e410608a0562ddef86d9a3a451d4addf66a0f Issue-ID: VID-419 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@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.java44
1 files changed, 41 insertions, 3 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
index 1509637bb..4d0d983e9 100644
--- 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
@@ -1,15 +1,20 @@
package org.onap.vid.services;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+
+import com.google.common.collect.Lists;
import io.joshworks.restclient.http.HttpResponse;
import java.util.Collections;
import java.util.List;
+
+import org.assertj.core.api.Assertions;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.vid.model.SOWorkflow;
+import org.onap.vid.model.SOWorkflowParameterDefinition;
+import org.onap.vid.model.SOWorkflowParameterDefinitions;
+import org.onap.vid.model.SOWorkflowType;
import org.onap.vid.model.SOWorkflows;
import org.onap.vid.mso.MsoResponseWrapper2;
import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
@@ -17,6 +22,8 @@ import org.onap.vid.services.ExtWorkflowsServiceImpl.BadResponseFromMso;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+
+
public class ExtWorkflowServiceImplTest {
@Mock
@@ -24,6 +31,10 @@ public class ExtWorkflowServiceImplTest {
@Mock
private HttpResponse<SOWorkflows> response;
+ @Mock
+ private HttpResponse<SOWorkflowParameterDefinitions> parameterDefinitionsHttpResponse;
+
+
@BeforeMethod
public void init(){
MockitoAnnotations.initMocks(this);
@@ -41,7 +52,7 @@ public class ExtWorkflowServiceImplTest {
List<SOWorkflow> workflows = extWorkflowsService.getWorkflows("test");
// then
Mockito.verify(client).getWorkflows("test");
- assertThat(workflows.get(0).getName(), is("xyz"));
+ Assertions.assertThat(workflows.get(0).getName()).isEqualTo("xyz");
}
@Test(expectedExceptions = BadResponseFromMso.class)
@@ -56,5 +67,32 @@ public class ExtWorkflowServiceImplTest {
extWorkflowsService.getWorkflows("test");
// then throw exception
}
+ @Test
+ public void shouldReturnWorkflowParametersOnValidResponse() {
+ SOWorkflowParameterDefinitions parameters = new SOWorkflowParameterDefinitions(Collections.singletonList(new SOWorkflowParameterDefinition(1L, "sample", "[0-9]", SOWorkflowType.STRING, true)));
+ ExtWorkflowsService extWorkflowsService = new ExtWorkflowsServiceImpl(client);
+ Mockito.when(parameterDefinitionsHttpResponse.getStatus()).thenReturn(200);
+ Mockito.when(parameterDefinitionsHttpResponse.getBody()).thenReturn(parameters);
+ MsoResponseWrapper2<SOWorkflowParameterDefinitions> msoResponseWrapper = new MsoResponseWrapper2<>(parameterDefinitionsHttpResponse);
+ Mockito.when(client.getWorkflowParameterDefinitions(1L)).thenReturn(msoResponseWrapper);
+
+ SOWorkflowParameterDefinitions workflowParameterDefinitions = extWorkflowsService.getWorkflowParameterDefinitions(1L);
+
+ Assertions.assertThat(workflowParameterDefinitions).isEqualTo(parameters);
+ }
+
+ @Test
+ public void shouldProperlyHandleEmptyParametersList(){
+ ExtWorkflowsService extWorkflowsService = new ExtWorkflowsServiceImpl(client);
+ Mockito.when(parameterDefinitionsHttpResponse.getStatus()).thenReturn(200);
+ Mockito.when(parameterDefinitionsHttpResponse.getBody()).thenReturn(new SOWorkflowParameterDefinitions(Lists.newArrayList()));
+
+ MsoResponseWrapper2<SOWorkflowParameterDefinitions> msoResponseWrapper = new MsoResponseWrapper2<>(parameterDefinitionsHttpResponse);
+ Mockito.when(client.getWorkflowParameterDefinitions(1L)).thenReturn(msoResponseWrapper);
+
+
+ SOWorkflowParameterDefinitions workflowParameterDefinitions = extWorkflowsService.getWorkflowParameterDefinitions(1L);
+ Assertions.assertThat(workflowParameterDefinitions.getParameterDefinitions()).isEmpty();
+ }
}