aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server/src
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
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')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java9
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java3
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImplTest.java24
3 files changed, 18 insertions, 18 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
index 69246090..3318d331 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
@@ -21,7 +21,6 @@
package org.onap.dcaegen2.services.prh.tasks;
import com.google.gson.JsonArray;
-import java.util.Objects;
import java.util.Optional;
import javax.net.ssl.SSLException;
import org.onap.dcaegen2.services.prh.configuration.Config;
@@ -30,7 +29,6 @@ import org.onap.dcaegen2.services.prh.service.DmaapConsumerJsonParser;
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 org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consumer.DMaaPReactiveWebClientFactory;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -53,12 +51,12 @@ public class DmaapConsumerTaskImpl implements DmaapConsumerTask {
@Autowired
public DmaapConsumerTaskImpl(Config config) {
this(config, new DmaapConsumerJsonParser(),
- new ConsumerReactiveHttpClientFactory(new DMaaPReactiveWebClientFactory()));
+ new ConsumerReactiveHttpClientFactory(new DMaaPReactiveWebClientFactory()));
}
DmaapConsumerTaskImpl(Config prhAppConfig,
- DmaapConsumerJsonParser dmaapConsumerJsonParser,
- ConsumerReactiveHttpClientFactory httpClientFactory) {
+ DmaapConsumerJsonParser dmaapConsumerJsonParser,
+ ConsumerReactiveHttpClientFactory httpClientFactory) {
this.config = prhAppConfig;
this.dmaapConsumerJsonParser = dmaapConsumerJsonParser;
this.httpClientFactory = httpClientFactory;
@@ -73,7 +71,6 @@ public class DmaapConsumerTaskImpl implements DmaapConsumerTask {
public Flux<ConsumerDmaapModel> execute(String object) throws SSLException {
DMaaPConsumerReactiveHttpClient dmaaPConsumerReactiveHttpClient = resolveClient();
LOGGER.debug("Method called with arg {}", object);
-
Mono<JsonArray> response = dmaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse(
Optional.empty());
return dmaapConsumerJsonParser.getJsonObject(response);
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
index 7ecf4a6e..6ae8a3c7 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
@@ -32,7 +32,6 @@ import org.onap.dcaegen2.services.prh.exceptions.DmaapEmptyResponseException;
import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.model.logging.MdcVariables;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -109,9 +108,7 @@ public class ScheduledTasks {
}
private void onSuccess(HttpClientResponse response) {
-
String statusCode = Integer.toString(response.status().code());
-
MDC.put(RESPONSE_CODE, statusCode);
logger.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}",
statusCode);
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);