summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/test
diff options
context:
space:
mode:
authorMarcin Migdal <marcin.migdal@nokia.com>2019-03-20 12:45:59 +0100
committerMarcin Migdal <marcin.migdal@nokia.com>2019-03-20 12:46:07 +0100
commitbccafdc99094a8ff9107f242b31f80e5a839b5c2 (patch)
treeab6b8fee5d46417f4f1e469da51f875d0aa6fe3d /prh-app-server/src/test
parent295746ec486e0300e7d5958ba44f8054c30389f4 (diff)
Fix Junits
Change-Id: I4ed75b52a8d6266a4e09da3382fc06f3ed4c0ae0 Issue-ID: DCAEGEN2-1078 Signed-off-by: Marcin Migdal <marcin.migdal@nokia.com>
Diffstat (limited to 'prh-app-server/src/test')
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java24
1 files changed, 15 insertions, 9 deletions
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
index 48e52bbd..9b34ef4c 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java
@@ -28,11 +28,11 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.onap.dcaegen2.services.prh.TestAppConfiguration.createDefaultDmaapConsumerConfiguration;
+import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.Optional;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
@@ -41,7 +41,6 @@ import org.onap.dcaegen2.services.prh.service.DmaapConsumerJsonParser;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consumer.ConsumerReactiveHttpClientFactory;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consumer.DMaaPConsumerReactiveHttpClient;
-
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -57,6 +56,9 @@ class DmaapConsumerTaskImplTest {
private static AppConfig appConfig;
private static DmaapConsumerConfiguration dmaapConsumerConfiguration;
private static String message;
+ private static String messageContentEmpty;
+ private static JsonArray jsonArray;
+ private static JsonArray jsonArrayWrongContent;
@BeforeAll
static void setUp() {
@@ -99,13 +101,18 @@ class DmaapConsumerTaskImplTest {
+ " \"oamV6IpAddress\": \"0:0:0:0:0:FFFF:0A10:7BEA\","
+ " \"additionalFields\": {\"attachmentPoint\": \"bla-bla-30-3\",\"cvlan\": \"678\",\"svlan\": \"1005\"}"
+ "}}}]";
+
+ messageContentEmpty = "[]";
+ JsonParser jsonParser = new JsonParser();
+ jsonArray = (JsonArray) jsonParser.parse(message);
+ jsonArrayWrongContent = (JsonArray) jsonParser.parse(messageContentEmpty);
+
}
- @Disabled
@Test
void whenPassedObjectDoesNotFit_DoesNotThrowPrhTaskException() throws Exception {
//given
- prepareMocksForDmaapConsumer(Optional.empty());
+ prepareMocksForDmaapConsumer(Optional.of(jsonArrayWrongContent));
//when
Flux<ConsumerDmaapModel> response = dmaapConsumerTask.execute("Sample input");
@@ -115,11 +122,10 @@ class DmaapConsumerTaskImplTest {
assertNull(response.blockFirst());
}
- @Disabled
@Test
void whenPassedObjectFits_ReturnsCorrectResponse() throws Exception {
//given
- prepareMocksForDmaapConsumer(Optional.of(message));
+ prepareMocksForDmaapConsumer(Optional.of(jsonArray));
//when
Flux<ConsumerDmaapModel> response = dmaapConsumerTask.execute("Sample input");
@@ -129,7 +135,6 @@ class DmaapConsumerTaskImplTest {
assertEquals(consumerDmaapModel, response.blockFirst());
}
- @Disabled
@Test
void whenInitConfigs_initStreamReader() {
//when
@@ -139,9 +144,10 @@ class DmaapConsumerTaskImplTest {
verify(appConfig).initFileStreamReader();
}
- private void prepareMocksForDmaapConsumer(Optional<String> message) throws Exception {
+ private void prepareMocksForDmaapConsumer(Optional<JsonArray> message) throws Exception {
dMaaPConsumerReactiveHttpClient = mock(DMaaPConsumerReactiveHttpClient.class);
- //when(dMaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse(Optional.empty())).thenReturn(Mono.just(message.orElse("")));
+ when(dMaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse(Optional.empty()))
+ .thenReturn(Mono.just(message.get()));
when(appConfig.getDmaapConsumerConfiguration()).thenReturn(dmaapConsumerConfiguration);
ConsumerReactiveHttpClientFactory httpClientFactory = mock(ConsumerReactiveHttpClientFactory.class);
doReturn(dMaaPConsumerReactiveHttpClient).when(httpClientFactory).create(dmaapConsumerConfiguration);