aboutsummaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'prh-app-server/src/test')
-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
-rw-r--r--prh-app-server/src/test/resources/logback-test.xml4
-rw-r--r--prh-app-server/src/test/resources/prh_endpoints.json2
5 files changed, 59 insertions, 55 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
diff --git a/prh-app-server/src/test/resources/logback-test.xml b/prh-app-server/src/test/resources/logback-test.xml
index 0a53315a..9c161fe3 100644
--- a/prh-app-server/src/test/resources/logback-test.xml
+++ b/prh-app-server/src/test/resources/logback-test.xml
@@ -18,8 +18,8 @@
-->
<configuration debug="false">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
- <logger name="org.onap.dcaegen2.services.prh" level="DEBUG"/>
- <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
+ <logger level="DEBUG" name="org.onap.dcaegen2.services.prh"/>
+ <appender class="ch.qos.logback.core.ConsoleAppender" name="Console">
<encoder>
<pattern>%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n</pattern>
</encoder>
diff --git a/prh-app-server/src/test/resources/prh_endpoints.json b/prh-app-server/src/test/resources/prh_endpoints.json
index e088e2ae..07e87c67 100644
--- a/prh-app-server/src/test/resources/prh_endpoints.json
+++ b/prh-app-server/src/test/resources/prh_endpoints.json
@@ -15,7 +15,7 @@
"X-TransactionId": "9999",
"Accept": "application/json",
"Real-Time": "true",
- "Content-Type":"application/merge-patch+json"
+ "Content-Type": "application/merge-patch+json"
}
}
},