summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/test/java/org
diff options
context:
space:
mode:
authormicdzied <michal.1.dziedzic@nokia.com>2018-08-30 10:25:19 +0200
committermicdzied <michal.1.dziedzic@nokia.com>2018-08-30 14:53:20 +0200
commit6fd8c7770fbea30ad2ec6e3f7645b8baab5a49a1 (patch)
tree78d572b5df8c88047d74edf3c75b28fcab3d0dc6 /prh-app-server/src/test/java/org
parent82a6fc31d1905f380fbbae1d0b4a34b67d8258e3 (diff)
add MDC's
Change-Id: Ie4fe86791f46b790ae42088a5d2b93f491e4549d Issue-ID: DCAEGEN2-730 Signed-off-by: micdzied <michal.1.dziedzic@nokia.com>
Diffstat (limited to 'prh-app-server/src/test/java/org')
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java78
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/integration/junit5/mockito/MockitoExtension.java7
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java23
3 files changed, 56 insertions, 52 deletions
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java
index 6d74771d..dd0a3dbd 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java
@@ -20,12 +20,17 @@
package org.onap.dcaegen2.services.prh.configuration;
+import static org.assertj.core.api.Assertions.assertThat;
+
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.services.prh.config.*;
-
-import static org.assertj.core.api.Assertions.assertThat;
+import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
+import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
+import org.onap.dcaegen2.services.prh.config.ImmutableAaiClientConfiguration;
+import org.onap.dcaegen2.services.prh.config.ImmutableDmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.prh.config.ImmutableDmaapPublisherConfiguration;
public class CloudConfigParserTest {
@@ -58,47 +63,48 @@ public class CloudConfigParserTest {
private static final ImmutableAaiClientConfiguration correctAaiClientConfig =
new ImmutableAaiClientConfiguration.Builder()
- .aaiHost("aai.onap.svc.cluster.local")
- .aaiPort(8443)
- .aaiUserName("AAI")
- .aaiPnfPath("/network/pnfs/pnf")
- .aaiIgnoreSslCertificateErrors(true)
- .aaiUserPassword("AAI")
- .aaiProtocol("https")
- .aaiBasePath("/aai/v12")
- .build();
+ .aaiHost("aai.onap.svc.cluster.local")
+ .aaiPort(8443)
+ .aaiUserName("AAI")
+ .aaiPnfPath("/network/pnfs/pnf")
+ .aaiIgnoreSslCertificateErrors(true)
+ .aaiUserPassword("AAI")
+ .aaiProtocol("https")
+ .aaiBasePath("/aai/v12")
+ .build();
private static final ImmutableDmaapConsumerConfiguration correctDmaapConsumerConfig =
new ImmutableDmaapConsumerConfiguration.Builder()
- .timeoutMs(-1)
- .dmaapHostName("message-router.onap.svc.cluster.local")
- .dmaapUserName("admin")
- .dmaapUserPassword("admin")
- .dmaapTopicName("/events/unauthenticated.SEC_OTHER_OUTPUT")
- .dmaapPortNumber(3904)
- .dmaapContentType("application/json")
- .messageLimit(-1)
- .dmaapProtocol("http")
- .consumerId("c12")
- .consumerGroup("OpenDCAE-c12")
- .build();
+ .timeoutMs(-1)
+ .dmaapHostName("message-router.onap.svc.cluster.local")
+ .dmaapUserName("admin")
+ .dmaapUserPassword("admin")
+ .dmaapTopicName("/events/unauthenticated.SEC_OTHER_OUTPUT")
+ .dmaapPortNumber(3904)
+ .dmaapContentType("application/json")
+ .messageLimit(-1)
+ .dmaapProtocol("http")
+ .consumerId("c12")
+ .consumerGroup("OpenDCAE-c12")
+ .build();
private static final ImmutableDmaapPublisherConfiguration correctDmaapPublisherConfig =
new ImmutableDmaapPublisherConfiguration.Builder()
- .dmaapTopicName("/events/unauthenticated.PNF_READY")
- .dmaapUserPassword("admin")
- .dmaapPortNumber(3904)
- .dmaapProtocol("http")
- .dmaapContentType("application/json")
- .dmaapHostName("message-router.onap.svc.cluster.local")
- .dmaapUserName("admin")
- .build();
+ .dmaapTopicName("/events/unauthenticated.PNF_READY")
+ .dmaapUserPassword("admin")
+ .dmaapPortNumber(3904)
+ .dmaapProtocol("http")
+ .dmaapContentType("application/json")
+ .dmaapHostName("message-router.onap.svc.cluster.local")
+ .dmaapUserName("admin")
+ .build();
- private CloudConfigParser cloudConfigParser = new CloudConfigParser(new Gson().fromJson(correctJson, JsonObject.class));
+ private CloudConfigParser cloudConfigParser = new CloudConfigParser(
+ new Gson().fromJson(correctJson, JsonObject.class));
@Test
- public void shouldCreateAaiConfigurationCorrectly(){
+ public void shouldCreateAaiConfigurationCorrectly() {
// when
AaiClientConfiguration aaiClientConfig = cloudConfigParser.getAaiClientConfig();
@@ -109,7 +115,7 @@ public class CloudConfigParserTest {
@Test
- public void shouldCreateDmaapConsumerConfigurationCorrectly(){
+ public void shouldCreateDmaapConsumerConfigurationCorrectly() {
// when
DmaapConsumerConfiguration dmaapConsumerConfig = cloudConfigParser.getDmaapConsumerConfig();
@@ -120,7 +126,7 @@ public class CloudConfigParserTest {
@Test
- public void shouldCreateDmaapPublisherConfigurationCorrectly(){
+ public void shouldCreateDmaapPublisherConfigurationCorrectly() {
// when
DmaapPublisherConfiguration dmaapPublisherConfig = cloudConfigParser.getDmaapPublisherConfig();
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 5c19186b..9835e9ed 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
@@ -23,7 +23,6 @@ package org.onap.dcaegen2.services.prh.integration.junit5.mockito;
import static org.mockito.Mockito.mock;
import java.lang.reflect.Parameter;
-
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
import org.junit.jupiter.api.extension.ExtensionContext.Store;
@@ -36,9 +35,9 @@ import org.mockito.MockitoAnnotations;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> 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/tasks/AaiProducerTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java
index 4589341e..54259397 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImplTest.java
@@ -81,6 +81,17 @@ class AaiProducerTaskImplTest {
}
+ private static void getAaiProducerTask_whenMockingResponseObject(Integer statusCode) {
+ //given
+ aaiProducerReactiveHttpClient = mock(AaiProducerReactiveHttpClient.class);
+ when(aaiProducerReactiveHttpClient.getAaiProducerResponse(any()))
+ .thenReturn(Mono.just(statusCode));
+ when(appConfig.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration);
+ aaiProducerTask = spy(new AaiProducerTaskImpl(appConfig));
+ when(aaiProducerTask.resolveConfiguration()).thenReturn(aaiClientConfiguration);
+ doReturn(aaiProducerReactiveHttpClient).when(aaiProducerTask).resolveClient();
+ }
+
@Test
void whenPassedObjectDoesntFit_ThrowsPrhTaskException() {
//given/when/
@@ -106,7 +117,6 @@ class AaiProducerTaskImplTest {
}
-
@Test
void whenPassedObjectFits_butIncorrectResponseReturns() throws PrhTaskException {
//given/when
@@ -117,15 +127,4 @@ class AaiProducerTaskImplTest {
verify(aaiProducerReactiveHttpClient, times(1)).getAaiProducerResponse(any());
verifyNoMoreInteractions(aaiProducerReactiveHttpClient);
}
-
- private static void getAaiProducerTask_whenMockingResponseObject(Integer statusCode) {
- //given
- aaiProducerReactiveHttpClient = mock(AaiProducerReactiveHttpClient.class);
- when(aaiProducerReactiveHttpClient.getAaiProducerResponse(any()))
- .thenReturn(Mono.just(statusCode));
- when(appConfig.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration);
- aaiProducerTask = spy(new AaiProducerTaskImpl(appConfig));
- when(aaiProducerTask.resolveConfiguration()).thenReturn(aaiClientConfiguration);
- doReturn(aaiProducerReactiveHttpClient).when(aaiProducerTask).resolveClient();
- }
} \ No newline at end of file