summaryrefslogtreecommitdiffstats
path: root/datafile-app-server/src/test/java
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2019-01-07 13:48:18 +0100
committerelinuxhenrik <henrik.b.andersson@est.tech>2019-01-25 14:04:43 +0100
commit8a84a9d39fe71984bd5d861e8c865e748ca3df30 (patch)
tree76e50367dffde229a5f2bc427f3544bf60002d3a /datafile-app-server/src/test/java
parenta224b4adbe65b476cdbd74efb3169aacbf292382 (diff)
Integration with SDK
* New fields added to DmaapPublisherConfiguraion * New fields added to DmaapConsumerConfiguration * Dmaap Consumer web client replaced by SDK's consumer web client * UTs aligned * Disable enforcer plugin in DFC * Update oparent to 1.2.1 Change-Id: I3569180c15227bc2c8df74fd070571b0aa56fa04 Issue-ID: DCAEGEN2-1096 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'datafile-app-server/src/test/java')
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParserTest.java28
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfigTest.java10
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImplTest.java27
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImplTest.java10
4 files changed, 55 insertions, 20 deletions
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParserTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParserTest.java
index 119224b4..2e6b63b8 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParserTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/CloudConfigParserTest.java
@@ -21,24 +21,32 @@ import static org.assertj.core.api.Assertions.assertThat;
import com.google.gson.JsonObject;
import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapPublisherConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration;
+
class CloudConfigParserTest {
private static final ImmutableDmaapConsumerConfiguration CORRECT_DMAAP_CONSUMER_CONFIG =
- new ImmutableDmaapConsumerConfiguration.Builder().timeoutMS(-1)
+ new ImmutableDmaapConsumerConfiguration.Builder().timeoutMs(-1)
.dmaapHostName("message-router.onap.svc.cluster.local").dmaapUserName("admin")
.dmaapUserPassword("admin").dmaapTopicName("/events/unauthenticated.VES_NOTIFICATION_OUTPUT")
.dmaapPortNumber(2222).dmaapContentType("application/json").messageLimit(-1).dmaapProtocol("http")
- .consumerId("C12").consumerGroup("OpenDCAE-c12").build();
+ .consumerId("C12").consumerGroup("OpenDCAE-c12").trustStorePath("trustStorePath")
+ .trustStorePasswordPath("trustStorePasswordPath").keyStorePath("keyStorePath")
+ .keyStorePasswordPath("keyStorePasswordPath").enableDmaapCertAuth(true)
+ .build();
private static final ImmutableDmaapPublisherConfiguration CORRECT_DMAAP_PUBLISHER_CONFIG =
new ImmutableDmaapPublisherConfiguration.Builder().dmaapTopicName("publish").dmaapUserPassword("dradmin")
.dmaapPortNumber(3907).dmaapProtocol("https").dmaapContentType("application/json")
- .dmaapHostName("message-router.onap.svc.cluster.local").dmaapUserName("dradmin").build();
+ .dmaapHostName("message-router.onap.svc.cluster.local").dmaapUserName("dradmin")
+ .trustStorePath("trustStorePath")
+ .trustStorePasswordPath("trustStorePasswordPath").keyStorePath("keyStorePath")
+ .keyStorePasswordPath("keyStorePasswordPath").enableDmaapCertAuth(true)
+ .build();
private static final ImmutableFtpesConfig CORRECT_FTPES_CONFIGURATION =
new ImmutableFtpesConfig.Builder().keyCert("/config/ftpKey.jks").keyPassword("secret")
@@ -96,6 +104,12 @@ class CloudConfigParserTest {
config.addProperty("dmaap.ftpesConfig.trustedCA", "config/cacerts");
config.addProperty("dmaap.ftpesConfig.trustedCAPassword", "secret");
+ config.addProperty("dmaap.security.trustStorePath", "trustStorePath");
+ config.addProperty("dmaap.security.trustStorePasswordPath", "trustStorePasswordPath");
+ config.addProperty("dmaap.security.keyStorePath", "keyStorePath");
+ config.addProperty("dmaap.security.keyStorePasswordPath", "keyStorePasswordPath");
+ config.addProperty("dmaap.security.enableDmaapCertAuth", "true");
+
return config;
}
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfigTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfigTest.java
index 1238a472..62302793 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfigTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfigTest.java
@@ -176,7 +176,7 @@ class DatafileAppConfigTest {
dmaapConsumerConfigData.addProperty("dmaapContentType", "application/json");
dmaapConsumerConfigData.addProperty("consumerId", "C12");
dmaapConsumerConfigData.addProperty("consumerGroup", "OpenDcae-c12");
- dmaapConsumerConfigData.addProperty("timeoutMS", -1);
+ dmaapConsumerConfigData.addProperty("timeoutMs", -1);
dmaapConsumerConfigData.addProperty("messageLimit", 1);
JsonObject dmaapProducerConfigData = new JsonObject();
@@ -200,12 +200,20 @@ class DatafileAppConfigTest {
ftpesConfigData.addProperty("trustedCA", "config/cacerts");
ftpesConfigData.addProperty("trustedCAPassword", "secret");
+ JsonObject security = new JsonObject();
+ security.addProperty("trustStorePath", "trustStorePath");
+ security.addProperty("trustStorePasswordPath", "trustStorePasswordPath");
+ security.addProperty("keyStorePath", "keyStorePath");
+ security.addProperty("keyStorePasswordPath", "keyStorePasswordPath");
+ security.addProperty("enableDmaapCertAuth", "enableDmaapCertAuth");
+
JsonObject ftpesConfiguration = new JsonObject();
ftpesConfiguration.add("ftpesConfiguration", ftpesConfigData);
JsonObject configs = new JsonObject();
configs.add("dmaap", dmaapConfigs);
configs.add("ftp", ftpesConfiguration);
+ configs.add("security", security);
JsonObject completeJson = new JsonObject();
completeJson.add("configs", configs);
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImplTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImplTest.java
index c6d115f6..f8f6cf64 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImplTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImplTest.java
@@ -29,8 +29,7 @@ import java.util.List;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
+
import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapEmptyResponseException;
@@ -41,10 +40,13 @@ import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
import org.onap.dcaegen2.collectors.datafile.model.ImmutableFileData;
import org.onap.dcaegen2.collectors.datafile.model.ImmutableFileMetaData;
import org.onap.dcaegen2.collectors.datafile.service.DmaapConsumerJsonParser;
-import org.onap.dcaegen2.collectors.datafile.service.consumer.DmaapConsumerReactiveHttpClient;
+
import org.onap.dcaegen2.collectors.datafile.utils.JsonMessage;
import org.onap.dcaegen2.collectors.datafile.utils.JsonMessage.AdditionalField;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.service.consumer.DMaaPConsumerReactiveHttpClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -81,7 +83,7 @@ class DmaapConsumerTaskImplTest {
private static AppConfig appConfig;
private static DmaapConsumerConfiguration dmaapConsumerConfiguration;
private DmaapConsumerTaskImpl dmaapConsumerTask;
- private DmaapConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient;
+ private DMaaPConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient;
private static String ftpesMessage;
private static FileData ftpesFileData;
@@ -101,8 +103,13 @@ class DmaapConsumerTaskImplTest {
.dmaapUserName("Datafile")
.dmaapUserPassword("Datafile")
.dmaapTopicName("unauthenticated.NOTIFICATION")
- .timeoutMS(-1)
+ .timeoutMs(-1)
.messageLimit(-1)
+ .trustStorePath("trustStorePath")
+ .trustStorePasswordPath("trustStorePasswordPath")
+ .keyStorePath("keyStorePath")
+ .keyStorePasswordPath("keyStorePasswordPath")
+ .enableDmaapCertAuth(true)
.build();
appConfig = mock(AppConfig.class);
@@ -191,7 +198,7 @@ class DmaapConsumerTaskImplTest {
StepVerifier.create(dmaapConsumerTask.execute("Sample input")).expectSubscription()
.expectError(DmaapEmptyResponseException.class).verify();
- verify(dmaapConsumerReactiveHttpClient, times(1)).getDmaapConsumerResponse();
+ verify(dmaapConsumerReactiveHttpClient, times(1)).getDMaaPConsumerResponse();
}
@Test
@@ -200,7 +207,7 @@ class DmaapConsumerTaskImplTest {
StepVerifier.create(dmaapConsumerTask.execute(ftpesMessage)).expectNext(ftpesFileData).verifyComplete();
- verify(dmaapConsumerReactiveHttpClient, times(1)).getDmaapConsumerResponse();
+ verify(dmaapConsumerReactiveHttpClient, times(1)).getDMaaPConsumerResponse();
verifyNoMoreInteractions(dmaapConsumerReactiveHttpClient);
}
@@ -210,15 +217,15 @@ class DmaapConsumerTaskImplTest {
StepVerifier.create(dmaapConsumerTask.execute(ftpesMessage)).expectNext(sftpFileData).verifyComplete();
- verify(dmaapConsumerReactiveHttpClient, times(1)).getDmaapConsumerResponse();
+ verify(dmaapConsumerReactiveHttpClient, times(1)).getDMaaPConsumerResponse();
verifyNoMoreInteractions(dmaapConsumerReactiveHttpClient);
}
private void prepareMocksForDmaapConsumer(String message, FileData fileDataAfterConsume) {
Mono<String> messageAsMono = Mono.just(message);
DmaapConsumerJsonParser dmaapConsumerJsonParserMock = mock(DmaapConsumerJsonParser.class);
- dmaapConsumerReactiveHttpClient = mock(DmaapConsumerReactiveHttpClient.class);
- when(dmaapConsumerReactiveHttpClient.getDmaapConsumerResponse()).thenReturn(messageAsMono);
+ dmaapConsumerReactiveHttpClient = mock(DMaaPConsumerReactiveHttpClient.class);
+ when(dmaapConsumerReactiveHttpClient.getDMaaPConsumerResponse()).thenReturn(messageAsMono);
if (!message.isEmpty()) {
when(dmaapConsumerJsonParserMock.getJsonObject(messageAsMono)).thenReturn(Flux.just(fileDataAfterConsume));
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImplTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImplTest.java
index 7770eec4..5b29bf10 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImplTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImplTest.java
@@ -27,12 +27,13 @@ import static org.mockito.Mockito.when;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapPublisherConfiguration;
+
import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
import org.onap.dcaegen2.collectors.datafile.service.producer.DmaapProducerReactiveHttpClient;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration;
import org.springframework.http.HttpStatus;
import reactor.core.publisher.Flux;
@@ -68,6 +69,11 @@ class DmaapPublisherTaskImplTest {
.dmaapUserName("DFC")
.dmaapUserPassword("DFC")
.dmaapTopicName("unauthenticated.VES_NOTIFICATION_OUTPUT")
+ .trustStorePath("trustStorePath")
+ .trustStorePasswordPath("trustStorePasswordPath")
+ .keyStorePath("keyStorePath")
+ .keyStorePasswordPath("keyStorePasswordPath")
+ .enableDmaapCertAuth(true)
.build();
consumerDmaapModel = ImmutableConsumerDmaapModel.builder()
.productName(PRODUCT_NAME)