summaryrefslogtreecommitdiffstats
path: root/prh-dmaap-client
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-07-10 11:47:01 +0200
committerwasala <przemyslaw.wasala@nokia.com>2018-08-07 10:18:47 +0200
commitc1f0313e1f0085afb813d1ba3e2d7fcc71b5833d (patch)
tree88bece267217d7a1d3d921c85aad2c01778e98f9 /prh-dmaap-client
parent01578219e470c4cd9b6181c0615759a7118c0abb (diff)
Checkstyle violations
*Correction of violations without javadoc Change-Id: Ida177bf32a58605e74feae5fab22198228e970ce Issue-ID: DCAEGEN2-563 Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
Diffstat (limited to 'prh-dmaap-client')
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapConsumerConfiguration.java7
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapCustomConfig.java3
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapPublisherConfiguration.java1
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPConsumerResponse.java32
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPConsumerResponseImpl.java72
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPResponse.java32
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java17
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java1
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java1
-rw-r--r--prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClientTest.java22
-rw-r--r--prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapConsumerConfigurationTest.java8
-rw-r--r--prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapPublisherConfigurationTest.java6
-rw-r--r--prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java41
-rw-r--r--prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClientTest.java43
14 files changed, 78 insertions, 208 deletions
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapConsumerConfiguration.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapConsumerConfiguration.java
index 89d3bd4c..6663554e 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapConsumerConfiguration.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapConsumerConfiguration.java
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* PNF-REGISTRATION-HANDLER
* ================================================================================
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.config;
import org.immutables.gson.Gson;
@@ -41,7 +42,7 @@ public abstract class DmaapConsumerConfiguration implements DmaapCustomConfig {
public abstract String consumerGroup();
@Value.Parameter
- public abstract Integer timeoutMS();
+ public abstract Integer timeoutMs();
@Value.Parameter
public abstract Integer messageLimit();
@@ -54,7 +55,7 @@ public abstract class DmaapConsumerConfiguration implements DmaapCustomConfig {
Builder consumerGroup(String consumerGroup);
- Builder timeoutMS(Integer timeoutMS);
+ Builder timeoutMs(Integer timeoutMs);
Builder messageLimit(Integer messageLimit);
}
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 ecc9d211..6e7f538a 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
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* PNF-REGISTRATION-HANDLER
* ================================================================================
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.config;
import java.io.Serializable;
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapPublisherConfiguration.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapPublisherConfiguration.java
index 2e95463c..e353056f 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapPublisherConfiguration.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/config/DmaapPublisherConfiguration.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.config;
import org.immutables.gson.Gson;
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPConsumerResponse.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPConsumerResponse.java
deleted file mode 100644
index d2c83e73..00000000
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPConsumerResponse.java
+++ /dev/null
@@ -1,32 +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.response;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/17/18
- */
-public interface DMaaPConsumerResponse extends DMaaPResponse {
-
-
- List<String> getFetchedMessages();
-
-}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPConsumerResponseImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPConsumerResponseImpl.java
deleted file mode 100644
index ddac9cbf..00000000
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPConsumerResponseImpl.java
+++ /dev/null
@@ -1,72 +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.response;
-
-import static java.util.Collections.unmodifiableList;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import java.util.StringJoiner;
-import org.springframework.lang.NonNull;
-import org.springframework.lang.Nullable;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/17/18
- */
-public class DMaaPConsumerResponseImpl implements DMaaPConsumerResponse {
-
-
- private final Integer responseCode;
- private final String responseMessage;
- private final List<String> fetchedMessage;
-
- public DMaaPConsumerResponseImpl(@NonNull Integer responseCode, @NonNull String responseMessage,
- @Nullable List<String> fetchedMessage) {
- this.responseCode = responseCode;
- this.responseMessage = responseMessage;
- this.fetchedMessage = Optional.ofNullable(fetchedMessage).orElse(Collections.emptyList());
- }
-
-
- @Override
- public String getResponseMessage() {
- return responseMessage;
- }
-
- @Override
- public Integer getResponseCode() {
- return responseCode;
- }
-
- @Override
- public List<String> getFetchedMessages() {
- return unmodifiableList(fetchedMessage);
- }
-
- @Override
- public String toString() {
- return new StringJoiner(", ", this.getClass().getSimpleName() + "[", "]")
- .add("responseCode=" + responseCode)
- .add("responseMessage=" + responseMessage)
- .add("fetchedMessage=" + fetchedMessage)
- .toString();
- }
-}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPResponse.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPResponse.java
deleted file mode 100644
index 5bf199c0..00000000
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/response/DMaaPResponse.java
+++ /dev/null
@@ -1,32 +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.response;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/17/18
- */
-public interface DMaaPResponse {
-
- Integer getResponseCode();
-
-
- String getResponseMessage();
-}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java
index ab81bede..b0cca3f3 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.service;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
@@ -36,21 +37,21 @@ public class DMaaPReactiveWebClient {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private String dMaaPContentType;
- private String dMaaPUserName;
- private String dMaaPUserPassword;
+ private String dmaaPContentType;
+ private String dmaaPUserName;
+ private String dmaaPUserPassword;
public DMaaPReactiveWebClient fromConfiguration(DmaapCustomConfig dmaapCustomConfig) {
- this.dMaaPUserName = dmaapCustomConfig.dmaapUserName();
- this.dMaaPUserPassword = dmaapCustomConfig.dmaapUserPassword();
- this.dMaaPContentType = dmaapCustomConfig.dmaapContentType();
+ this.dmaaPUserName = dmaapCustomConfig.dmaapUserName();
+ this.dmaaPUserPassword = dmaapCustomConfig.dmaapUserPassword();
+ this.dmaaPContentType = dmaapCustomConfig.dmaapContentType();
return this;
}
public WebClient build() {
return WebClient.builder()
- .defaultHeader(HttpHeaders.CONTENT_TYPE, dMaaPContentType)
- .filter(basicAuthentication(dMaaPUserName, dMaaPUserPassword))
+ .defaultHeader(HttpHeaders.CONTENT_TYPE, dmaaPContentType)
+ .filter(basicAuthentication(dmaaPUserName, dmaaPUserPassword))
.filter(logRequest())
.filter(logResponse())
.build();
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 23cdc98d..af54bf3b 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.service.consumer;
import java.net.URI;
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 e29ecc64..0bc78d43 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.service.producer;
import java.net.URI;
diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClientTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClientTest.java
index 2e323c5e..ee88f1f8 100644
--- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClientTest.java
+++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClientTest.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.service;
import static org.mockito.Mockito.mock;
@@ -30,28 +31,27 @@ import org.springframework.web.reactive.function.client.WebClient;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/5/18
*/
-public class DMaaPReactiveWebClientTest {
+class DMaaPReactiveWebClientTest {
@Test
- public void builder_shouldBuildDMaaPReactiveWebClient() {
+ void builder_shouldBuildDMaaPReactiveWebClient() {
//given
DmaapConsumerConfiguration dmaapConsumerConfiguration = mock(DmaapConsumerConfiguration.class);
- WebClient dMaaPReactiveWebClient;
- String dMaaPContentType = "*/*";
- String dMaaPUserName = "DMaaP";
- String dMaaPUserPassword = "DMaaP";
+ String dmaaPContentType = "*/*";
+ String dmaaPUserName = "DMaaP";
+ String dmaaPUserPassword = "DMaaP";
//when
- when(dmaapConsumerConfiguration.dmaapContentType()).thenReturn(dMaaPContentType);
- when(dmaapConsumerConfiguration.dmaapUserName()).thenReturn(dMaaPUserName);
- when(dmaapConsumerConfiguration.dmaapUserPassword()).thenReturn(dMaaPUserPassword);
- dMaaPReactiveWebClient = new DMaaPReactiveWebClient()
+ when(dmaapConsumerConfiguration.dmaapContentType()).thenReturn(dmaaPContentType);
+ when(dmaapConsumerConfiguration.dmaapUserName()).thenReturn(dmaaPUserName);
+ when(dmaapConsumerConfiguration.dmaapUserPassword()).thenReturn(dmaaPUserPassword);
+ WebClient dmaapreactiveWebClient = new DMaaPReactiveWebClient()
.fromConfiguration(dmaapConsumerConfiguration)
.build();
//then
- Assertions.assertNotNull(dMaaPReactiveWebClient);
+ Assertions.assertNotNull(dmaapreactiveWebClient);
}
} \ No newline at end of file
diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapConsumerConfigurationTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapConsumerConfigurationTest.java
index 96939771..2239d110 100644
--- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapConsumerConfigurationTest.java
+++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapConsumerConfigurationTest.java
@@ -25,10 +25,10 @@ import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.prh.config.ImmutableDmaapConsumerConfiguration;
-public class DmaapConsumerConfigurationTest {
+class DmaapConsumerConfigurationTest {
@Test
- public void builder_shouldBuildConfigurationObject() {
+ void builder_shouldBuildConfigurationObject() {
// Given
DmaapConsumerConfiguration configuration;
@@ -55,7 +55,7 @@ public class DmaapConsumerConfigurationTest {
.dmaapUserPassword(dmaapUserPassword)
.dmaapContentType(dmaapContentType)
.consumerGroup(consumerGroup)
- .timeoutMS(timeoutMs)
+ .timeoutMs(timeoutMs)
.messageLimit(messageLimit)
.build();
@@ -69,7 +69,7 @@ public class DmaapConsumerConfigurationTest {
Assertions.assertEquals(dmaapUserName, configuration.dmaapUserName());
Assertions.assertEquals(dmaapUserPassword, configuration.dmaapUserPassword());
Assertions.assertEquals(consumerGroup, configuration.consumerGroup());
- Assertions.assertEquals(timeoutMs, configuration.timeoutMS());
+ Assertions.assertEquals(timeoutMs, configuration.timeoutMs());
Assertions.assertEquals(messageLimit, configuration.messageLimit());
}
}
diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapPublisherConfigurationTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapPublisherConfigurationTest.java
index 47dd30f4..f4a8f107 100644
--- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapPublisherConfigurationTest.java
+++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/config/DmaapPublisherConfigurationTest.java
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* PNF-REGISTRATION-HANDLER
* ================================================================================
@@ -25,11 +25,11 @@ import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.prh.config.ImmutableDmaapPublisherConfiguration;
-public class DmaapPublisherConfigurationTest {
+class DmaapPublisherConfigurationTest {
@Test
- public void builder_shouldBuildConfigurationObject() {
+ void builder_shouldBuildConfigurationObject() {
// Given
DmaapPublisherConfiguration configuration;
diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java
index 1f04da15..9a46b2a9 100644
--- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java
+++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java
@@ -17,10 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.service.consumer;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -30,11 +30,10 @@ import static org.springframework.web.reactive.function.client.ExchangeFilterFun
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration;
import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClient.RequestHeadersUriSpec;
import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
@@ -44,20 +43,20 @@ import reactor.test.StepVerifier;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 6/27/18
*/
-public class DMaaPConsumerReactiveHttpClientTest {
+class DMaaPConsumerReactiveHttpClientTest {
- private static DMaaPConsumerReactiveHttpClient DMaaPConsumerReactiveHttpClient;
+ private DMaaPConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient;
- private static DmaapConsumerConfiguration consumerConfigurationMock = mock(DmaapConsumerConfiguration.class);
+ private DmaapConsumerConfiguration consumerConfigurationMock = mock(DmaapConsumerConfiguration.class);
private static final String JSON_MESSAGE = "{ \"responseFromDmaap\": \"Success\"}";
- private static Mono<String> expectedResult = Mono.empty();
- private static WebClient webClient = mock(WebClient.class);
- private static RequestHeadersUriSpec requestHeadersSpec;
- private static ResponseSpec responseSpec;
+ private Mono<String> expectedResult = Mono.empty();
+ private WebClient webClient = mock(WebClient.class);
+ private RequestHeadersUriSpec requestHeadersSpec;
+ private ResponseSpec responseSpec;
- @BeforeAll
- public static void setUp() {
+ @BeforeEach
+ void setUp() {
when(consumerConfigurationMock.dmaapHostName()).thenReturn("54.45.33.2");
when(consumerConfigurationMock.dmaapProtocol()).thenReturn("https");
when(consumerConfigurationMock.dmaapPortNumber()).thenReturn(1234);
@@ -68,7 +67,7 @@ public class DMaaPConsumerReactiveHttpClientTest {
when(consumerConfigurationMock.consumerGroup()).thenReturn("OpenDCAE-c12");
when(consumerConfigurationMock.consumerId()).thenReturn("c12");
- DMaaPConsumerReactiveHttpClient = new DMaaPConsumerReactiveHttpClient(consumerConfigurationMock);
+ dmaapConsumerReactiveHttpClient = new DMaaPConsumerReactiveHttpClient(consumerConfigurationMock);
webClient = spy(WebClient.builder()
.defaultHeader(HttpHeaders.CONTENT_TYPE, consumerConfigurationMock.dmaapContentType())
.filter(basicAuthentication(consumerConfigurationMock.dmaapUserName(),
@@ -80,15 +79,15 @@ public class DMaaPConsumerReactiveHttpClientTest {
@Test
- public void getHttpResponse_Success() {
+ void getHttpResponse_Success() {
//given
expectedResult = Mono.just(JSON_MESSAGE);
//when
mockDependantObjects();
doReturn(expectedResult).when(responseSpec).bodyToMono(String.class);
- DMaaPConsumerReactiveHttpClient.createDMaaPWebClient(webClient);
- Mono<String> response = DMaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse();
+ dmaapConsumerReactiveHttpClient.createDMaaPWebClient(webClient);
+ Mono<String> response = dmaapConsumerReactiveHttpClient.getDMaaPConsumerResponse();
//then
StepVerifier.create(response).expectSubscription()
@@ -99,16 +98,16 @@ public class DMaaPConsumerReactiveHttpClientTest {
}
@Test
- public void getHttpResponse_whenURISyntaxExceptionHasBeenThrown() throws URISyntaxException {
+ void getHttpResponse_whenUriSyntaxExceptionHasBeenThrown() throws URISyntaxException {
//given
- DMaaPConsumerReactiveHttpClient = spy(DMaaPConsumerReactiveHttpClient);
+ dmaapConsumerReactiveHttpClient = spy(dmaapConsumerReactiveHttpClient);
//when
when(webClient.get()).thenReturn(requestHeadersSpec);
- DMaaPConsumerReactiveHttpClient.createDMaaPWebClient(webClient);
- when(DMaaPConsumerReactiveHttpClient.getUri()).thenThrow(URISyntaxException.class);
+ dmaapConsumerReactiveHttpClient.createDMaaPWebClient(webClient);
+ when(dmaapConsumerReactiveHttpClient.getUri()).thenThrow(URISyntaxException.class);
//then
- StepVerifier.create(DMaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse()).expectSubscription()
+ StepVerifier.create(dmaapConsumerReactiveHttpClient.getDMaaPConsumerResponse()).expectSubscription()
.expectError(Exception.class).verify();
}
diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClientTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClientTest.java
index 20ab64e5..b5e730a0 100644
--- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClientTest.java
+++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClientTest.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.prh.service.producer;
import static org.mockito.ArgumentMatchers.any;
@@ -29,7 +30,7 @@ import static org.springframework.web.reactive.function.client.ExchangeFilterFun
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
@@ -45,21 +46,20 @@ import reactor.test.StepVerifier;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18
*/
-public class DMaaPProducerReactiveHttpClientTest {
+class DMaaPProducerReactiveHttpClientTest {
- private static DMaaPProducerReactiveHttpClient dMaaPProducerReactiveHttpClient;
+ private DMaaPProducerReactiveHttpClient dmaapProducerReactiveHttpClient;
- private static DmaapPublisherConfiguration dmaapPublisherConfigurationMock = mock(
+ private DmaapPublisherConfiguration dmaapPublisherConfigurationMock = mock(
DmaapPublisherConfiguration.class);
- private static final Integer RESPONSE_SUCCESS = 200;
- private static ConsumerDmaapModel consumerDmaapModel = new ConsumerDmaapModelForUnitTest();
- private static WebClient webClient = mock(WebClient.class);
- private static RequestBodyUriSpec requestBodyUriSpec;
- private static ResponseSpec responseSpec;
+ private ConsumerDmaapModel consumerDmaapModel = new ConsumerDmaapModelForUnitTest();
+ private WebClient webClient = mock(WebClient.class);
+ private RequestBodyUriSpec requestBodyUriSpec;
+ private ResponseSpec responseSpec;
- @BeforeAll
- public static void setUp() {
+ @BeforeEach
+ void setUp() {
when(dmaapPublisherConfigurationMock.dmaapHostName()).thenReturn("54.45.33.2");
when(dmaapPublisherConfigurationMock.dmaapProtocol()).thenReturn("https");
when(dmaapPublisherConfigurationMock.dmaapPortNumber()).thenReturn(1234);
@@ -68,7 +68,7 @@ public class DMaaPProducerReactiveHttpClientTest {
when(dmaapPublisherConfigurationMock.dmaapContentType()).thenReturn("application/json");
when(dmaapPublisherConfigurationMock.dmaapTopicName()).thenReturn("pnfReady");
- dMaaPProducerReactiveHttpClient = new DMaaPProducerReactiveHttpClient(dmaapPublisherConfigurationMock);
+ dmaapProducerReactiveHttpClient = new DMaaPProducerReactiveHttpClient(dmaapPublisherConfigurationMock);
webClient = spy(WebClient.builder()
.defaultHeader(HttpHeaders.CONTENT_TYPE, dmaapPublisherConfigurationMock.dmaapContentType())
@@ -80,31 +80,32 @@ public class DMaaPProducerReactiveHttpClientTest {
}
@Test
- public void getHttpResponse_Success() {
+ void getHttpResponse_Success() {
//given
- Mono<Integer> expectedResult = Mono.just(RESPONSE_SUCCESS);
+ Integer responseSuccess = 200;
+ Mono<Integer> expectedResult = Mono.just(responseSuccess);
//when
mockWebClientDependantObject();
doReturn(expectedResult).when(responseSpec).bodyToMono(String.class);
- dMaaPProducerReactiveHttpClient.createDMaaPWebClient(webClient);
- Mono<String> response = dMaaPProducerReactiveHttpClient.getDMaaPProducerResponse(Mono.just(consumerDmaapModel));
+ dmaapProducerReactiveHttpClient.createDMaaPWebClient(webClient);
+ Mono<String> response = dmaapProducerReactiveHttpClient.getDMaaPProducerResponse(Mono.just(consumerDmaapModel));
//then
Assertions.assertEquals(response.block(), expectedResult.block());
}
@Test
- public void getHttpResponse_whenURISyntaxExceptionHasBeenThrown() throws URISyntaxException {
+ void getHttpResponse_whenUriSyntaxExceptionHasBeenThrown() throws URISyntaxException {
//given
- dMaaPProducerReactiveHttpClient = spy(dMaaPProducerReactiveHttpClient);
+ dmaapProducerReactiveHttpClient = spy(dmaapProducerReactiveHttpClient);
//when
when(webClient.post()).thenReturn(requestBodyUriSpec);
- dMaaPProducerReactiveHttpClient.createDMaaPWebClient(webClient);
- when(dMaaPProducerReactiveHttpClient.getUri()).thenThrow(URISyntaxException.class);
+ dmaapProducerReactiveHttpClient.createDMaaPWebClient(webClient);
+ when(dmaapProducerReactiveHttpClient.getUri()).thenThrow(URISyntaxException.class);
//then
- StepVerifier.create(dMaaPProducerReactiveHttpClient.getDMaaPProducerResponse(any())).expectSubscription()
+ StepVerifier.create(dmaapProducerReactiveHttpClient.getDMaaPProducerResponse(any())).expectSubscription()
.expectError(Exception.class).verify();
}