From 3737046ff3c8e032257b257912778403fc058ee0 Mon Sep 17 00:00:00 2001 From: pwielebs Date: Tue, 4 Sep 2018 09:38:35 +0200 Subject: Clear warnings in sysout Fix: *Checkstyle violations *Sonar Issues *FindBugs Issues Change-Id: Ie634fa6644cdbdb1f952826a75c6a4ffeabe0cbf Issue-ID: DCAEGEN2-606 Signed-off-by: pwielebs --- .../services/prh/service/AaiReactiveWebClient.java | 4 +- .../producer/AaiProducerReactiveHttpClient.java | 17 ++++----- .../prh/configuration/EnvironmentProcessor.java | 5 +-- .../services/prh/configuration/PrhAppConfig.java | 12 +++--- .../prh/configuration/SchedulerConfig.java | 16 ++++---- .../prh/controllers/HeartbeatController.java | 2 +- .../prh/service/DmaapConsumerJsonParser.java | 29 +++++++------- .../services/prh/service/HttpGetClient.java | 12 +++--- .../prh/service/PrhConfigurationProvider.java | 11 +++--- .../services/prh/tasks/AaiProducerTask.java | 2 +- .../services/prh/tasks/AaiProducerTaskImpl.java | 2 +- .../services/prh/tasks/ScheduledTasks.java | 14 ++++--- .../junit5/mockito/MockitoExtension.java | 6 +-- .../services/prh/service/HttpGetClientTest.java | 13 ++++--- .../prh/service/PrhConfigurationProviderTest.java | 7 ++-- .../services/prh/tasks/AaiPublisherTaskSpy.java | 7 +++- .../prh/tasks/DmaapPublisherTaskImplTest.java | 14 +++++-- .../services/prh/model/logging/MDCVariables.java | 43 --------------------- .../services/prh/model/logging/MdcVariables.java | 44 ++++++++++++++++++++++ .../services/prh/config/DmaapCustomConfig.java | 1 - .../consumer/DMaaPConsumerReactiveHttpClient.java | 6 +-- .../producer/DMaaPProducerReactiveHttpClient.java | 6 +-- 22 files changed, 142 insertions(+), 131 deletions(-) delete mode 100644 prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MDCVariables.java create mode 100644 prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MdcVariables.java diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java index 55dcb398..b13f1824 100644 --- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java +++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java @@ -20,8 +20,8 @@ package org.onap.dcaegen2.services.prh.service; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.RESPONSE_CODE; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.SERVICE_NAME; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.RESPONSE_CODE; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.SERVICE_NAME; import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication; import io.netty.handler.ssl.SslContext; diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java index 358a4524..4e0758c1 100644 --- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java +++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java @@ -20,23 +20,22 @@ package org.onap.dcaegen2.services.prh.service.producer; +import static org.onap.dcaegen2.services.prh.model.CommonFunctions.createJsonBody; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.REQUEST_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_INVOCATION_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_ONAP_REQUEST_ID; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.UUID; import org.apache.http.client.utils.URIBuilder; import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.UUID; - -import static org.onap.dcaegen2.services.prh.model.CommonFunctions.createJsonBody; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.*; - public class AaiProducerReactiveHttpClient { diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java index fdf6847b..114e9839 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java @@ -20,6 +20,8 @@ package org.onap.dcaegen2.services.prh.configuration; +import java.util.Optional; +import java.util.Properties; import org.onap.dcaegen2.services.prh.exceptions.EnvironmentLoaderException; import org.onap.dcaegen2.services.prh.model.EnvProperties; import org.onap.dcaegen2.services.prh.model.ImmutableEnvProperties; @@ -27,9 +29,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; -import java.util.Optional; -import java.util.Properties; - /** * @author Przemysław Wąsala on 8/10/18 */ diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java index 92574417..03d24382 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java @@ -20,8 +20,8 @@ package org.onap.dcaegen2.services.prh.configuration; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.INVOCATION_ID; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.REQUEST_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.INVOCATION_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.REQUEST_ID; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; @@ -141,11 +141,11 @@ public abstract class PrhAppConfig implements Config { this.filepath = filepath; } - public void setXOnapRequestId(String xOnapRequestId) { - MDC.put(REQUEST_ID, xOnapRequestId); + public void setXOnapRequestId(String xonaprequestid) { + MDC.put(REQUEST_ID, xonaprequestid); } - public void setXInvocationId(String xInvocationId) { - MDC.put(INVOCATION_ID, xInvocationId); + public void setXInvocationId(String xinvocationid) { + MDC.put(INVOCATION_ID, xinvocationid); } } \ No newline at end of file diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java index 214d6db6..76ba5ec6 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java @@ -21,6 +21,12 @@ package org.onap.dcaegen2.services.prh.configuration; import io.swagger.annotations.ApiOperation; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ScheduledFuture; +import javax.annotation.PostConstruct; import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,12 +40,6 @@ import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.annotation.EnableScheduling; import reactor.core.publisher.Mono; -import javax.annotation.PostConstruct; -import java.time.Duration; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ScheduledFuture; /** * @author Przemysław Wąsala on 6/13/18 @@ -60,8 +60,8 @@ public class SchedulerConfig { @Autowired public SchedulerConfig(TaskScheduler taskScheduler, - ScheduledTasks scheduledTask, - CloudConfiguration cloudConfiguration) { + ScheduledTasks scheduledTask, + CloudConfiguration cloudConfiguration) { this.taskScheduler = taskScheduler; this.scheduledTask = scheduledTask; this.cloudConfiguration = cloudConfiguration; diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java index 1b2f4a11..c09cc945 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java @@ -54,7 +54,7 @@ public class HeartbeatController { @ApiResponse(code = 401, message = "You are not authorized to view the resource"), @ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"), @ApiResponse(code = 404, message = "The resource you were trying to reach is not found") - } + } ) public Mono> heartbeat() { LOGGER.trace("Receiving heartbeat request"); diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java index a5ecc1dd..4e34f6e6 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java @@ -23,6 +23,8 @@ package org.onap.dcaegen2.services.prh.service; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import java.util.Optional; +import java.util.stream.StreamSupport; import org.onap.dcaegen2.services.prh.exceptions.DmaapEmptyResponseException; import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException; import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel; @@ -30,9 +32,6 @@ import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel; import org.springframework.util.StringUtils; import reactor.core.publisher.Mono; -import java.util.Optional; -import java.util.stream.StreamSupport; - /** * @author Przemysław Wąsala on 5/8/18 */ @@ -88,21 +87,21 @@ public class DmaapConsumerJsonParser { private Mono transform(JsonObject responseFromDmaap) { JsonObject commonEventHeader = responseFromDmaap.getAsJsonObject(EVENT) - .getAsJsonObject(COMMON_EVENT_HEADER); + .getAsJsonObject(COMMON_EVENT_HEADER); JsonObject pnfRegistrationFields = responseFromDmaap.getAsJsonObject(EVENT) - .getAsJsonObject(PNF_REGISTRATION_FIELDS); + .getAsJsonObject(PNF_REGISTRATION_FIELDS); String pnfSourceName = getValueFromJson(commonEventHeader, SOURCE_NAME); String pnfOamIpv4Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_4_ADDRESS); String pnfOamIpv6Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_6_ADDRESS); - return ( StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address) ) - ? Mono.error(new DmaapNotFoundException("Incorrect json, consumerDmaapModel can not be created: " - + printMessage(pnfSourceName, pnfOamIpv4Address, pnfOamIpv6Address))) : - Mono.just(ImmutableConsumerDmaapModel.builder() - .sourceName(pnfSourceName) - .ipv4(pnfOamIpv4Address) - .ipv6(pnfOamIpv6Address).build()); + return (StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address)) + ? Mono.error(new DmaapNotFoundException("Incorrect json, consumerDmaapModel can not be created: " + + printMessage(pnfSourceName, pnfOamIpv4Address, pnfOamIpv6Address))) : + Mono.just(ImmutableConsumerDmaapModel.builder() + .sourceName(pnfSourceName) + .ipv4(pnfOamIpv4Address) + .ipv6(pnfOamIpv6Address).build()); } private String getValueFromJson(JsonObject jsonObject, String jsonKey) { @@ -119,9 +118,9 @@ public class DmaapConsumerJsonParser { private String printMessage(String sourceName, String oamIpv4Address, String oamIpv6Address) { return String.format("%n{" - + "\"" + SOURCE_NAME + "\": \"%s\"," - + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\"," - + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\"" + + "\"" + SOURCE_NAME + "\": \"%s\"," + + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\"," + + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\"" + "%n}", sourceName, oamIpv4Address, oamIpv6Address); } } diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java index 4f66e25c..e3a8dcf6 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpGetClient.java @@ -46,7 +46,7 @@ class HttpGetClient { this.gson = new Gson(); } - Mono callHttpGet(String url, Class tClass) { + Mono callHttpGet(String url, Class genericClassDeclaration) { return webClient .get() .uri(url) @@ -54,7 +54,7 @@ class HttpGetClient { .onStatus(HttpStatus::is4xxClientError, response -> Mono.error(getException(response))) .onStatus(HttpStatus::is5xxServerError, response -> Mono.error(getException(response))) .bodyToMono(String.class) - .flatMap(body -> getJsonFromRequest(body, tClass)); + .flatMap(body -> getJsonFromRequest(body, genericClassDeclaration)); } private RuntimeException getException(ClientResponse response) { @@ -62,16 +62,16 @@ class HttpGetClient { response.statusCode().value())); } - private Mono getJsonFromRequest(String body, Class tClass) { + private Mono getJsonFromRequest(String body, Class genericClassDeclaration) { try { - return Mono.just(parseJson(body, tClass)); + return Mono.just(parseJson(body, genericClassDeclaration)); } catch (JsonSyntaxException | IllegalStateException e) { return Mono.error(e); } } - private T parseJson(String body, Class tClass) { - return gson.fromJson(body, tClass); + private T parseJson(String body, Class genericClassDeclaration) { + return gson.fromJson(body, genericClassDeclaration); } private static ExchangeFilterFunction logResponse() { diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java index b346bf5e..414c5a34 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProvider.java @@ -22,6 +22,7 @@ package org.onap.dcaegen2.services.prh.service; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import java.net.URISyntaxException; import org.apache.http.client.utils.URIBuilder; import org.onap.dcaegen2.services.prh.model.EnvProperties; import org.slf4j.Logger; @@ -29,7 +30,6 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; -import java.net.URISyntaxException; /** * @author Przemysław Wąsala on 8/10/18 @@ -59,7 +59,7 @@ public class PrhConfigurationProvider { LOGGER.info("Retrieving Config Binding Service endpoint from Consul"); try { return httpGetClient.callHttpGet(getConsulUrl(envProperties), JsonArray.class) - .flatMap(jsonArray -> this.createConfigBindingServiceURL(jsonArray, envProperties.appName())); + .flatMap(jsonArray -> this.createConfigBindingserviceurl(jsonArray, envProperties.appName())); } catch (URISyntaxException e) { LOGGER.warn("Malformed Consul uri", e); return Mono.error(e); @@ -77,11 +77,12 @@ public class PrhConfigurationProvider { } - private Mono createConfigBindingServiceURL(JsonArray jsonArray, String appName) { - return getConfigBindingObject(jsonArray).flatMap(jsonObject -> buildConfigBindingServiceURL(jsonObject, appName)); + private Mono createConfigBindingserviceurl(JsonArray jsonArray, String appName) { + return getConfigBindingObject(jsonArray) + .flatMap(jsonObject -> buildConfigBindingserviceurl(jsonObject, appName)); } - private Mono buildConfigBindingServiceURL(JsonObject jsonObject, String appName) { + private Mono buildConfigBindingserviceurl(JsonObject jsonObject, String appName) { try { return Mono.just(getUri(jsonObject.get("ServiceAddress").getAsString(), jsonObject.get("ServicePort").getAsInt(), "/service_component", appName)); diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java index 5a05d374..efa4f66f 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java @@ -20,6 +20,7 @@ package org.onap.dcaegen2.services.prh.tasks; +import javax.net.ssl.SSLException; import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration; import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException; import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException; @@ -29,7 +30,6 @@ import org.onap.dcaegen2.services.prh.service.producer.AaiProducerReactiveHttpCl import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; -import javax.net.ssl.SSLException; /** * @author Przemysław Wąsala on 4/13/18 diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java index 7ccf75a6..5bf3e408 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java @@ -20,6 +20,7 @@ package org.onap.dcaegen2.services.prh.tasks; +import javax.net.ssl.SSLException; import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration; import org.onap.dcaegen2.services.prh.configuration.Config; import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException; @@ -36,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; -import javax.net.ssl.SSLException; /** * @author Przemysław Wąsala on 4/13/18 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 f74bc56a..728c0dae 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 @@ -20,8 +20,9 @@ package org.onap.dcaegen2.services.prh.tasks; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.INSTANCE_UUID; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.RESPONSE_CODE; + +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.INSTANCE_UUID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.RESPONSE_CODE; import java.util.Map; import java.util.UUID; @@ -30,7 +31,7 @@ import javax.net.ssl.SSLException; 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.onap.dcaegen2.services.prh.model.logging.MdcVariables; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -71,7 +72,7 @@ public class ScheduledTasks { * Main function for scheduling prhWorkflow. */ public void scheduleMainPrhEventTask() { - MDCVariables.setMdcContextMap(contextMap); + MdcVariables.setMdcContextMap(contextMap); try { logger.trace("Execution of tasks was registered"); CountDownLatch mainCountDownLatch = new CountDownLatch(1); @@ -86,7 +87,8 @@ public class ScheduledTasks { mainCountDownLatch.await(); } catch (InterruptedException e) { - throw new RuntimeException(e); + logger.warn("Interruption problem on countDownLatch ", e); + Thread.currentThread().interrupt(); } } @@ -110,7 +112,7 @@ public class ScheduledTasks { private Mono consumeFromDMaaPMessage() { return Mono.defer(() -> { - MDCVariables.setMdcContextMap(contextMap); + MdcVariables.setMdcContextMap(contextMap); MDC.put(INSTANCE_UUID, UUID.randomUUID().toString()); logger.info("Init configs"); dmaapConsumerTask.initConfigs(); diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/integration/junit5/mockito/MockitoExtension.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/integration/junit5/mockito/MockitoExtension.java index 9835e9ed..af9c2b44 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/integration/junit5/mockito/MockitoExtension.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/integration/junit5/mockito/MockitoExtension.java @@ -35,9 +35,9 @@ import org.mockito.MockitoAnnotations; /** * @author Przemysław Wąsala on 3/27/18 * - * {@code MockitoExtension } showcases the {@link TestInstancePostProcessor} and {@link ParameterResolver} extension - * APIs of JUnit 5 by providing dependency injection support at the field level and at the method parameter level - * viaMockito 2.x's {@link Mock @Mock} annotation. + * {@code MockitoExtension } showcases the {@link TestInstancePostProcessor} and {@link ParameterResolver} + * extension APIs of JUnit 5 by providing dependency injection support at the field level and at the method + * parameter level viaMockito 2.x's {@link Mock @Mock} annotation. */ public class MockitoExtension implements TestInstancePostProcessor, ParameterResolver { diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java index 5caed791..20fbc6bf 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/HttpGetClientTest.java @@ -21,19 +21,20 @@ package org.onap.dcaegen2.services.prh.service; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; import com.google.gson.JsonSyntaxException; import org.junit.jupiter.api.Test; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; - class HttpGetClientTest { private static final String SOMEURL = "http://someurl"; private static final String DATA = "{}"; diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java index 8b7ea3d0..7b305222 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/service/PrhConfigurationProviderTest.java @@ -20,6 +20,10 @@ package org.onap.dcaegen2.services.prh.service; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -29,9 +33,6 @@ import org.onap.dcaegen2.services.prh.model.EnvProperties; import org.onap.dcaegen2.services.prh.model.ImmutableEnvProperties; import reactor.core.publisher.Mono; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; class PrhConfigurationProviderTest { diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiPublisherTaskSpy.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiPublisherTaskSpy.java index 231bf144..5b0979a4 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiPublisherTaskSpy.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiPublisherTaskSpy.java @@ -20,6 +20,11 @@ package org.onap.dcaegen2.services.prh.tasks; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +import javax.net.ssl.SSLException; import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration; import org.onap.dcaegen2.services.prh.configuration.AppConfig; import org.onap.dcaegen2.services.prh.service.producer.AaiProducerReactiveHttpClient; @@ -27,9 +32,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import javax.net.ssl.SSLException; -import static org.mockito.Mockito.*; /** * @author Przemysław Wąsala on 4/13/18 diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java index ae7b8e77..c410fc35 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImplTest.java @@ -20,6 +20,16 @@ package org.onap.dcaegen2.services.prh.tasks; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; @@ -36,10 +46,6 @@ import org.springframework.http.ResponseEntity; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; - /** * @author Przemysław Wąsala on 5/17/18 */ diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MDCVariables.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MDCVariables.java deleted file mode 100644 index 33d0c87d..00000000 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MDCVariables.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.services.prh.model.logging; - -import java.util.Map; -import org.slf4j.MDC; - -public final class MDCVariables { - - public static final String X_ONAP_REQUEST_ID = "X-ONAP-RequestID"; - public static final String X_INVOCATION_ID = "X-InvocationID"; - public static final String REQUEST_ID = "RequestID"; - public static final String INVOCATION_ID = "InvocationID"; - public static final String INSTANCE_UUID = "InstanceUUID"; - public static final String RESPONSE_CODE = "ResponseCode"; - public static final String SERVICE_NAME = "ServiceName"; - - public static void setMdcContextMap(Map mdcContextMap) { - if(mdcContextMap != null) - MDC.setContextMap(mdcContextMap); - } - - private MDCVariables() { - } -} diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MdcVariables.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MdcVariables.java new file mode 100644 index 00000000..c6fc4592 --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MdcVariables.java @@ -0,0 +1,44 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.prh.model.logging; + +import java.util.Map; +import org.slf4j.MDC; + +public final class MdcVariables { + + public static final String X_ONAP_REQUEST_ID = "X-ONAP-RequestID"; + public static final String X_INVOCATION_ID = "X-InvocationID"; + public static final String REQUEST_ID = "RequestID"; + public static final String INVOCATION_ID = "InvocationID"; + public static final String INSTANCE_UUID = "InstanceUUID"; + public static final String RESPONSE_CODE = "ResponseCode"; + public static final String SERVICE_NAME = "ServiceName"; + + private MdcVariables() { + } + + public static void setMdcContextMap(Map mdcContextMap) { + if (mdcContextMap != null) { + MDC.setContextMap(mdcContextMap); + } + } +} diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapCustomConfig.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapCustomConfig.java index 3c9bd99a..b21cc6ea 100644 --- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapCustomConfig.java +++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapCustomConfig.java @@ -21,7 +21,6 @@ package org.onap.dcaegen2.services.prh.config; import java.io.Serializable; -import java.util.Map; import org.immutables.value.Value; /** diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java index f9a66378..ab6686db 100644 --- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java +++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java @@ -20,9 +20,9 @@ package org.onap.dcaegen2.services.prh.service.consumer; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.REQUEST_ID; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.X_INVOCATION_ID; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.X_ONAP_REQUEST_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.REQUEST_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_INVOCATION_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_ONAP_REQUEST_ID; import java.net.URI; import java.net.URISyntaxException; diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java index 5c72b38c..0b61f9c2 100644 --- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java +++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java @@ -21,9 +21,9 @@ package org.onap.dcaegen2.services.prh.service.producer; import static org.onap.dcaegen2.services.prh.model.CommonFunctions.createJsonBody; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.REQUEST_ID; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.X_INVOCATION_ID; -import static org.onap.dcaegen2.services.prh.model.logging.MDCVariables.X_ONAP_REQUEST_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.REQUEST_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_INVOCATION_ID; +import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_ONAP_REQUEST_ID; import java.net.URI; import java.net.URISyntaxException; -- cgit 1.2.3-korg