summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorelinuxhenrik <henrik.b.andersson@est.tech>2018-09-14 15:49:10 +0200
committerelinuxhenrik <henrik.b.andersson@est.tech>2018-09-17 08:06:07 +0200
commitf394594ec70aaf1eefa4f23b80226c3426dbc17a (patch)
tree89e280889259b11c2651b06fb55d679cf5faf410
parent7ceca5db40ff6cbd88c95fe335a6a6e582189066 (diff)
Deliver first version of Datafile
Change-Id: Iadd1455d7fe45b4c022dd7fde2f8a506d1b7cd57 Issue-ID: DCAEGEN2-640 Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
-rw-r--r--.gitignore10
-rw-r--r--INFO.yaml41
-rw-r--r--LICENSE.txt3
-rw-r--r--datafile-aai-client/pom.xml130
-rw-r--r--datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/AaiClientConfiguration.java67
-rw-r--r--datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/AaiRequestException.java28
-rw-r--r--datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiClientImpl.java94
-rw-r--r--datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiConsumerClient.java140
-rw-r--r--datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiReactiveWebClient.java85
-rw-r--r--datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/AaiProducerReactiveHttpClient.java99
-rw-r--r--datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/AaiConsumerClientTest.java95
-rw-r--r--datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/AaiHttpClientImplTest.java55
-rw-r--r--datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/AaiProducerReactiveHttpClientTest.java142
-rw-r--r--datafile-app-server/config/application.yaml6
-rw-r--r--datafile-app-server/config/datafile_endpoints.json28
-rw-r--r--datafile-app-server/config/prh_endpoints.json47
-rw-r--r--datafile-app-server/pom.xml212
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/MainApp.java19
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java103
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/Config.java16
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfig.java50
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java41
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SwaggerConfig.java81
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/TomcatHttpConfig.java55
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/HeartbeatController.java45
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleController.java20
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/AaiNotFoundException.java31
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java12
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapEmptyResponseException.java10
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapNotFoundException.java10
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollector.java117
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileServerData.java31
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java117
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClient.java98
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParser.java179
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/FileData.java (renamed from datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiExtendedHttpClient.java)34
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTask.java36
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskImpl.java78
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTask.java49
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTaskImpl.java89
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTask.java28
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImpl.java72
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTask.java43
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImpl.java62
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java50
-rw-r--r--datafile-app-server/src/main/resources/application.properties5
-rw-r--r--datafile-app-server/src/main/resources/keystore.jksbin2643 -> 2627 bytes
-rw-r--r--datafile-app-server/src/main/resources/keystore.jks.oldbin2272 -> 0 bytes
-rw-r--r--datafile-app-server/src/main/resources/logback-spring.xml16
-rw-r--r--datafile-app-server/src/main/resources/scheduled-context.xml24
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfigTest.java144
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectorTest.java116
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpClientTest.java57
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClientTest.java103
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ScheduledXmlContextITest.java14
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ServiceMockProvider.java2
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/junit5/mockito/MockitoExtension.java17
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParserTest.java349
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskImplTest.java149
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskSpy.java50
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTaskImplTest.java133
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiPublisherTaskSpy.java58
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImplTest.java220
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskSpy.java59
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapProducerTaskSpy.java59
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImplTest.java94
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduleControllerSpy.java54
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java204
-rw-r--r--datafile-app-server/src/test/resources/datafile_endpoints.json69
-rw-r--r--datafile-commons/pom.xml29
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java36
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java49
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelForUnitTest.java66
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtils.java10
-rw-r--r--datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java37
-rw-r--r--datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelTest.java57
-rw-r--r--datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtilsTest.java20
-rw-r--r--datafile-dmaap-client/pom.xml54
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java21
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java10
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java17
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClient.java (renamed from datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DMaaPReactiveWebClient.java)20
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/HttpUtils.java (renamed from datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiClient.java)23
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClient.java (renamed from datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DMaaPConsumerReactiveHttpClient.java)26
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DMaaPProducerReactiveHttpClient.java96
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java151
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DMaaPReactiveWebClientTest.java58
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java34
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java27
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java (renamed from datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DMaaPConsumerReactiveHttpClientTest.java)35
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DMaaPProducerReactiveHttpClientTest.java121
-rw-r--r--datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java129
-rw-r--r--pom.xml486
-rw-r--r--swagger.yaml10
-rw-r--r--version.properties12
95 files changed, 2451 insertions, 4037 deletions
diff --git a/.gitignore b/.gitignore
index 37f2c431..d03f9a95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,12 @@ hs_err_pid*
.idea
*.iml
+# Eclipse IDE
+.project
+.classpath
+.settings
+bin
+
# Maven
target
target/
@@ -40,4 +46,6 @@ buildNumber.properties
.mvn/wrapper/maven-wrapper.jar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid* \ No newline at end of file
+hs_err_pid*
+
+opt/ \ No newline at end of file
diff --git a/INFO.yaml b/INFO.yaml
deleted file mode 100644
index 72719384..00000000
--- a/INFO.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
----
-project: 'dcaegen2-collectors-datafile'
-project_creation_date: '2018-01-31'
-project_category: ''
-lifecycle_state: 'Incubation'
-project_lead: &onap_dcaegen2_ptl
- name: 'Vijay Venkatesh Kumar'
- email: 'vv770d@att.com'
- id: 'vv770d'
- company: 'ATT'
- timezone: 'America/New_York'
-primary_contact: *onap_dcaegen2_ptl
-issue_tracking:
- type: 'jira'
- url: 'https://jira.onap.org/projects/DCAEGEN2'
- key: 'DCAEGEN2'
-mailing_list:
- type: 'groups.io'
- url: 'lists.onap.org'
- tag: '<[sub-project_name]>'
-realtime_discussion: ''
-meetings:
- - type: 'zoom'
- agenda: 'https://wiki.onap.org/display/DW/DCAE+Project+Meetings'
- url: 'https://wiki.onap.org/pages/viewpage.action?pageId=6593119'
- server: 'n/a'
- channel: 'n/a'
- repeats: 'weekly'
- time: '13:00 UTC (DST), 15:30 UTC (post DST)'
-repositories:
- - 'dcaegen2-collectors-hv-ves'
- - 'dcaegen2-collectors-datafile'
-committers:
- - <<: *onap_dcaegen2_ptl
- - name: 'Lusheng Ji'
- email: 'lji@research.att.com'
- company: 'ATT'
- id: 'wrider'
- timezone: 'America/New_York'
-tsc:
- approval: 'https://lists.onap.org/pipermail/onap-tsc'
diff --git a/LICENSE.txt b/LICENSE.txt
index 22e7ef85..b0ebcb6e 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,7 +1,6 @@
/*
* ============LICENSE_START==========================================
-* ===================================================================
-* Copyright (c) 2018 NOKIA Intellectual Property. All rights reserved.
+* Copyright (c) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
diff --git a/datafile-aai-client/pom.xml b/datafile-aai-client/pom.xml
deleted file mode 100644
index bc496562..00000000
--- a/datafile-aai-client/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ ============LICENSE_START=======================================================
- ~ Datafile Collector Service
- ~ ================================================================================
- ~ 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=========================================================
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>datafile</artifactId>
- <groupId>org.onap.dcaegen2.collectors</groupId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>datafile-aai-client</artifactId>
- <groupId>org.onap.dcaegen2.collectors.datafile</groupId>
- <packaging>jar</packaging>
-
-
- <properties>
- <main.basedir>${project.parent.basedir}</main.basedir>
- </properties>
- <dependencies>
-
- <!-- DEVELOPMENT DEPENDENCIES -->
- <dependency>
- <groupId>org.immutables</groupId>
- <artifactId>value</artifactId>
- </dependency>
- <dependency>
- <groupId>org.immutables</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webflux</artifactId>
- <version>5.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-reactor-netty</artifactId>
- <version>2.0.4.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.onap.dcaegen2.collectors.datafile</groupId>
- <artifactId>datafile-commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
-
- <!-- LOGGING DEPENDENCIES-->
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- </dependency>
-
- <!-- TEST DEPENDENCIES-->
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/AaiClientConfiguration.java b/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/AaiClientConfiguration.java
deleted file mode 100644
index ce77599a..00000000
--- a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/AaiClientConfiguration.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.config;
-
-import java.io.Serializable;
-
-import java.util.Map;
-
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-import org.springframework.stereotype.Component;
-
-
-@Component
-@Value.Immutable(prehash = true)
-@Value.Style(builder = "new")
-@Gson.TypeAdapters
-public abstract class AaiClientConfiguration implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Value.Parameter
- public abstract String aaiHost();
-
- @Value.Parameter
- public abstract Integer aaiPort();
-
- @Value.Parameter
- public abstract String aaiProtocol();
-
- @Value.Parameter
- public abstract String aaiUserName();
-
- @Value.Parameter
- public abstract String aaiUserPassword();
-
- @Value.Parameter
- public abstract Boolean aaiIgnoreSslCertificateErrors();
-
- @Value.Parameter
- public abstract String aaiBasePath();
-
- @Value.Parameter
- public abstract String aaiPnfPath();
-
- @Value.Parameter
- public abstract Map<String, String> aaiHeaders();
-
-}
diff --git a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/AaiRequestException.java b/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/AaiRequestException.java
deleted file mode 100644
index a30867a2..00000000
--- a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/AaiRequestException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.exceptions;
-
-public class AaiRequestException extends Exception {
-
- public AaiRequestException(String message) {
- super(message);
- }
-}
diff --git a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiClientImpl.java b/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiClientImpl.java
deleted file mode 100644
index 8af4a13a..00000000
--- a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiClientImpl.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service;
-
-import java.security.KeyManagementException;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContextBuilder;
-import org.apache.http.ssl.TrustStrategy;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.service.AaiClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class AaiClientImpl implements AaiClient {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private AaiClientConfiguration aaiClientConfig;
-
-
- AaiClientImpl(AaiClientConfiguration aaiClientConfiguration) {
- this.aaiClientConfig = aaiClientConfiguration;
- }
-
- @Override
- public CloseableHttpClient getAaiHttpClient() {
-
- final HttpClientBuilder httpClientBuilder = HttpClients.custom().useSystemProperties();
- final boolean aaiIgnoreSslCertificateErrors = aaiClientConfig.aaiIgnoreSslCertificateErrors();
-
- TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
-
- if (aaiIgnoreSslCertificateErrors) {
- try {
- logger.info("Setting SSL Context for AAI HTTP Client");
- httpClientBuilder.setSSLContext(new SSLContextBuilder()
- .loadTrustMaterial(null, acceptingTrustStrategy)
- .build());
-
- } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
- logger.error("Exception while setting SSL Context for AAI HTTP Client: {}", e);
- }
-
- httpClientBuilder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
- }
-
- final String aaiUserName = aaiClientConfig.aaiUserName();
-
- final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-
- if (aaiUserName != null) {
- final String aaiHost = aaiClientConfig.aaiHost();
- final Integer aaiHostPortNumber = aaiClientConfig.aaiPort();
- final String aaiUserPassword = aaiClientConfig.aaiUserPassword();
- final AuthScope aaiHostPortAuthScope = new AuthScope(aaiHost, aaiHostPortNumber);
- final Credentials aaiCredentials = new UsernamePasswordCredentials(aaiUserName, aaiUserPassword);
- credentialsProvider.setCredentials(aaiHostPortAuthScope, aaiCredentials);
- }
-
- httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
-
- return httpClientBuilder.build();
- }
-}
diff --git a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiConsumerClient.java b/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiConsumerClient.java
deleted file mode 100644
index ecc9ed2c..00000000
--- a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiConsumerClient.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.util.EntityUtils;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.model.utils.HttpUtils;
-import org.onap.dcaegen2.collectors.datafile.service.AaiClientImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class AaiConsumerClient {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final CloseableHttpClient closeableHttpClient;
- private final String aaiHost;
- private final String aaiProtocol;
- private final Integer aaiHostPortNumber;
- private final String aaiPath;
- private final Map<String, String> aaiHeaders;
-
- /**
- * A{@literal &}AI client for consuming data from A{@literal &}AI.
- *
- * @param aaiClientConfiguration - A{@literal &}AI client config
- */
- public AaiConsumerClient(AaiClientConfiguration aaiClientConfiguration) {
- closeableHttpClient = new AaiClientImpl(aaiClientConfiguration).getAaiHttpClient();
- aaiHost = aaiClientConfiguration.aaiHost();
- aaiProtocol = aaiClientConfiguration.aaiProtocol();
- aaiHostPortNumber = aaiClientConfiguration.aaiPort();
- aaiPath = aaiClientConfiguration.aaiBasePath() + aaiClientConfiguration.aaiPnfPath();
- aaiHeaders = aaiClientConfiguration.aaiHeaders();
- }
-
- /**
- * Function which call http client for getting object from A{@literal &}AI.
- *
- * @param consumerDmaapModel - helper object for uri generation
- * @return - status code of operation
- * @throws IOException - Apache HTTP client exception
- */
- public Optional<String> getHttpResponse(ConsumerDmaapModel consumerDmaapModel) throws IOException {
- Optional<HttpRequestBase> request = createRequest(consumerDmaapModel);
- try {
- return closeableHttpClient.execute(request.get(), aaiResponseHandler());
- } catch (IOException e) {
- logger.warn("Exception while executing http client: ", e);
- throw new IOException();
- }
- }
-
- private URI createAaiExtendedUri(String pnfName) {
-
- URI extendedUri = null;
-
- final URIBuilder uriBuilder = new URIBuilder()
- .setScheme(aaiProtocol)
- .setHost(aaiHost)
- .setPort(aaiHostPortNumber)
- .setPath(aaiPath + "/" + pnfName);
-
- try {
- extendedUri = uriBuilder.build();
- logger.trace("Building extended URI: {}", extendedUri);
- } catch (URISyntaxException e) {
- logger.warn("Exception while building extended URI: {}", e);
- }
-
- return extendedUri;
- }
-
- private ResponseHandler<Optional<String>> aaiResponseHandler() {
- return httpResponse -> {
- final int responseCode = httpResponse.getStatusLine().getStatusCode();
- logger.info("Status code of operation: {}", responseCode);
- final HttpEntity responseEntity = httpResponse.getEntity();
-
- if (HttpUtils.isSuccessfulResponseCode(responseCode)) {
- logger.trace("HTTP response successful.");
- final String aaiResponse = EntityUtils.toString(responseEntity);
- return Optional.of(aaiResponse);
- } else {
- String aaiResponse = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
- logger.warn("HTTP response not successful : {}", aaiResponse);
- return Optional.of(String.valueOf(responseCode));
- }
- };
- }
-
- private HttpRequestBase createHttpRequest(URI extendedUri) {
- return isExtendedUriNotNull(extendedUri) ? new HttpGet(extendedUri) : null;
- }
-
- private Boolean isExtendedUriNotNull(URI extendedUri) {
- return extendedUri != null;
- }
-
- private Optional<HttpRequestBase> createRequest(ConsumerDmaapModel consumerDmaapModel) {
- final URI extendedUri = createAaiExtendedUri(consumerDmaapModel.getPnfName());
- HttpRequestBase request = createHttpRequest(extendedUri);
- aaiHeaders.forEach(Objects.requireNonNull(request)::addHeader);
- Objects.requireNonNull(request).addHeader("Content-Type", "application/json");
- return Optional.of(request);
- }
-}
diff --git a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiReactiveWebClient.java b/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiReactiveWebClient.java
deleted file mode 100644
index 9a9ff27e..00000000
--- a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiReactiveWebClient.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service;
-
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-
-import java.util.Map;
-
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.service.AaiReactiveWebClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
-import org.springframework.web.reactive.function.client.WebClient;
-import reactor.core.publisher.Mono;
-
-
-public class AaiReactiveWebClient {
-
- private Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private String aaiUserName;
- private String aaiUserPassword;
- private Map<String, String> aaiHeaders;
-
- /**
- * Creating AaiReactiveWebClient.
- * @param configuration - configuration object
- * @return AaiReactiveWebClient
- */
- public AaiReactiveWebClient fromConfiguration(AaiClientConfiguration configuration) {
- this.aaiUserName = configuration.aaiUserName();
- this.aaiUserPassword = configuration.aaiUserPassword();
- this.aaiHeaders = configuration.aaiHeaders();
- return this;
- }
-
- /**
- * Construct Reactive WebClient with appropriate settings.
- *
- * @return WebClient
- */
- public WebClient build() {
- return WebClient.builder()
- .defaultHeaders(httpHeaders -> httpHeaders.setAll(aaiHeaders))
- .filter(basicAuthentication(aaiUserName, aaiUserPassword))
- .filter(logRequest())
- .filter(logResponse())
- .build();
- }
-
- private ExchangeFilterFunction logRequest() {
- return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
- logger.info("Request: {} {}", clientRequest.method(), clientRequest.url());
- clientRequest.headers()
- .forEach((name, values) -> values.forEach(value -> logger.info("{}={}",name, value)));
- return Mono.just(clientRequest);
- });
- }
-
- private ExchangeFilterFunction logResponse() {
- return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> {
- logger.info("Response Status {}", clientResponse.statusCode());
- return Mono.just(clientResponse);
- });
- }
-}
diff --git a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/AaiProducerReactiveHttpClient.java b/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/AaiProducerReactiveHttpClient.java
deleted file mode 100644
index 65ae40b8..00000000
--- a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/AaiProducerReactiveHttpClient.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service.producer;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.http.client.utils.URIBuilder;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.exceptions.AaiRequestException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.producer.AaiProducerReactiveHttpClient;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.client.WebClient;
-import reactor.core.publisher.Mono;
-
-
-public class AaiProducerReactiveHttpClient {
-
- private WebClient webClient;
- private final String aaiHost;
- private final String aaiProtocol;
- private final Integer aaiHostPortNumber;
- private final String aaiBasePath;
-
-
- /**
- * Constructor of AaiProducerReactiveHttpClient.
- *
- * @param configuration - AAI producer configuration object
- */
- public AaiProducerReactiveHttpClient(AaiClientConfiguration configuration) {
- this.aaiHost = configuration.aaiHost();
- this.aaiProtocol = configuration.aaiProtocol();
- this.aaiHostPortNumber = configuration.aaiPort();
- this.aaiBasePath = configuration.aaiBasePath();
- }
-
- /**
- * Function for calling AAI Http producer - patch request to AAI database.
- *
- * @param consumerDmaapModelMono - object which will be sent to AAI database
- * @return status code of operation
- */
- public Mono<Integer> getAaiProducerResponse(Mono<ConsumerDmaapModel> consumerDmaapModelMono) {
- return consumerDmaapModelMono.flatMap(this::patchAaiRequest);
- }
-
- public AaiProducerReactiveHttpClient createAaiWebClient(WebClient webClient) {
- this.webClient = webClient;
- return this;
- }
-
- private Mono<Integer> patchAaiRequest(ConsumerDmaapModel dmaapModel) {
- try {
- return webClient.patch()
- .uri(getUri(dmaapModel.getPnfName()))
- .body(BodyInserters.fromObject(dmaapModel))
- .retrieve()
- .onStatus(
- HttpStatus::is4xxClientError,
- clientResponse -> Mono.error(new AaiRequestException("HTTP 400"))
- )
- .onStatus(HttpStatus::is5xxServerError,
- clientResponse -> Mono.error(new AaiRequestException("HTTP 500")))
- .bodyToMono(Integer.class);
- } catch (URISyntaxException e) {
- return Mono.error(e);
- }
- }
-
- URI getUri(String pnfName) throws URISyntaxException {
- return new URIBuilder()
- .setScheme(aaiProtocol)
- .setHost(aaiHost)
- .setPort(aaiHostPortNumber)
- .setPath(aaiBasePath + "/" + pnfName)
- .build();
- }
-}
diff --git a/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/AaiConsumerClientTest.java b/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/AaiConsumerClientTest.java
deleted file mode 100644
index 719418fb..00000000
--- a/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/AaiConsumerClientTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.AaiConsumerClient;
-
-class AaiConsumerClientTest {
-
- private static AaiConsumerClient testedObject;
- private static AaiClientConfiguration aaiHttpClientConfigurationMock = mock(AaiClientConfiguration.class);
- private static CloseableHttpClient closeableHttpClientMock = mock(CloseableHttpClient.class);
- private static final String JSON_MESSAGE = "{ \"pnf-id\": \"example-pnf-id-val-22343\", "
- + "\"regional-resource-zone\":null, \"ipaddress-v4-oam\": \"11.22.33.44\" }";
- private static ConsumerDmaapModel consumerDmaapModelMock = mock(ConsumerDmaapModel.class);
- private static final String PNF_NAME = "nokia-pnf-nhfsadhff";
-
- @BeforeAll
- static void setup() throws NoSuchFieldException, IllegalAccessException {
-
- Map<String, String> aaiHeaders = new HashMap<>();
- aaiHeaders.put("X-FromAppId", "datafile");
- aaiHeaders.put("X-TransactionId", "9999");
- aaiHeaders.put("Accept", "application/json");
- aaiHeaders.put("Authorization", "Basic QUFJOkFBSQ==");
- aaiHeaders.put("Real-Time", "true");
- aaiHeaders.put("Content-Type", "application/json");
-
- when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("54.45.33.2");
- when(aaiHttpClientConfigurationMock.aaiProtocol()).thenReturn("https");
- when(aaiHttpClientConfigurationMock.aaiPort()).thenReturn(1234);
- when(aaiHttpClientConfigurationMock.aaiUserName()).thenReturn("Datafile");
- when(aaiHttpClientConfigurationMock.aaiUserPassword()).thenReturn("Datafile");
- when(aaiHttpClientConfigurationMock.aaiBasePath()).thenReturn("/aai/v11");
- when(aaiHttpClientConfigurationMock.aaiPnfPath()).thenReturn("/network/pnfs/pnf");
- when(aaiHttpClientConfigurationMock.aaiHeaders()).thenReturn(aaiHeaders);
-
- when(consumerDmaapModelMock.getPnfName()).thenReturn(PNF_NAME);
-
- testedObject = new AaiConsumerClient(aaiHttpClientConfigurationMock);
- setField();
- }
-
-
- @Test
- void getExtendedDetails_returnsSuccess() throws IOException {
-
- when(closeableHttpClientMock.execute(any(HttpGet.class), any(ResponseHandler.class)))
- .thenReturn(Optional.of(JSON_MESSAGE));
- Optional<String> actualResult = testedObject.getHttpResponse(consumerDmaapModelMock);
- Assertions.assertEquals(Optional.of(JSON_MESSAGE), actualResult);
- }
-
-
- private static void setField() throws NoSuchFieldException, IllegalAccessException {
- Field field = testedObject.getClass().getDeclaredField("closeableHttpClient");
- field.setAccessible(true);
- field.set(testedObject, closeableHttpClientMock);
- }
-}
diff --git a/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/AaiHttpClientImplTest.java b/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/AaiHttpClientImplTest.java
deleted file mode 100644
index dcf29549..00000000
--- a/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/AaiHttpClientImplTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-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.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.service.AaiClientImpl;
-
-class AaiHttpClientImplTest {
-
- private static AaiClientImpl testedObject;
-
-
- @BeforeAll
- public static void setup() {
- AaiClientConfiguration aaiHttpClientConfigurationMock = mock(AaiClientConfiguration.class);
- when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("54.45.33.2");
- when(aaiHttpClientConfigurationMock.aaiProtocol()).thenReturn("https");
- when(aaiHttpClientConfigurationMock.aaiPort()).thenReturn(1234);
- when(aaiHttpClientConfigurationMock.aaiUserName()).thenReturn("PNF");
- when(aaiHttpClientConfigurationMock.aaiUserPassword()).thenReturn("PNF");
- when(aaiHttpClientConfigurationMock.aaiIgnoreSslCertificateErrors()).thenReturn(true);
-
- testedObject = new AaiClientImpl(aaiHttpClientConfigurationMock);
- }
-
- @Test
- public void getAaiHttpClientObject_shouldNotBeNull() {
- assertNotNull(testedObject.getAaiHttpClient());
- }
-}
-
diff --git a/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/AaiProducerReactiveHttpClientTest.java b/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/AaiProducerReactiveHttpClientTest.java
deleted file mode 100644
index 65f13553..00000000
--- a/datafile-aai-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/AaiProducerReactiveHttpClientTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service.producer;
-
-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.when;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModelForUnitTest;
-import org.onap.dcaegen2.collectors.datafile.service.producer.AaiProducerReactiveHttpClient;
-import org.springframework.web.reactive.function.client.WebClient;
-import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-
-class AaiProducerReactiveHttpClientTest {
-
- private static AaiProducerReactiveHttpClient aaiProducerReactiveHttpClient;
-
- private static final Integer SUCCESS_RESPONSE = 200;
-
- private static AaiClientConfiguration aaiConfigurationMock = mock(AaiClientConfiguration.class);
- private static WebClient webClient = mock(WebClient.class);
-
- private static ConsumerDmaapModel dmaapModel = new ConsumerDmaapModelForUnitTest();
- private static WebClient.RequestBodyUriSpec requestBodyUriSpec;
- private static ResponseSpec responseSpec;
-
- private static Map<String, String> aaiHeaders;
-
- @BeforeAll
- static void setUp() {
- setupHeaders();
-
- when(aaiConfigurationMock.aaiHost()).thenReturn("54.45.33.2");
- when(aaiConfigurationMock.aaiProtocol()).thenReturn("https");
- when(aaiConfigurationMock.aaiPort()).thenReturn(1234);
- when(aaiConfigurationMock.aaiUserName()).thenReturn("Datafile");
- when(aaiConfigurationMock.aaiUserPassword()).thenReturn("Datafile");
- when(aaiConfigurationMock.aaiBasePath()).thenReturn("/aai/v11");
- when(aaiConfigurationMock.aaiPnfPath()).thenReturn("/network/pnfs/pnf");
- when(aaiConfigurationMock.aaiHeaders()).thenReturn(aaiHeaders);
-
- aaiProducerReactiveHttpClient = new AaiProducerReactiveHttpClient(aaiConfigurationMock);
-
- webClient = spy(WebClient.builder()
- .defaultHeaders(httpHeaders -> httpHeaders.setAll(aaiHeaders))
- .filter(basicAuthentication(aaiConfigurationMock.aaiUserName(), aaiConfigurationMock.aaiUserPassword()))
- .build());
-
- requestBodyUriSpec = mock(WebClient.RequestBodyUriSpec.class);
- responseSpec = mock(ResponseSpec.class);
- }
-
-
- @Test
- void getAaiProducerResponse_shouldReturn200() {
- //given
- Mono<Integer> expectedResult = Mono.just(SUCCESS_RESPONSE);
-
- //when
- mockWebClientDependantObject();
- doReturn(expectedResult).when(responseSpec).bodyToMono(Integer.class);
- aaiProducerReactiveHttpClient.createAaiWebClient(webClient);
- Mono<Integer> response = aaiProducerReactiveHttpClient.getAaiProducerResponse(Mono.just(dmaapModel));
-
- //then
- StepVerifier.create(response).expectSubscription()
- .expectNextMatches(results -> {
- Assertions.assertEquals(results, expectedResult.block());
- return true;
- }).verifyComplete();
- }
-
- @Test
- void getHttpResponse_whenUriSyntaxExceptionHasBeenThrown() throws URISyntaxException {
- ///given
- aaiProducerReactiveHttpClient = spy(aaiProducerReactiveHttpClient);
- //when
- when(webClient.patch()).thenReturn(requestBodyUriSpec);
- aaiProducerReactiveHttpClient.createAaiWebClient(webClient);
- when(aaiProducerReactiveHttpClient.getUri("pnfName")).thenThrow(URISyntaxException.class);
-
- //then
- StepVerifier.create(
- aaiProducerReactiveHttpClient.getAaiProducerResponse(
- Mono.just(dmaapModel)
- )).expectSubscription().expectError(Exception.class).verify();
- }
-
-
- private void mockWebClientDependantObject() {
- WebClient.RequestHeadersSpec requestHeadersSpec = mock(WebClient.RequestHeadersSpec.class);
- when(webClient.patch()).thenReturn(requestBodyUriSpec);
- when(requestBodyUriSpec.uri((URI) any())).thenReturn(requestBodyUriSpec);
- when(requestBodyUriSpec.body(any())).thenReturn(requestHeadersSpec);
- doReturn(responseSpec).when(requestHeadersSpec).retrieve();
- doReturn(responseSpec).when(responseSpec).onStatus(any(), any());
- }
-
- private static void setupHeaders() {
- aaiHeaders = new HashMap<>();
- aaiHeaders.put("X-FromAppId", "Datafile");
- aaiHeaders.put("X-TransactionId", "vv-temp");
- aaiHeaders.put("Accept", "application/json");
- aaiHeaders.put("Real-Time", "true");
- aaiHeaders.put("Content-Type", "application/merge-patch+json");
- }
-
-}
-
diff --git a/datafile-app-server/config/application.yaml b/datafile-app-server/config/application.yaml
index 6a792346..ca3160c7 100644
--- a/datafile-app-server/config/application.yaml
+++ b/datafile-app-server/config/application.yaml
@@ -1,15 +1,13 @@
spring:
profiles:
active: prod
- main:
- web-application-type: none
server:
port: 8433
ssl:
key-store-type: PKCS12
- key-store-password: nokiapnf
+ key-store-password: ericssondfc
key-store: classpath:keystore.jks
- key-password: nokiapnf
+ key-password: ericssondfc
keyAlias: tomcat-localhost
logging:
level:
diff --git a/datafile-app-server/config/datafile_endpoints.json b/datafile-app-server/config/datafile_endpoints.json
new file mode 100644
index 00000000..41f9b6d8
--- /dev/null
+++ b/datafile-app-server/config/datafile_endpoints.json
@@ -0,0 +1,28 @@
+{
+ "configs": {
+ "dmaap": {
+ "dmaapConsumerConfiguration": {
+ "dmaapHostName": "localhost",
+ "dmaapPortNumber": 3904,
+ "dmaapTopicName": "/events/unauthenticated.VES_NOTIFICATION_OUTPUT",
+ "dmaapProtocol": "http",
+ "dmaapUserName": "admin",
+ "dmaapUserPassword": "admin",
+ "dmaapContentType": "application/json",
+ "consumerId": "c12",
+ "consumerGroup": "OpenDcae-c12",
+ "timeoutMS": -1,
+ "messageLimit": 1
+ },
+ "dmaapProducerConfiguration": {
+ "dmaapHostName": "localhost",
+ "dmaapPortNumber": 3905,
+ "dmaapTopicName": "/events/unauthenticated.VES_NOTIFICATION_OUTPUT",
+ "dmaapProtocol": "http",
+ "dmaapUserName": "admin",
+ "dmaapUserPassword": "admin",
+ "dmaapContentType": "application/octet-stream"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/datafile-app-server/config/prh_endpoints.json b/datafile-app-server/config/prh_endpoints.json
deleted file mode 100644
index 772d9708..00000000
--- a/datafile-app-server/config/prh_endpoints.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "configs": {
- "dmaap": {
- "dmaapConsumerConfiguration": {
- "dmaapHostName": "localhost",
- "dmaapPortNumber": 2222,
- "dmaapTopicName": "/events/unauthenticated.SEC_OTHER_OUTPUT",
- "dmaapProtocol": "http",
- "dmaapUserName": "admin",
- "dmaapUserPassword": "admin",
- "dmaapContentType": "application/json",
- "consumerId": "c12",
- "consumerGroup": "OpenDcae-c12",
- "timeoutMS": -1,
- "messageLimit": 1
- },
- "dmaapProducerConfiguration": {
- "dmaapHostName": "localhost",
- "dmaapPortNumber": 2223,
- "dmaapTopicName": "/events/unauthenticated.PNF_READY",
- "dmaapProtocol": "http",
- "dmaapUserName": "admin",
- "dmaapUserPassword": "admin",
- "dmaapContentType": "application/json"
- }
- },
- "aai": {
- "aaiClientConfiguration": {
- "aaiHost": "localhost",
- "aaiPort": 8080,
- "aaiProtocol": "https",
- "aaiUserName": "AAI",
- "aaiUserPassword": "AAI",
- "aaiIgnoreSSLCertificateErrors": true,
- "aaiBasePath": "/aai/v12",
- "aaiPnfPath": "/network/pnfs/pnf",
- "aaiHeaders": {
- "X-FromAppId": "datafile",
- "X-TransactionId": "9999",
- "Accept": "application/json",
- "Real-Time": "true",
- "Content-Type":"application/merge-patch+json"
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/datafile-app-server/pom.xml b/datafile-app-server/pom.xml
index 84c9539b..339daeb4 100644
--- a/datafile-app-server/pom.xml
+++ b/datafile-app-server/pom.xml
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ ============LICENSE_START=======================================================
- ~ Datafile Collector Service
- ~ ================================================================================
- ~ Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- ~ ================================================================================
+ ~ Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ ~ 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,
@@ -22,54 +20,28 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>datafile</artifactId>
<groupId>org.onap.dcaegen2.collectors</groupId>
+ <artifactId>datafile</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>datafile-app-server</artifactId>
<groupId>org.onap.dcaegen2.collectors.datafile</groupId>
+ <artifactId>datafile-app-server</artifactId>
<packaging>jar</packaging>
+
<properties>
+ <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
- <project.fatJar.finalName>datafile-app-server</project.fatJar.finalName>
+ <project.fatJar.finalName>datafile-happ-server</project.fatJar.finalName>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<snapshots.path>content/repositories/snapshots/</snapshots.path>
<releases.path>content/repositories/releases/</releases.path>
- <docker.repo.url>${onap.nexus.dockerregistry.daily}</docker.repo.url>
- <nexus.staging>false</nexus.staging>
</properties>
+
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>custom-resources</id>
- <phase>process-resources</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/config</outputDirectory>
- <resources>
- <resource>
- <directory>${project.basedir}/config</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- <encoding>UTF-8</encoding>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
@@ -84,15 +56,15 @@
<mainClass>org.onap.dcaegen2.collectors.datafile.MainApp</mainClass>
</configuration>
</plugin>
- <!-- This plugin may go away in favor of a custom Dockerfile provided by Carsten and co. -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
- <skipDockerBuild>false</skipDockerBuild>
- <imageName>
- ${docker.repo.url}/onap/${project.groupId}.${project.artifactId}
- </imageName>
+ <serverId>${onap.nexus.dockerregistry.daily}</serverId>
+ <imageName>${docker.image.name}</imageName>
+ <imageTags>
+ <tag>latest</tag>
+ </imageTags>
<baseImage>openjdk:8-jre-alpine</baseImage>
<entryPoint>["java", "-jar", "/opt/${project.fatJar.finalName}.jar"]</entryPoint>
<resources>
@@ -103,7 +75,7 @@
</resource>
<resource>
<targetPath>/config</targetPath>
- <directory>${project.build.directory}/config</directory>
+ <directory>${project.basedir}/config</directory>
<include>*</include>
</resource>
</resources>
@@ -111,36 +83,73 @@
<expose>8100</expose>
<expose>8433</expose>
</exposes>
- <imageTags>
- <imageTag>${project.version}-SNAPSHOT-${maven.build.timestamp}Z</imageTag>
- <imageTag>${project.version}</imageTag>
- <imageTag>latest</imageTag>
- </imageTags>
- <serverId>${docker.repo.url}</serverId>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <serverId>ecomp-staging</serverId>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <skipNexusStagingDeployMojo>${nexus.staging}</skipNexusStagingDeployMojo>
</configuration>
+ <executions>
+ <execution>
+ <id>build-image</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>tag-and-push-image-latest</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <image>${docker.image.name}:latest</image>
+ <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest</newName>
+ <pushImage>true</pushImage>
+ </configuration>
+ </execution>
+ <execution>
+ <id>tag-and-push-image-with-version</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <image>${docker.image.name}:latest</image>
+ <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}</newName>
+ <pushImage>true</pushImage>
+ </configuration>
+ </execution>
+ <execution>
+ <id>tag-and-push-image-with-version-and-date</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <image>${docker.image.name}:latest</image>
+ <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}-${maven.build.timestamp}Z</newName>
+ <pushImage>true</pushImage>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
<dependencies>
-
- <!--DEVELOPMENT DEPENDENCIES-->
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-core</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>value</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
@@ -155,60 +164,17 @@
</exclusions>
</dependency>
<dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk15on</artifactId>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
</dependency>
<dependency>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcpkix-jdk15on</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-el</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-websocket</artifactId>
- </dependency>
- <dependency>
- <groupId>org.immutables</groupId>
- <artifactId>value</artifactId>
- </dependency>
- <dependency>
- <groupId>org.immutables</groupId>
- <artifactId>gson</artifactId>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.onap.dcaegen2.collectors.datafile</groupId>
- <artifactId>datafile-commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
-
-
- <!-- LOGGING DEPENDENCIES-->
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
+ <artifactId>datafile-dmaap-client</artifactId>
+ <version>${project.parent.version}</version>
</dependency>
<!--TESTS DEPENDENCIES -->
@@ -223,11 +189,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
@@ -235,6 +196,7 @@
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -254,16 +216,17 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.dcaegen2.collectors.datafile</groupId>
- <artifactId>datafile-aai-client</artifactId>
- <version>${project.parent.version}</version>
+ <groupId>org.mockftpserver</groupId>
+ <artifactId>MockFtpServer</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.dcaegen2.collectors.datafile</groupId>
- <artifactId>datafile-dmaap-client</artifactId>
- <version>${project.parent.version}</version>
+ <groupId>com.github.stefanbirkner</groupId>
+ <artifactId>fake-sftp-server-rule</artifactId>
+ <scope>test</scope>
</dependency>
<!--REQUIRED TO GENERATE DOCUMENTATION -->
@@ -275,6 +238,7 @@
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
+
</dependencies>
<dependencyManagement>
<dependencies>
@@ -282,7 +246,7 @@
<!-- IMPORT DEPENDENCY MANAGEMENT FROM SPRING BOOT -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
- <version>2.0.1.RELEASE</version>
+ <version>2.0.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/MainApp.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/MainApp.java
index 63fbccb0..d0443ecf 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/MainApp.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/MainApp.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,29 +13,24 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile;
import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
-@SpringBootApplication
-@Configuration
-@ComponentScan
-@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class})
+@SpringBootApplication(exclude = {JacksonAutoConfiguration.class})
@EnableScheduling
public class MainApp {
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
index 1fd50c94..245e0959 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfig.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,35 +13,30 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.configuration;
import java.util.Optional;
-import java.util.function.Predicate;
-
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableAaiClientConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapPublisherConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
-
/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@Component
@Configuration
public class AppConfig extends DatafileAppConfig {
- private static Predicate<String> isEmpty = String::isEmpty;
@Value("${dmaap.dmaapConsumerConfiguration.dmaapHostName:}")
public String consumerDmaapHostName;
@@ -71,8 +64,8 @@ public class AppConfig extends DatafileAppConfig {
@Value("${dmaap.dmaapConsumerConfiguration.consumerGroup:}")
public String consumerGroup;
- @Value("${dmaap.dmaapConsumerConfiguration.timeoutMs:}")
- public Integer consumerTimeoutMs;
+ @Value("${dmaap.dmaapConsumerConfiguration.timeoutMS:}")
+ public Integer consumerTimeoutMS;
@Value("${dmaap.dmaapConsumerConfiguration.message-limit:}")
public Integer consumerMessageLimit;
@@ -98,113 +91,65 @@ public class AppConfig extends DatafileAppConfig {
@Value("${dmaap.dmaapProducerConfiguration.dmaapContentType:}")
public String producerDmaapContentType;
- @Value("${aai.aaiClientConfiguration.aaiHost:}")
- public String aaiHost;
-
- @Value("${aai.aaiClientConfiguration.aaiHostPortNumber:}")
- public Integer aaiPort;
-
- @Value("${aai.aaiClientConfiguration.aaiProtocol:}")
- public String aaiProtocol;
-
- @Value("${aai.aaiClientConfiguration.aaiUserName:}")
- public String aaiUserName;
-
- @Value("${aai.aaiClientConfiguration.aaiUserPassword:}")
- public String aaiUserPassword;
-
- @Value("${aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors:}")
- public Boolean aaiIgnoreSslCertificateErrors;
-
- @Value("${aai.aaiClientConfiguration.aaiBasePath:}")
- public String aaiBasePath;
-
- @Value("${aai.aaiClientConfiguration.aaiPnfPath:}")
- public String aaiPnfPath;
-
@Override
public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
return new ImmutableDmaapConsumerConfiguration.Builder()
.dmaapUserPassword(
- Optional.ofNullable(consumerDmaapUserPassword).filter(isEmpty.negate())
+ Optional.ofNullable(consumerDmaapUserPassword).filter(p -> !p.isEmpty())
.orElse(dmaapConsumerConfiguration.dmaapUserPassword()))
.dmaapUserName(
- Optional.ofNullable(consumerDmaapUserName).filter(isEmpty.negate())
+ Optional.ofNullable(consumerDmaapUserName).filter(p -> !p.isEmpty())
.orElse(dmaapConsumerConfiguration.dmaapUserName()))
.dmaapHostName(
- Optional.ofNullable(consumerDmaapHostName).filter(isEmpty.negate())
+ Optional.ofNullable(consumerDmaapHostName).filter(p -> !p.isEmpty())
.orElse(dmaapConsumerConfiguration.dmaapHostName()))
.dmaapPortNumber(
Optional.ofNullable(consumerDmaapPortNumber).filter(p -> !p.toString().isEmpty())
.orElse(dmaapConsumerConfiguration.dmaapPortNumber()))
.dmaapProtocol(
- Optional.ofNullable(consumerDmaapProtocol).filter(isEmpty.negate())
+ Optional.ofNullable(consumerDmaapProtocol).filter(p -> !p.isEmpty())
.orElse(dmaapConsumerConfiguration.dmaapProtocol()))
.dmaapContentType(
- Optional.ofNullable(consumerDmaapContentType).filter(isEmpty.negate())
+ Optional.ofNullable(consumerDmaapContentType).filter(p -> !p.isEmpty())
.orElse(dmaapConsumerConfiguration.dmaapContentType()))
.dmaapTopicName(
- Optional.ofNullable(consumerDmaapTopicName).filter(isEmpty.negate())
+ Optional.ofNullable(consumerDmaapTopicName).filter(p -> !p.isEmpty())
.orElse(dmaapConsumerConfiguration.dmaapTopicName()))
.messageLimit(
Optional.ofNullable(consumerMessageLimit).filter(p -> !p.toString().isEmpty())
.orElse(dmaapConsumerConfiguration.messageLimit()))
- .timeoutMs(Optional.ofNullable(consumerTimeoutMs).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapConsumerConfiguration.timeoutMs()))
- .consumerGroup(Optional.ofNullable(consumerGroup).filter(isEmpty.negate())
+ .timeoutMS(Optional.ofNullable(consumerTimeoutMS).filter(p -> !p.toString().isEmpty())
+ .orElse(dmaapConsumerConfiguration.timeoutMS()))
+ .consumerGroup(Optional.ofNullable(consumerGroup).filter(p -> !p.isEmpty())
.orElse(dmaapConsumerConfiguration.consumerGroup()))
- .consumerId(Optional.ofNullable(consumerId).filter(isEmpty.negate())
+ .consumerId(Optional.ofNullable(consumerId).filter(p -> !p.isEmpty())
.orElse(dmaapConsumerConfiguration.consumerId()))
.build();
}
@Override
- public AaiClientConfiguration getAaiClientConfiguration() {
- return new ImmutableAaiClientConfiguration.Builder()
- .aaiHost(Optional.ofNullable(aaiHost).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiHost()))
- .aaiPort(
- Optional.ofNullable(aaiPort).filter(p -> !p.toString().isEmpty())
- .orElse(aaiClientConfiguration.aaiPort()))
- .aaiIgnoreSslCertificateErrors(
- Optional.ofNullable(aaiIgnoreSslCertificateErrors).filter(p -> !p.toString().isEmpty())
- .orElse(aaiClientConfiguration.aaiIgnoreSslCertificateErrors()))
- .aaiProtocol(
- Optional.ofNullable(aaiProtocol).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiProtocol()))
- .aaiUserName(
- Optional.ofNullable(aaiUserName).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiUserName()))
- .aaiUserPassword(Optional.ofNullable(aaiUserPassword).filter(isEmpty.negate())
- .orElse(aaiClientConfiguration.aaiUserPassword()))
- .aaiBasePath(Optional.ofNullable(aaiBasePath).filter(isEmpty.negate())
- .orElse(aaiClientConfiguration.aaiBasePath()))
- .aaiPnfPath(
- Optional.ofNullable(aaiPnfPath).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiPnfPath()))
- .aaiHeaders(aaiClientConfiguration.aaiHeaders())
- .build();
- }
-
- @Override
public DmaapPublisherConfiguration getDmaapPublisherConfiguration() {
return new ImmutableDmaapPublisherConfiguration.Builder()
.dmaapContentType(
- Optional.ofNullable(producerDmaapContentType).filter(isEmpty.negate())
+ Optional.ofNullable(producerDmaapContentType).filter(p -> !p.isEmpty())
.orElse(dmaapPublisherConfiguration.dmaapContentType()))
.dmaapHostName(
- Optional.ofNullable(producerDmaapHostName).filter(isEmpty.negate())
+ Optional.ofNullable(producerDmaapHostName).filter(p -> !p.isEmpty())
.orElse(dmaapPublisherConfiguration.dmaapHostName()))
.dmaapPortNumber(
Optional.ofNullable(producerDmaapPortNumber).filter(p -> !p.toString().isEmpty())
.orElse(dmaapPublisherConfiguration.dmaapPortNumber()))
.dmaapProtocol(
- Optional.ofNullable(producerDmaapProtocol).filter(isEmpty.negate())
+ Optional.ofNullable(producerDmaapProtocol).filter(p -> !p.isEmpty())
.orElse(dmaapPublisherConfiguration.dmaapProtocol()))
.dmaapTopicName(
- Optional.ofNullable(producerDmaapTopicName).filter(isEmpty.negate())
+ Optional.ofNullable(producerDmaapTopicName).filter(p -> !p.isEmpty())
.orElse(dmaapPublisherConfiguration.dmaapTopicName()))
.dmaapUserName(
- Optional.ofNullable(producerDmaapUserName).filter(isEmpty.negate())
+ Optional.ofNullable(producerDmaapUserName).filter(p -> !p.isEmpty())
.orElse(dmaapPublisherConfiguration.dmaapUserName()))
.dmaapUserPassword(
- Optional.ofNullable(producerDmaapUserPassword).filter(isEmpty.negate())
+ Optional.ofNullable(producerDmaapUserPassword).filter(p -> !p.isEmpty())
.orElse(dmaapPublisherConfiguration.dmaapUserPassword()))
.build();
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/Config.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/Config.java
index 5c6f1512..5ab4358a 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/Config.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/Config.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,24 +13,22 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.configuration;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/25/18
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
public interface Config {
DmaapConsumerConfiguration getDmaapConsumerConfiguration();
- AaiClientConfiguration getAaiClientConfiguration();
-
DmaapPublisherConfiguration getDmaapPublisherConfiguration();
void initFileStreamReader();
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfig.java
index 169bf8ed..b6525f0f 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfig.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/DatafileAppConfig.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,30 +13,21 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.configuration;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.TypeAdapterFactory;
-
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-
-import java.nio.charset.StandardCharsets;
import java.util.ServiceLoader;
+
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
import org.slf4j.Logger;
@@ -47,8 +36,16 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.TypeAdapterFactory;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@Configuration
@EnableConfigurationProperties
@@ -56,15 +53,11 @@ import org.springframework.context.annotation.Configuration;
public abstract class DatafileAppConfig implements Config {
private static final String CONFIG = "configs";
- private static final String AAI = "aai";
private static final String DMAAP = "dmaap";
- private static final String AAI_CONFIG = "aaiClientConfiguration";
private static final String DMAAP_PRODUCER = "dmaapProducerConfiguration";
private static final String DMAAP_CONSUMER = "dmaapConsumerConfiguration";
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- AaiClientConfiguration aaiClientConfiguration;
+ private static final Logger logger = LoggerFactory.getLogger(DatafileAppConfig.class);
DmaapConsumerConfiguration dmaapConsumerConfiguration;
@@ -80,11 +73,6 @@ public abstract class DatafileAppConfig implements Config {
}
@Override
- public AaiClientConfiguration getAaiClientConfiguration() {
- return aaiClientConfiguration;
- }
-
- @Override
public DmaapPublisherConfiguration getDmaapPublisherConfiguration() {
return dmaapPublisherConfiguration;
}
@@ -100,10 +88,6 @@ public abstract class DatafileAppConfig implements Config {
JsonElement rootElement = getJsonElement(parser, inputStream);
if (rootElement.isJsonObject()) {
jsonObject = rootElement.getAsJsonObject();
- aaiClientConfiguration = deserializeType(gsonBuilder,
- jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(AAI).getAsJsonObject(AAI_CONFIG),
- AaiClientConfiguration.class);
-
dmaapConsumerConfiguration = deserializeType(gsonBuilder,
jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(DMAAP).getAsJsonObject(DMAAP_CONSUMER),
DmaapConsumerConfiguration.class);
@@ -113,14 +97,14 @@ public abstract class DatafileAppConfig implements Config {
DmaapPublisherConfiguration.class);
}
} catch (IOException e) {
- logger.warn("Problem with file loading, file: {}", filepath, e);
+ logger.error("Problem with file loading, file: {}", filepath, e);
} catch (JsonSyntaxException e) {
- logger.warn("Problem with Json deserialization", e);
+ logger.error("Problem with Json deserialization", e);
}
}
JsonElement getJsonElement(JsonParser parser, InputStream inputStream) {
- return parser.parse(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
+ return parser.parse(new InputStreamReader(inputStream));
}
private <T> T deserializeType(@NotNull GsonBuilder gsonBuilder, @NotNull JsonObject jsonObject,
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java
index 823fe732..1d0a192f 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfig.java
@@ -1,29 +1,25 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.configuration;
-import io.swagger.annotations.ApiOperation;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
+
import javax.annotation.PostConstruct;
import org.onap.dcaegen2.collectors.datafile.tasks.ScheduledTasks;
@@ -33,6 +29,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
+
+import io.swagger.annotations.ApiOperation;
import reactor.core.publisher.Mono;
/**
@@ -43,7 +41,7 @@ import reactor.core.publisher.Mono;
public class SchedulerConfig extends DatafileAppConfig {
private static final int SCHEDULING_DELAY = 2000;
- private static volatile List<ScheduledFuture> scheduledFutureList = new ArrayList<>();
+ private static volatile List<ScheduledFuture> scheduledFutureList = new ArrayList<ScheduledFuture>();
private final TaskScheduler taskScheduler;
private final ScheduledTasks scheduledTask;
@@ -63,9 +61,8 @@ public class SchedulerConfig extends DatafileAppConfig {
public synchronized Mono<ResponseEntity<String>> getResponseFromCancellationOfTasks() {
scheduledFutureList.forEach(x -> x.cancel(false));
scheduledFutureList.clear();
- return Mono.defer(() ->
- Mono.just(new ResponseEntity<>("Datafile Service has already been stopped!", HttpStatus.CREATED))
- );
+ return Mono.defer(() -> Mono
+ .just(new ResponseEntity<>("Datafile Service has already been stopped!", HttpStatus.CREATED)));
}
/**
@@ -77,8 +74,8 @@ public class SchedulerConfig extends DatafileAppConfig {
@ApiOperation(value = "Start task if possible")
public synchronized boolean tryToStartTask() {
if (scheduledFutureList.isEmpty()) {
- scheduledFutureList.add(taskScheduler
- .scheduleWithFixedDelay(scheduledTask::scheduleMainDatafileEventTask, SCHEDULING_DELAY));
+ scheduledFutureList.add(taskScheduler.scheduleWithFixedDelay(scheduledTask::scheduleMainDatafileEventTask,
+ SCHEDULING_DELAY));
return true;
} else {
return false;
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SwaggerConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SwaggerConfig.java
index c45b136a..967be5f6 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SwaggerConfig.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/SwaggerConfig.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.configuration;
@@ -25,6 +23,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
@@ -37,46 +36,42 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@Configuration
@Profile("prod")
-public class SwaggerConfig extends WebMvcConfigurationSupport {
+public class SwaggerConfig extends WebMvcConfigurationSupport{
- private static final String PACKAGE_PATH = "org.onap.dcaegen2.collectors.datafile";
- private static final String API_TITLE = "Datafile app server";
- private static final String DESCRIPTION = "This page lists all the rest apis for Datafile app server.";
- private static final String VERSION = "1.0";
- private static final String RESOURCES_PATH = "classpath:/META-INF/resources/";
- private static final String WEBJARS_PATH = RESOURCES_PATH + "webjars/";
- private static final String SWAGGER_UI = "swagger-ui.html";
- private static final String WEBJARS = "/webjars/**";
+ public static final String PACKAGE_PATH = "org.onap.dcaegen2.collectors.datafile";
+ public static final String API_TITLE = "DATAFILE app server";
+ public static final String DESCRIPTION = "This page lists all the rest apis for DATAFILE app server.";
+ public static final String VERSION = "1.0";
+ public static final String RESOURCES_PATH = "classpath:/META-INF/resources/";
+ public static final String WEBJARS_PATH = RESOURCES_PATH + "webjars/";
+ public static final String SWAGGER_UI = "swagger-ui.html";
+ public static final String WEBJARS = "/webjars/**";
- /**
- * Swagger configuration function for hosting it next to spring http website.
- * @return Docket
- */
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2)
- .apiInfo(apiInfo())
- .select()
- .apis(RequestHandlerSelectors.basePackage(PACKAGE_PATH))
- .paths(PathSelectors.any())
- .build();
- }
+ @Bean
+ public Docket api() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage(PACKAGE_PATH))
+ .paths(PathSelectors.any())
+ .build();
+ }
- private ApiInfo apiInfo() {
- return new ApiInfoBuilder()
- .title(API_TITLE)
- .description(DESCRIPTION)
- .version(VERSION)
- .build();
- }
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title(API_TITLE)
+ .description(DESCRIPTION)
+ .version(VERSION)
+ .build();
+ }
- @Override
- protected void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler(SWAGGER_UI)
- .addResourceLocations(RESOURCES_PATH);
+ @Override
+ protected void addResourceHandlers(ResourceHandlerRegistry registry) {
+ registry.addResourceHandler(SWAGGER_UI)
+ .addResourceLocations(RESOURCES_PATH);
- registry.addResourceHandler(WEBJARS)
- .addResourceLocations(WEBJARS_PATH);
- }
-} \ No newline at end of file
+ registry.addResourceHandler(WEBJARS)
+ .addResourceLocations(WEBJARS_PATH);
+ }
+}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/TomcatHttpConfig.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/TomcatHttpConfig.java
deleted file mode 100644
index b6231418..00000000
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/configuration/TomcatHttpConfig.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.configuration;
-
-import org.apache.catalina.connector.Connector;
-import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/18/18
- */
-@Configuration
-public class TomcatHttpConfig {
-
- /**
- * Class for setting up hosting Datafile on http/https.
- *
- * @return ServletWebServerFactory
- */
- @Bean
- public ServletWebServerFactory servletContainer() {
- TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
- tomcat.addAdditionalTomcatConnectors(getHttpConnector());
- return tomcat;
- }
-
- private Connector getHttpConnector() {
- Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
- connector.setScheme("http");
- connector.setPort(8100);
- connector.setSecure(false);
- return connector;
- }
-
-}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/HeartbeatController.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/HeartbeatController.java
index 070fe591..98dfdedc 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/HeartbeatController.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/HeartbeatController.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,15 +13,11 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.controllers;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
@@ -31,35 +25,36 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/19/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@RestController
-@Api(value = "HeartbeatController", description = "Check liveness of Datafile service")
+@Api(value = "HeartbeatController", description = "Check liveness of DATAFILE service")
public class HeartbeatController {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ private static final Logger logger = LoggerFactory.getLogger(HeartbeatController.class);
- /**
- * Endpoint for checking that Datafile is alive.
- *
- * @return HTTP Status Code
- */
@RequestMapping(value = "heartbeat", method = RequestMethod.GET)
- @ApiOperation(value = "Returns liveness of Datafile service")
+ @ApiOperation(value = "Returns liveness of DATAFILE service")
@ApiResponses(value = {
- @ApiResponse(code = 200, message = "Datafile sevice is living"),
- @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")
- }
+ @ApiResponse(code = 200, message = "DATAFILE service is living"),
+ @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<ResponseEntity<String>> heartbeat() {
logger.trace("Receiving heartbeat request");
return Mono.defer(() ->
- Mono.just(new ResponseEntity<>("alive", HttpStatus.OK))
+ Mono.just(new ResponseEntity<>("I'm living", HttpStatus.OK))
);
}
-} \ No newline at end of file
+}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleController.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleController.java
index f3cf354f..5765b31c 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleController.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleController.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,14 +13,11 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.controllers;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-
import org.onap.dcaegen2.collectors.datafile.configuration.SchedulerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,16 +27,21 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/5/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
+
@RestController
@Api(value = "ScheduleController", description = "Schedule Controller")
public class ScheduleController {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ private static final Logger logger = LoggerFactory.getLogger(ScheduleController.class);
private final SchedulerConfig schedulerConfig;
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/AaiNotFoundException.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/AaiNotFoundException.java
deleted file mode 100644
index a83b5bd6..00000000
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/AaiNotFoundException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.exceptions;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
- */
-public class AaiNotFoundException extends DatafileTaskException {
-
- public AaiNotFoundException(String message) {
- super(message);
- }
-}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java
index 41f77332..2d62871c 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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
@@ -15,13 +13,13 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.exceptions;
/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
public class DatafileTaskException extends Exception {
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapEmptyResponseException.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapEmptyResponseException.java
index d9f6f873..cf387296 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapEmptyResponseException.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapEmptyResponseException.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.exceptions;
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapNotFoundException.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapNotFoundException.java
index ebff8ae3..e27a2036 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapNotFoundException.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DmaapNotFoundException.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.exceptions;
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollector.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollector.java
new file mode 100644
index 00000000..0f03b1a4
--- /dev/null
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollector.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END========================================================================
+ */
+
+package org.onap.dcaegen2.collectors.datafile.ftp;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FilenameUtils;
+import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
+import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
+import org.onap.dcaegen2.collectors.datafile.service.FileData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import reactor.core.publisher.Mono;
+
+/**
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
+ *
+ */
+@Component
+public class FileCollector { // TODO: Should be final, but that means adding PowerMock or Mockito
+ // 2.x for testing so it is left for later improvement.
+ private static final String FTPES = "ftpes";
+ private static final String FTPS = "ftps";
+ private static final String SFTP = "sftp";
+
+ private static final Logger logger = LoggerFactory.getLogger(FileCollector.class);
+
+ private final FtpsClient ftpsClient;
+ private final SftpClient sftpClient;
+
+ @Autowired
+ protected FileCollector(FtpsClient ftpsCleint, SftpClient sftpClient) {
+ this.ftpsClient = ftpsCleint;
+ this.sftpClient = sftpClient;
+ }
+
+ public Mono<List<ConsumerDmaapModel>> getFilesFromSender(List<FileData> listOfFileData) {
+ List<ConsumerDmaapModel> consumerModels = new ArrayList<ConsumerDmaapModel>();
+ for (FileData fileData : listOfFileData) {
+ String localFile = collectFile(fileData);
+
+ if (localFile != null) {
+ ConsumerDmaapModel consumerDmaapModel = getConsumerDmaapModel(fileData, localFile);
+ consumerModels.add(consumerDmaapModel);
+ }
+ }
+ return Mono.just(consumerModels);
+ }
+
+ private String collectFile(FileData fileData) {
+ String location = fileData.location();
+ URI uri = URI.create(location);
+ String[] userInfo = getUserNameAndPasswordIfGiven(uri.getUserInfo());
+ FileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(uri.getHost())
+ .userId(userInfo != null ? userInfo[0] : "").password(userInfo != null ? userInfo[1] : "")
+ .port(uri.getPort()).build();
+ String remoteFile = uri.getPath();
+ String localFile = "target/" + FilenameUtils.getName(remoteFile);
+ String scheme = uri.getScheme();
+
+ boolean fileDownloaded = false;
+ if (FTPES.equals(scheme) || FTPS.equals(scheme)) {
+ fileDownloaded = ftpsClient.collectFile(fileServerData, remoteFile, localFile);
+ } else if (SFTP.equals(scheme)) {
+ fileDownloaded = sftpClient.collectFile(fileServerData, remoteFile, localFile);
+ } else {
+
+ logger.error("DFC does not support protocol {}. Supported protocols are " + FTPES + ", " + FTPS + ", and "
+ + SFTP + ". " + fileData);
+ localFile = null;
+ }
+ if (!fileDownloaded) {
+ localFile = null;
+ }
+ return localFile;
+ }
+
+ private String[] getUserNameAndPasswordIfGiven(String userInfoString) {
+ String[] userInfo = null;
+ if (userInfoString != null && !userInfoString.isEmpty()) {
+ userInfo = userInfoString.split(":");
+ }
+ return userInfo;
+ }
+
+ private ConsumerDmaapModel getConsumerDmaapModel(FileData fileData, String localFile) {
+ String compression = fileData.compression();
+ String fileFormatType = fileData.fileFormatType();
+ String fileFormatVersion = fileData.fileFormatVersion();
+
+ return ImmutableConsumerDmaapModel.builder().location(localFile).compression(compression)
+ .fileFormatType(fileFormatType).fileFormatVersion(fileFormatVersion).build();
+ }
+}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileServerData.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileServerData.java
new file mode 100644
index 00000000..d4eca4d7
--- /dev/null
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileServerData.java
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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.collectors.datafile.ftp;
+
+import org.immutables.value.Value;
+
+/**
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
+ *
+ */
+@Value.Immutable
+public interface FileServerData {
+ public String serverAddress();
+ public String userId();
+ public String password();
+ public int port();
+}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java
new file mode 100644
index 00000000..a3f75826
--- /dev/null
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClient.java
@@ -0,0 +1,117 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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.collectors.datafile.ftp;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.net.ftp.FTPReply;
+import org.apache.commons.net.ftp.FTPSClient;
+import org.apache.commons.net.util.TrustManagerUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * Gets file from xNF with FTPS protocol.
+ *
+ * TODO: Refactor for better test.
+ *
+ * @author <a href="mailto:martin.c.yan@est.tech">Martin Yan</a>
+ *
+ */
+@Component
+public class FtpsClient { // TODO: Should be final but needs PowerMock or Mockito 2.x to be able to
+ // mock then, so this will be done as an improvement after first version
+ // committed.
+ private static final Logger logger = LoggerFactory.getLogger(FtpsClient.class);
+
+ public boolean collectFile(FileServerData fileServerData, String remoteFile, String localFile) {
+ boolean result = true;
+ try {
+ FTPSClient ftps = new FTPSClient("TLS");
+
+ result = setUpConnection(fileServerData, ftps);
+
+ if (result) {
+ getFile(remoteFile, localFile, ftps);
+
+ closeDownConnection(ftps);
+ }
+ } catch (IOException ex) {
+ logger.error("Unable to collect file from xNF. " + fileServerData, ex);
+ result = false;
+ }
+ return result;
+ }
+
+ private boolean setUpConnection(FileServerData fileServerData, FTPSClient ftps) {
+ boolean success = true;
+ ftps.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager());
+
+ try {
+ ftps.connect(fileServerData.serverAddress(), fileServerData.port());
+
+ if (!ftps.login(fileServerData.userId(), fileServerData.password())) {
+ ftps.logout();
+ logger.error("Unable to log in to xNF. " + fileServerData);
+ success = false;
+ }
+
+ if (success) {
+ int reply = ftps.getReplyCode();
+ if (!FTPReply.isPositiveCompletion(reply)) {
+ ftps.disconnect();
+ logger.error("Unable to connect in to xNF. " + fileServerData);
+ success = false;
+ }
+ ftps.enterLocalPassiveMode();
+ }
+ } catch (Exception ex) {
+ logger.error("Unable to connect to xNF." + fileServerData, ex);
+ success = false;
+ }
+
+ return success;
+ }
+
+ private void getFile(String remoteFile, String localFile, FTPSClient ftps)
+ throws IOException, FileNotFoundException {
+ OutputStream output;
+ File outfile = new File(localFile);
+ outfile.createNewFile();
+
+ output = new FileOutputStream(outfile);
+
+ ftps.retrieveFile(remoteFile, output);
+
+ output.close();
+ logger.debug("File " + outfile.getName() + " Download Successfull from xNF");
+ }
+
+ private void closeDownConnection(FTPSClient ftps) {
+ try {
+ ftps.logout();
+ ftps.disconnect();
+ } catch (Exception e) {
+ // Do nothing, file has been collected.
+ }
+ }
+}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClient.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClient.java
new file mode 100644
index 00000000..e7c7c09b
--- /dev/null
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClient.java
@@ -0,0 +1,98 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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.collectors.datafile.ftp;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelSftp;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.SftpException;
+
+import org.apache.commons.io.FilenameUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * Gets file from xNF with SFTP protocol.
+ *
+ * TODO: Refactor for better test.
+ *
+ * @author <a href="mailto:martin.c.yan@est.tech">Martin Yan</a>
+ *
+ */
+@Component
+public class SftpClient { // TODO: Should be final but needs PowerMock to be able to mock then, so
+ // this will be done as an improvement after first version committed.
+ private static final Logger logger = LoggerFactory.getLogger(SftpClient.class);
+
+ public boolean collectFile(FileServerData fileServerData, String remoteFile, String localFile) {
+ boolean result = true;
+ Session session = setUpSession(fileServerData);
+
+ if (session != null) {
+ ChannelSftp sftpChannel = getChannel(session, fileServerData);
+ if (sftpChannel != null) {
+ try {
+ sftpChannel.get(remoteFile, localFile);
+ logger.debug("File " + FilenameUtils.getName(localFile) + " Download Successfull from xNF");
+ } catch (SftpException e) {
+ logger.error("Unable to get file from xNF. " + fileServerData, e);
+ result = false;
+ }
+
+ sftpChannel.exit();
+ } else {
+ result = false;
+ }
+ session.disconnect();
+ } else {
+ result = false;
+ }
+ return result;
+ }
+
+ private Session setUpSession(FileServerData fileServerData) {
+ JSch jsch = new JSch(); // TODO: Might be changed to use Spring as an improvement after
+ // first version committed.
+
+ Session session = null;
+ try {
+ session = jsch.getSession(fileServerData.userId(), fileServerData.serverAddress(), fileServerData.port());
+ session.setConfig("StrictHostKeyChecking", "no");
+ session.setPassword(fileServerData.password());
+ session.connect();
+ } catch (JSchException e) {
+ logger.error("Unable to set up SFTP connection to xNF. " + fileServerData, e);
+ }
+ return session;
+ }
+
+ private ChannelSftp getChannel(Session session, FileServerData fileServerData) {
+ ChannelSftp sftpChannel = null;
+ try {
+ Channel channel;
+ channel = session.openChannel("sftp");
+ channel.connect();
+ sftpChannel = (ChannelSftp) channel;
+ } catch (JSchException e) {
+ logger.error("Unable to get sftp channel to xNF. " + fileServerData, e);
+ }
+ return sftpChannel;
+ }
+}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParser.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParser.java
index aeaf0da1..98f3a72a 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParser.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParser.java
@@ -1,130 +1,171 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.service;
+import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import java.util.stream.StreamSupport;
import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapEmptyResponseException;
import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapNotFoundException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
import org.springframework.util.StringUtils;
+
import reactor.core.publisher.Mono;
/**
+ * Parses the fileReady event and creates an array of FileData containing the information.
+ *
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/8/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
public class DmaapConsumerJsonParser {
private static final String EVENT = "event";
- private static final String OTHER_FIELDS = "otherFields";
- private static final String PNF_OAM_IPV_4_ADDRESS = "pnfOamIpv4Address";
- private static final String PNF_OAM_IPV_6_ADDRESS = "pnfOamIpv6Address";
- private static final String PNF_VENDOR_NAME = "pnfVendorName";
- private static final String PNF_SERIAL_NUMBER = "pnfSerialNumber";
+ private static final String NOTIFICATION_FIELDS = "notificationFields";
+ private static final String CHANGE_IDENTIFIER = "changeIdentifier";
+ private static final String CHANGE_TYPE = "changeType";
+ private static final String NOTIFICATION_FIELDS_VERSION = "notificationFieldsVersion";
+
+ private static final String LOCATION = "location";
+ private static final String COMPRESSION = "compression";
+ private static final String FILE_FORMAT_TYPE = "fileFormatType";
+ private static final String FILE_FORMAT_VERSION = "fileFormatVersion";
/**
- * Extract info from string and create @see {@link org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel}.
+ * Extract info from string and create @see
+ * {@link org.onap.dcaegen2.collectors.datafile.service.FileData}.
*
* @param monoMessage - results from DMaaP
- * @return reactive DMaaPModel
+ * @return reactive Mono with an array of FileData
*/
- public Mono<ConsumerDmaapModel> getJsonObject(Mono<String> monoMessage) {
- return monoMessage
- .flatMap(this::getJsonParserMessage)
- .flatMap(this::createJsonConsumerModel);
+ public Mono<List<FileData>> getJsonObject(Mono<String> monoMessage) {
+ return monoMessage.flatMap(this::getJsonParserMessage).flatMap(this::createJsonConsumerModel);
}
private Mono<JsonElement> getJsonParserMessage(String message) {
return StringUtils.isEmpty(message) ? Mono.error(new DmaapEmptyResponseException())
- : Mono.fromSupplier(() -> new JsonParser().parse(message));
+ : Mono.fromSupplier(() -> new JsonParser().parse(message));
}
- private Mono<ConsumerDmaapModel> createJsonConsumerModel(JsonElement jsonElement) {
- return jsonElement.isJsonObject()
- ? create(Mono.fromSupplier(jsonElement::getAsJsonObject))
- : getConsumerDmaapModelFromJsonArray(jsonElement);
+ private Mono<List<FileData>> createJsonConsumerModel(JsonElement jsonElement) {
+ return jsonElement.isJsonObject() ? create(Mono.fromSupplier(jsonElement::getAsJsonObject))
+ : getFileDataFromJsonArray(jsonElement);
}
- private Mono<ConsumerDmaapModel> getConsumerDmaapModelFromJsonArray(JsonElement jsonElement) {
- return create(
- Mono.fromCallable(() -> StreamSupport.stream(jsonElement.getAsJsonArray().spliterator(), false).findFirst()
- .flatMap(this::getJsonObjectFromAnArray)
- .orElseThrow(DmaapEmptyResponseException::new)));
+ private Mono<List<FileData>> getFileDataFromJsonArray(JsonElement jsonElement) {
+ return create(Mono.fromCallable(() -> StreamSupport.stream(jsonElement.getAsJsonArray().spliterator(), false)
+ .findFirst().flatMap(this::getJsonObjectFromAnArray).orElseThrow(DmaapEmptyResponseException::new)));
}
public Optional<JsonObject> getJsonObjectFromAnArray(JsonElement element) {
return Optional.of(new JsonParser().parse(element.getAsString()).getAsJsonObject());
}
- private Mono<ConsumerDmaapModel> create(Mono<JsonObject> jsonObject) {
- return jsonObject.flatMap(monoJsonP ->
- !containsHeader(monoJsonP) ? Mono.error(new DmaapNotFoundException("Incorrect JsonObject - missing header"))
+ private Mono<List<FileData>> create(Mono<JsonObject> jsonObject) {
+ return jsonObject.flatMap(monoJsonP -> !containsHeader(monoJsonP)
+ ? Mono.error(new DmaapNotFoundException("Incorrect JsonObject - missing header"))
: transform(monoJsonP));
}
- private Mono<ConsumerDmaapModel> transform(JsonObject monoJsonP) {
- monoJsonP = monoJsonP.getAsJsonObject(EVENT).getAsJsonObject(OTHER_FIELDS);
- String pnfVendorName = getValueFromJson(monoJsonP, PNF_VENDOR_NAME);
- String pnfSerialNumber = getValueFromJson(monoJsonP, PNF_SERIAL_NUMBER);
- String pnfOamIpv4Address = getValueFromJson(monoJsonP, PNF_OAM_IPV_4_ADDRESS);
- String pnfOamIpv6Address = getValueFromJson(monoJsonP, PNF_OAM_IPV_6_ADDRESS);
- return
- (!vendorAndSerialNotEmpty(pnfSerialNumber, pnfVendorName) || !ipPropertiesNotEmpty(pnfOamIpv4Address,
- pnfOamIpv6Address))
- ? Mono.error(new DmaapNotFoundException("Incorrect json, consumerDmaapModel can not be created: "
- + printMessage(pnfVendorName, pnfSerialNumber, pnfOamIpv4Address, pnfOamIpv6Address))) :
- Mono.just(ImmutableConsumerDmaapModel.builder()
- .pnfName(pnfVendorName.substring(0, Math.min(pnfVendorName.length(), 3)).toUpperCase()
- .concat(pnfSerialNumber)).ipv4(pnfOamIpv4Address)
- .ipv6(pnfOamIpv6Address).build());
+ private Mono<List<FileData>> transform(JsonObject jsonObject) {
+ if (containsHeader(jsonObject, EVENT, NOTIFICATION_FIELDS)) {
+ JsonObject notificationFields = jsonObject.getAsJsonObject(EVENT).getAsJsonObject(NOTIFICATION_FIELDS);
+ String changeIdentifier = getValueFromJson(notificationFields, CHANGE_IDENTIFIER);
+ String changeType = getValueFromJson(notificationFields, CHANGE_TYPE);
+ String notificationFieldsVersion = getValueFromJson(notificationFields, NOTIFICATION_FIELDS_VERSION);
+ JsonArray arrayOfAdditionalFields = notificationFields.getAsJsonArray("arrayOfAdditionalFields");
+
+ if (isNotificationFieldsHeaderNotEmpty(changeIdentifier, changeType, notificationFieldsVersion)
+ && arrayOfAdditionalFields != null) {
+ Mono<List<FileData>> res =
+ getFileDataFromJson(changeIdentifier, changeType, arrayOfAdditionalFields);
+ return res;
+ }
+
+ if (!isNotificationFieldsHeaderNotEmpty(changeIdentifier, changeType, notificationFieldsVersion)) {
+ return Mono.error(
+ new DmaapNotFoundException("FileReady event header is missing information. " + jsonObject));
+ } else if (arrayOfAdditionalFields != null) {
+ return Mono.error(new DmaapNotFoundException(
+ "FileReady event arrayOfAdditionalFields is missing. " + jsonObject));
+ }
+ return Mono.error(
+ new DmaapNotFoundException("FileReady event does not contain correct information. " + jsonObject));
+ }
+ return Mono.error(
+ new DmaapNotFoundException("FileReady event has incorrect JsonObject - missing header. " + jsonObject));
+
+ }
+
+ private Mono<List<FileData>> getFileDataFromJson(String changeIdentifier, String changeType,
+ JsonArray arrayOfAdditionalFields) {
+ List<FileData> res = new ArrayList<>();
+ for (int i = 0; i < arrayOfAdditionalFields.size(); i++) {
+ if (arrayOfAdditionalFields.get(i) != null) {
+ JsonObject fileInfo = (JsonObject) arrayOfAdditionalFields.get(i);
+ String fileFormatType = getValueFromJson(fileInfo, FILE_FORMAT_TYPE);
+ String fileFormatVersion = getValueFromJson(fileInfo, FILE_FORMAT_VERSION);
+ String location = getValueFromJson(fileInfo, LOCATION);
+ String compression = getValueFromJson(fileInfo, COMPRESSION);
+ if (isFileFormatFieldsNotEmpty(fileFormatVersion, fileFormatType)
+ && isLocationAndCompressionNotEmpty(location, compression)) {
+ res.add(ImmutableFileData.builder().changeIdentifier(changeIdentifier).changeType(changeType)
+ .location(location).compression(compression).fileFormatType(fileFormatType)
+ .fileFormatVersion(fileFormatVersion).build());
+ } else {
+ return Mono.error(new DmaapNotFoundException(
+ "FileReady event does not contain correct file format information. " + fileInfo));
+ }
+ }
+ }
+ return Mono.just(res);
}
private String getValueFromJson(JsonObject jsonObject, String jsonKey) {
return jsonObject.has(jsonKey) ? jsonObject.get(jsonKey).getAsString() : "";
}
- private boolean vendorAndSerialNotEmpty(String pnfSerialNumber, String pnfVendorName) {
- return (!StringUtils.isEmpty(pnfSerialNumber) && !StringUtils.isEmpty(pnfVendorName));
+ private boolean isNotificationFieldsHeaderNotEmpty(String changeIdentifier, String changeType,
+ String notificationFieldsVersion) {
+ return ((changeIdentifier != null && !changeIdentifier.isEmpty())
+ && (changeType != null && !changeType.isEmpty())
+ && (notificationFieldsVersion != null && !notificationFieldsVersion.isEmpty()));
+ }
+
+ private boolean isFileFormatFieldsNotEmpty(String fileFormatVersion, String fileFormatType) {
+ return ((fileFormatVersion != null && !fileFormatVersion.isEmpty())
+ && (fileFormatType != null && !fileFormatType.isEmpty()));
}
- private boolean ipPropertiesNotEmpty(String ipv4, String ipv6) {
- return (!StringUtils.isEmpty(ipv4)) || !(StringUtils.isEmpty(ipv6));
+ private boolean isLocationAndCompressionNotEmpty(String location, String compression) {
+ return (location != null && !location.isEmpty()) && (compression != null && !compression.isEmpty());
}
private boolean containsHeader(JsonObject jsonObject) {
- return jsonObject.has(EVENT) && jsonObject.getAsJsonObject(EVENT).has(OTHER_FIELDS);
+ return jsonObject.has(EVENT) && jsonObject.getAsJsonObject(EVENT).has(NOTIFICATION_FIELDS);
}
- private String printMessage(String pnfVendorName, String pnfSerialNumber, String pnfOamIpv4Address,
- String pnfOamIpv6Address) {
- return String.format("%n{"
- + "\"pnfVendorName\" : \"%s\","
- + "\"pnfSerialNumber\": \"%s\","
- + "\"pnfOamIpv4Address\": \"%s\","
- + "\"pnfOamIpv6Address\": \"%s\""
- + "%n}", pnfVendorName, pnfSerialNumber, pnfOamIpv4Address, pnfOamIpv6Address);
+ private boolean containsHeader(JsonObject jsonObject, String topHeader, String header) {
+ return jsonObject.has(topHeader) && jsonObject.getAsJsonObject(topHeader).has(header);
}
}
diff --git a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiExtendedHttpClient.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/FileData.java
index 3c85b68e..948976b6 100644
--- a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiExtendedHttpClient.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/service/FileData.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,19 +13,25 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.service;
-import java.net.URISyntaxException;
-import java.util.Optional;
+import org.immutables.value.Value;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-
-
-@FunctionalInterface
-public interface AaiExtendedHttpClient {
-
- Optional<Integer> getHttpResponse(ConsumerDmaapModel consumerDmaapModel) throws URISyntaxException;
+/**
+ * Contains data, from the fileReady event, about the file to collect from the xNF.
+ *
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
+ *
+ */
+@Value.Immutable
+public interface FileData {
+ public String changeIdentifier();
+ public String changeType();
+ public String location();
+ public String compression();
+ public String fileFormatType();
+ public String fileFormatVersion();
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTask.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTask.java
deleted file mode 100644
index 8083a255..00000000
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTask.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import java.util.Optional;
-
-import org.onap.dcaegen2.collectors.datafile.exceptions.AaiNotFoundException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.AaiConsumerClient;
-
-public abstract class AaiConsumerTask {
-
- abstract Optional<String> consume(ConsumerDmaapModel message) throws AaiNotFoundException;
-
- abstract AaiConsumerClient resolveClient();
-
- protected abstract String execute(ConsumerDmaapModel consumerDmaapModel) throws AaiNotFoundException;
-}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskImpl.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskImpl.java
deleted file mode 100644
index d487b6b2..00000000
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import java.io.IOException;
-import java.util.Optional;
-
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.configuration.Config;
-import org.onap.dcaegen2.collectors.datafile.exceptions.AaiNotFoundException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.AaiConsumerClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AaiConsumerTaskImpl extends AaiConsumerTask {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final Config datafileAppConfig;
- private AaiConsumerClient aaiConsumerClient;
-
- @Autowired
- public AaiConsumerTaskImpl(AppConfig datafileAppConfig) {
- this.datafileAppConfig = datafileAppConfig;
- }
-
- @Override
- Optional<String> consume(ConsumerDmaapModel consumerDmaapModel) throws AaiNotFoundException {
- logger.trace("Method called with arg {}", consumerDmaapModel);
- try {
- return aaiConsumerClient.getHttpResponse(consumerDmaapModel);
- } catch (IOException e) {
- logger.warn("Get request not successful", e);
- throw new AaiNotFoundException("Get request not successful");
- }
- }
-
- @Override
- public String execute(ConsumerDmaapModel consumerDmaapModel) throws AaiNotFoundException {
- consumerDmaapModel = Optional.ofNullable(consumerDmaapModel)
- .orElseThrow(() -> new AaiNotFoundException("Invoked null object to AAI task"));
- logger.trace("Method called with arg {}", consumerDmaapModel);
- aaiConsumerClient = resolveClient();
- return consume(consumerDmaapModel).orElseThrow(() -> new AaiNotFoundException("Null response code"));
- }
-
- protected AaiClientConfiguration resolveConfiguration() {
- return datafileAppConfig.getAaiClientConfiguration();
- }
-
- @Override
- AaiConsumerClient resolveClient() {
- return Optional.ofNullable(aaiConsumerClient).orElseGet(() -> new AaiConsumerClient(resolveConfiguration()));
- }
-}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTask.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTask.java
deleted file mode 100644
index ca2d03da..00000000
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTask.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.exceptions.AaiNotFoundException;
-import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.AaiReactiveWebClient;
-import org.onap.dcaegen2.collectors.datafile.service.producer.AaiProducerReactiveHttpClient;
-import org.springframework.web.reactive.function.client.WebClient;
-import reactor.core.publisher.Mono;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
- */
-public abstract class AaiProducerTask {
-
- abstract Mono<ConsumerDmaapModel> publish(Mono<ConsumerDmaapModel> message) throws AaiNotFoundException;
-
- abstract AaiProducerReactiveHttpClient resolveClient();
-
- protected abstract AaiClientConfiguration resolveConfiguration();
-
- protected abstract Mono<ConsumerDmaapModel> execute(Mono<ConsumerDmaapModel> consumerDmaapModel)
- throws DatafileTaskException;
-
- WebClient buildWebClient() {
- return new AaiReactiveWebClient().fromConfiguration(resolveConfiguration()).build();
- }
-}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTaskImpl.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTaskImpl.java
deleted file mode 100644
index 9d888aa7..00000000
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTaskImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.configuration.Config;
-import org.onap.dcaegen2.collectors.datafile.exceptions.AaiNotFoundException;
-import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapNotFoundException;
-import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.model.utils.HttpUtils;
-import org.onap.dcaegen2.collectors.datafile.service.producer.AaiProducerReactiveHttpClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import reactor.core.publisher.Mono;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
- */
-@Component
-public class AaiProducerTaskImpl extends
- AaiProducerTask {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final Config datafileAppConfig;
- private AaiProducerReactiveHttpClient aaiProducerReactiveHttpClient;
-
- @Autowired
- public AaiProducerTaskImpl(AppConfig datafileAppConfig) {
- this.datafileAppConfig = datafileAppConfig;
- }
-
- @Override
- Mono<ConsumerDmaapModel> publish(Mono<ConsumerDmaapModel> consumerDmaapModel) {
- logger.info("Sending PNF model to AAI {}", consumerDmaapModel);
- return aaiProducerReactiveHttpClient.getAaiProducerResponse(consumerDmaapModel)
- .flatMap(response -> {
- if (HttpUtils.isSuccessfulResponseCode(response)) {
- return consumerDmaapModel;
- }
- return Mono
- .error(new AaiNotFoundException("Incorrect response code for continuation of tasks workflow"));
- });
- }
-
- @Override
- AaiProducerReactiveHttpClient resolveClient() {
- return aaiProducerReactiveHttpClient == null ? new AaiProducerReactiveHttpClient(resolveConfiguration())
- .createAaiWebClient(buildWebClient()) : aaiProducerReactiveHttpClient;
- }
-
- @Override
- protected AaiClientConfiguration resolveConfiguration() {
- return datafileAppConfig.getAaiClientConfiguration();
- }
-
- @Override
- protected Mono<ConsumerDmaapModel> execute(Mono<ConsumerDmaapModel> consumerDmaapModel) throws DatafileTaskException {
- if (consumerDmaapModel == null) {
- throw new DmaapNotFoundException("Invoked null object to DMaaP task");
- }
- aaiProducerReactiveHttpClient = resolveClient();
- logger.trace("Method called with arg {}", consumerDmaapModel);
- return publish(consumerDmaapModel);
-
- }
-} \ No newline at end of file
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTask.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTask.java
index a5764704..30bf536e 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTask.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTask.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,35 +13,41 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.tasks;
+import java.util.List;
+
import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
+import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.DMaaPReactiveWebClient;
-import org.onap.dcaegen2.collectors.datafile.service.consumer.DMaaPConsumerReactiveHttpClient;
+import org.onap.dcaegen2.collectors.datafile.service.DmaapReactiveWebClient;
+import org.onap.dcaegen2.collectors.datafile.service.FileData;
+import org.onap.dcaegen2.collectors.datafile.service.consumer.DmaapConsumerReactiveHttpClient;
import org.springframework.web.reactive.function.client.WebClient;
+
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
abstract class DmaapConsumerTask {
- abstract Mono<ConsumerDmaapModel> consume(Mono<String> message) throws DatafileTaskException;
+ abstract Mono<List<FileData>> consume(Mono<String> message) throws DmaapNotFoundException;
- abstract DMaaPConsumerReactiveHttpClient resolveClient();
+ abstract DmaapConsumerReactiveHttpClient resolveClient();
abstract void initConfigs();
protected abstract DmaapConsumerConfiguration resolveConfiguration();
- protected abstract Mono<ConsumerDmaapModel> execute(String object) throws DatafileTaskException;
+ protected abstract Mono<List<ConsumerDmaapModel>> execute(String object) throws DatafileTaskException;
WebClient buildWebClient() {
- return new DMaaPReactiveWebClient().fromConfiguration(resolveConfiguration()).build();
+ return new DmaapReactiveWebClient().fromConfiguration(resolveConfiguration()).build();
}
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImpl.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImpl.java
index 8d45a7fd..fdd1bb49 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImpl.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskImpl.java
@@ -1,70 +1,86 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.tasks;
+import java.util.List;
+
import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
import org.onap.dcaegen2.collectors.datafile.configuration.Config;
+import org.onap.dcaegen2.collectors.datafile.ftp.FileCollector;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
import org.onap.dcaegen2.collectors.datafile.service.DmaapConsumerJsonParser;
-import org.onap.dcaegen2.collectors.datafile.service.consumer.DMaaPConsumerReactiveHttpClient;
+import org.onap.dcaegen2.collectors.datafile.service.FileData;
+import org.onap.dcaegen2.collectors.datafile.service.consumer.DmaapConsumerReactiveHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@Component
public class DmaapConsumerTaskImpl extends DmaapConsumerTask {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private final Config datafileAppConfig;
+ private static final Logger logger = LoggerFactory.getLogger(DmaapConsumerTaskImpl.class);
+
+ private Config datafileAppConfig;
private DmaapConsumerJsonParser dmaapConsumerJsonParser;
- private DMaaPConsumerReactiveHttpClient dmaaPConsumerReactiveHttpClient;
+ private DmaapConsumerReactiveHttpClient dmaaPConsumerReactiveHttpClient;
+ FileCollector fileCollector;
@Autowired
- public DmaapConsumerTaskImpl(AppConfig datafileAppConfig) {
+ public DmaapConsumerTaskImpl(AppConfig datafileAppConfig, FileCollector fileCollector) {
this.datafileAppConfig = datafileAppConfig;
this.dmaapConsumerJsonParser = new DmaapConsumerJsonParser();
+ this.fileCollector = fileCollector;
}
- DmaapConsumerTaskImpl(AppConfig datafileAppConfig, DmaapConsumerJsonParser dmaapConsumerJsonParser) {
+ protected DmaapConsumerTaskImpl(AppConfig datafileAppConfig,
+ DmaapConsumerReactiveHttpClient dmaaPConsumerReactiveHttpClient,
+ DmaapConsumerJsonParser dmaapConsumerJsonParser, FileCollector fileCollector) {
this.datafileAppConfig = datafileAppConfig;
+ this.dmaaPConsumerReactiveHttpClient = dmaaPConsumerReactiveHttpClient;
this.dmaapConsumerJsonParser = dmaapConsumerJsonParser;
+ this.fileCollector = fileCollector;
}
@Override
- Mono<ConsumerDmaapModel> consume(Mono<String> message) {
- logger.info("Consumed model from DMaaP: {}", message);
+ Mono<List<FileData>> consume(Mono<String> message) {
+ logger.trace("Method called with arg {}", message);
return dmaapConsumerJsonParser.getJsonObject(message);
}
+ private Mono<List<ConsumerDmaapModel>> getFilesFromSender(List<FileData> listOfFileData) {
+ Mono<List<ConsumerDmaapModel>> filesFromSender = fileCollector.getFilesFromSender(listOfFileData);
+ return filesFromSender;
+ }
+
@Override
- public Mono<ConsumerDmaapModel> execute(String object) {
+ protected Mono<List<ConsumerDmaapModel>> execute(String object) {
dmaaPConsumerReactiveHttpClient = resolveClient();
logger.trace("Method called with arg {}", object);
- return consume((dmaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse()));
+ Mono<List<FileData>> consumerResult =
+ consume((dmaaPConsumerReactiveHttpClient.getDmaapConsumerResponse()));
+ return consumerResult.flatMap(this::getFilesFromSender);
}
@Override
@@ -78,9 +94,9 @@ public class DmaapConsumerTaskImpl extends DmaapConsumerTask {
}
@Override
- DMaaPConsumerReactiveHttpClient resolveClient() {
+ protected DmaapConsumerReactiveHttpClient resolveClient() {
return dmaaPConsumerReactiveHttpClient == null
- ? new DMaaPConsumerReactiveHttpClient(resolveConfiguration()).createDMaaPWebClient(buildWebClient())
- : dmaaPConsumerReactiveHttpClient;
+ ? new DmaapConsumerReactiveHttpClient(resolveConfiguration()).createDmaapWebClient(buildWebClient())
+ : dmaaPConsumerReactiveHttpClient;
}
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTask.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTask.java
index 467eee0b..716b52c1 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTask.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTask.java
@@ -1,47 +1,48 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.tasks;
+import java.util.List;
+
import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.DMaaPReactiveWebClient;
-import org.onap.dcaegen2.collectors.datafile.service.producer.DMaaPProducerReactiveHttpClient;
+import org.onap.dcaegen2.collectors.datafile.service.DmaapReactiveWebClient;
+import org.onap.dcaegen2.collectors.datafile.service.producer.DmaapProducerReactiveHttpClient;
import org.springframework.web.reactive.function.client.WebClient;
+
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
abstract class DmaapPublisherTask {
- abstract Mono<String> publish(Mono<ConsumerDmaapModel> consumerDmaapModel) throws DatafileTaskException;
+ abstract Mono<String> publish(Mono<List<ConsumerDmaapModel>> consumerDmaapModel) throws DatafileTaskException;
- abstract DMaaPProducerReactiveHttpClient resolveClient();
+ abstract DmaapProducerReactiveHttpClient resolveClient();
protected abstract DmaapPublisherConfiguration resolveConfiguration();
- protected abstract Mono<String> execute(Mono<ConsumerDmaapModel> consumerDmaapModel) throws DatafileTaskException;
+ protected abstract Mono<String> execute(Mono<List<ConsumerDmaapModel>> consumerDmaapModel)
+ throws DatafileTaskException;
WebClient buildWebClient() {
- return new DMaaPReactiveWebClient().fromConfiguration(resolveConfiguration()).build();
+ return new DmaapReactiveWebClient().fromConfiguration(resolveConfiguration()).build();
}
}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImpl.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImpl.java
index 4d435a4f..8c4d7072 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImpl.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapPublisherTaskImpl.java
@@ -1,46 +1,47 @@
/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.tasks;
+import java.util.List;
+
import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
import org.onap.dcaegen2.collectors.datafile.configuration.Config;
+import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.producer.DMaaPProducerReactiveHttpClient;
+import org.onap.dcaegen2.collectors.datafile.service.producer.DmaapProducerReactiveHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@Component
public class DmaapPublisherTaskImpl extends DmaapPublisherTask {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ private static final Logger logger = LoggerFactory.getLogger(DmaapPublisherTaskImpl.class);
private final Config datafileAppConfig;
- private DMaaPProducerReactiveHttpClient dmaapProducerReactiveHttpClient;
+ private DmaapProducerReactiveHttpClient dmaapProducerReactiveHttpClient;
@Autowired
public DmaapPublisherTaskImpl(AppConfig datafileAppConfig) {
@@ -48,20 +49,21 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask {
}
@Override
- Mono<String> publish(Mono<ConsumerDmaapModel> consumerDmaapModel) {
- logger.info("Publishing on DMaaP topic {} object {}", resolveConfiguration().dmaapTopicName(),
- consumerDmaapModel);
- return dmaapProducerReactiveHttpClient.getDMaaPProducerResponse(consumerDmaapModel);
+ public Mono<String> publish(Mono<List<ConsumerDmaapModel>> consumerDmaapModels)
+ throws DatafileTaskException {
+ logger.info("Publishing on DMaaP DataRouter {}", consumerDmaapModels);
+ return dmaapProducerReactiveHttpClient.getDmaapProducerResponse(consumerDmaapModels);
}
@Override
- public Mono<String> execute(Mono<ConsumerDmaapModel> consumerDmaapModel) throws DmaapNotFoundException {
- if (consumerDmaapModel == null) {
+ public Mono<String> execute(Mono<List<ConsumerDmaapModel>> consumerDmaapModels)
+ throws DatafileTaskException {
+ if (consumerDmaapModels == null) {
throw new DmaapNotFoundException("Invoked null object to DMaaP task");
}
dmaapProducerReactiveHttpClient = resolveClient();
- logger.trace("Method called with arg {}", consumerDmaapModel);
- return publish(consumerDmaapModel);
+ logger.trace("Method called with arg {}", consumerDmaapModels);
+ return publish(consumerDmaapModels);
}
@Override
@@ -70,9 +72,9 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask {
}
@Override
- DMaaPProducerReactiveHttpClient resolveClient() {
+ DmaapProducerReactiveHttpClient resolveClient() {
return dmaapProducerReactiveHttpClient == null
- ? new DMaaPProducerReactiveHttpClient(resolveConfiguration()).createDMaaPWebClient(buildWebClient())
- : dmaapProducerReactiveHttpClient;
+ ? new DmaapProducerReactiveHttpClient(resolveConfiguration()).createDmaapWebClient(buildWebClient())
+ : dmaapProducerReactiveHttpClient;
}
-} \ No newline at end of file
+}
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java
index 2600b563..14085bb8 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,59 +13,57 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.tasks;
+import java.util.List;
import java.util.concurrent.Callable;
-import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapEmptyResponseException;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
+import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapEmptyResponseException;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@Component
public class ScheduledTasks {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
private final DmaapConsumerTask dmaapConsumerTask;
private final DmaapPublisherTask dmaapProducerTask;
- private final AaiProducerTask aaiProducerTask;
/**
- * Constructor for tasks registration in DatafileWorkflow.
+ * Constructor for task registration in Datafile Workflow.
*
* @param dmaapConsumerTask - fist task
- * @param dmaapPublisherTask - third task
- * @param aaiPublisherTask - second task
+ * @param dmaapPublisherTask - second task
*/
@Autowired
- public ScheduledTasks(DmaapConsumerTask dmaapConsumerTask, DmaapPublisherTask dmaapPublisherTask,
- AaiProducerTask aaiPublisherTask) {
+ public ScheduledTasks(DmaapConsumerTask dmaapConsumerTask, DmaapPublisherTask dmaapPublisherTask) {
this.dmaapConsumerTask = dmaapConsumerTask;
this.dmaapProducerTask = dmaapPublisherTask;
- this.aaiProducerTask = aaiPublisherTask;
}
/**
- * Main function for scheduling datafileWorkflow.
+ * Main function for scheduling Datafile Workflow.
*/
public void scheduleMainDatafileEventTask() {
logger.trace("Execution of tasks was registered");
- Mono<String> dmaapProducerResponse = Mono.fromCallable(consumeFromDMaaPMessage())
- .doOnError(DmaapEmptyResponseException.class, error -> logger.warn("Nothing to consume from DMaaP"))
- .map(this::publishToAaiConfiguration)
+ Mono<String> dmaapProducerResponse = Mono.fromCallable(consumeFromDmaapMessage())
+ .doOnError(DmaapEmptyResponseException.class, error -> logger.error("Nothing to consume from DMaaP"))
.flatMap(this::publishToDmaapConfiguration)
.subscribeOn(Schedulers.elastic());
@@ -84,28 +80,20 @@ public class ScheduledTasks {
private void onError(Throwable throwable) {
if (!(throwable instanceof DmaapEmptyResponseException)) {
- logger.warn("Chain of tasks have been aborted due to errors in Datafile workflow", throwable);
+ logger.error("Chain of tasks have been aborted due to errors in Datafile workflow", throwable);
}
}
- private Callable<Mono<ConsumerDmaapModel>> consumeFromDMaaPMessage() {
+ private Callable<Mono<List<ConsumerDmaapModel>>> consumeFromDmaapMessage() {
return () -> {
dmaapConsumerTask.initConfigs();
return dmaapConsumerTask.execute("");
};
}
- private Mono<ConsumerDmaapModel> publishToAaiConfiguration(Mono<ConsumerDmaapModel> monoDMaaPModel) {
- try {
- return aaiProducerTask.execute(monoDMaaPModel);
- } catch (DatafileTaskException e) {
- return Mono.error(e);
- }
- }
-
- private Mono<String> publishToDmaapConfiguration(Mono<ConsumerDmaapModel> monoAaiModel) {
+ private Mono<String> publishToDmaapConfiguration(Mono<List<ConsumerDmaapModel>> monoModel) {
try {
- return dmaapProducerTask.execute(monoAaiModel);
+ return dmaapProducerTask.execute(monoModel);
} catch (DatafileTaskException e) {
return Mono.error(e);
}
diff --git a/datafile-app-server/src/main/resources/application.properties b/datafile-app-server/src/main/resources/application.properties
index 205b6caa..2b9d7b1d 100644
--- a/datafile-app-server/src/main/resources/application.properties
+++ b/datafile-app-server/src/main/resources/application.properties
@@ -1,10 +1,9 @@
spring.profiles.active=prod
-spring.main.web-application-type=none
server.port=8433
server.ssl.key-store-type=PKCS12
-server.ssl.key-store-password=nokiapnf
+server.ssl.key-store-password=ericssondfc
server.ssl.key-store=classpath:keystore.jks
-server.ssl.key-password=nokiapnf
+server.ssl.key-password=ericssondfc
server.ssl.key-alias=tomcat-localhost
logging.level.root=ERROR
logging.level.org.springframework=ERROR
diff --git a/datafile-app-server/src/main/resources/keystore.jks b/datafile-app-server/src/main/resources/keystore.jks
index cd27cc01..574a585b 100644
--- a/datafile-app-server/src/main/resources/keystore.jks
+++ b/datafile-app-server/src/main/resources/keystore.jks
Binary files differ
diff --git a/datafile-app-server/src/main/resources/keystore.jks.old b/datafile-app-server/src/main/resources/keystore.jks.old
deleted file mode 100644
index 8a2b4f99..00000000
--- a/datafile-app-server/src/main/resources/keystore.jks.old
+++ /dev/null
Binary files differ
diff --git a/datafile-app-server/src/main/resources/logback-spring.xml b/datafile-app-server/src/main/resources/logback-spring.xml
index 925b38cc..af4ab189 100644
--- a/datafile-app-server/src/main/resources/logback-spring.xml
+++ b/datafile-app-server/src/main/resources/logback-spring.xml
@@ -12,11 +12,8 @@
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<file>${LOG_FILE}</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
- <maxFileSize>50MB</maxFileSize>
- <maxHistory>30</maxHistory>
- <totalSizeCap>10GB</totalSizeCap>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
</appender>
<root level="ERROR">
@@ -32,11 +29,12 @@
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<file>${LOG_FILE}</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
- <maxFileSize>50MB</maxFileSize>
- <maxHistory>30</maxHistory>
- <totalSizeCap>10GB</totalSizeCap>
+ <timeBasedFileNamingAndTriggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+ <maxFileSize>10MB</maxFileSize>
+ </timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
diff --git a/datafile-app-server/src/main/resources/scheduled-context.xml b/datafile-app-server/src/main/resources/scheduled-context.xml
index 369d2c7b..21996319 100644
--- a/datafile-app-server/src/main/resources/scheduled-context.xml
+++ b/datafile-app-server/src/main/resources/scheduled-context.xml
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:task="http://www.springframework.org/schema/task"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:task="http://www.springframework.org/schema/task"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
- <context:component-scan
- base-package="org.onap.dcaegen2.collectors.datafile"/>
- <task:scheduled-tasks>
- <task:scheduled ref="scheduleController" method="startTasks"
- fixed-rate="1000"/>
- </task:scheduled-tasks>
+ <context:component-scan
+ base-package="org.onap.dcaegen2.collectors.datafile" />
+ <task:scheduled-tasks>
+ <task:scheduled ref="scheduleController"
+ method="startTasks" fixed-rate="1000" />
+ </task:scheduled-tasks>
</beans>
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 7d54b4d5..12c8c7e7 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
@@ -1,21 +1,17 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.configuration;
@@ -31,154 +27,122 @@ import static org.mockito.Mockito.when;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
+
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.configuration.DatafileAppConfig;
import org.onap.dcaegen2.collectors.datafile.integration.junit5.mockito.MockitoExtension;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@ExtendWith({MockitoExtension.class})
class DatafileAppConfigTest {
private static final String DATAFILE_ENDPOINTS = "datafile_endpoints.json";
- private static final String jsonString = "{\"configs\":{\"aai\":{\"aaiClientConfiguration\":{\"aaiHost\":"
- + "\"localhost\",\"aaiPort\":8080,\"aaiIgnoreSslCertificateErrors\":true,\"aaiProtocol\":"
- + "\"https\",\"aaiUserName\":\"admin\",\"aaiUserPassword\":\"admin\",\"aaiBasePath\":\"/aai/v11\","
- + "\"aaiPnfPath\":\"/network/pnfs/pnf\",\"aaiHeaders\":{\"X-FromAppId\":\"datafile\",\"X-TransactionId\":\"9999\","
- + "\"Accept\":\"application/json\",\"Real-Time\":\"true\",\"Content-Type\":\"application/merge-patch+json\","
- + "\"Authorization\":\"Basic QUFJOkFBSQ==\"}}},"
- + "\"dmaap\":{\"dmaapConsumerConfiguration\":{\"consumerGroup\":\"other\",\"consumerId\":\"1\","
- + "\"dmaapContentType\":\"application/json\",\"dmaapHostName\":\"localhost\",\"dmaapPortNumber\":2222,"
- + "\"dmaapProtocol\":\"http\",\"dmaapTopicName\":\"temp\",\"dmaapUserName\":\"admin\",\"dmaapUserPassword\""
- + ":\"admin\",\"messageLimit\":1000,\"timeoutMs\":1000},\"dmaapProducerConfiguration\":{\"dmaapContentType\":"
- + "\"application/json\",\"dmaapHostName\":\"localhost\",\"dmaapPortNumber\":2223,\"dmaapProtocol\":\"http\","
- + "\"dmaapTopicName\":\"temp\",\"dmaapUserName\":\"admin\",\"dmaapUserPassword\":\"admin\"}}}}";
-
- private static final String incorrectJsonString = "{\"configs\":{\"aai\":{\"aaiClientConfiguration\":{\"aaiHost\":"
- + "\"localhost\",\"aaiPort\":8080,\"aaiIgnoreSslCertificateErrors\":true,\"aaiProtocol\":\"https\","
- + "\"aaiUserName\":\"admin\",\"aaiUserPassword\":\"admin\",\"aaiBasePath\":\"/aai/v11\",\"aaiPnfPath\":"
- + "\"/network/pnfs/pnf\",\"aaiHeaders\":{\"X-FromAppId\":\"datafile\",\"X-TransactionId\":\"9999\",\"Accept\":"
- + "\"application/json\",\"Real-Time\":\"true\",\"Content-Type\":\"application/merge-patch+json\","
- + "\"Authorization\":\"Basic QUFJOkFBSQ==\"}}},\"dmaap\""
- + ":{\"dmaapConsumerConfiguration\":{\"consumerGroup\":\"other\",\"consumerId\":\"1\",\"dmaapContentType\""
- + ":\"application/json\",\"dmaapHostName\":\"localhost\",\"dmaapPortNumber\":2222,\"dmaapProtocol\":\"http\""
- + ",\"dmaapTopicName\":\"temp\",\"dmaapUserName\":\"admin\",\"dmaapUserPassword\":\"admin\",\"messageLimit\""
- + ":1000,\"timeoutMs\":1000},\"dmaapProducerConfiguration\":{\"dmaapContentType\":\"application/json\","
- + "\"dmaapHostName\":\"localhost\",\"dmaapPortNumber\":2223,\"dmaapProtocol\":\"http\",\"dmaaptopicName\""
- + ":\"temp\",\"dmaapuserName\":\"admin\",\"dmaapuserPassword\":\"admin\"}}}}";
+ private static final String JSON_STRING =
+ "{\"configs\":{\"dmaap\":{\"dmaapConsumerConfiguration\":{\"consumerGroup\":\"other\",\"consumerId\":\"1\","
+ + "\"dmaapContentType\":\"application/json\",\"dmaapHostName\":\"localhost\","
+ + "\"dmaapPortNumber\":2222,\"dmaapProtocol\":\"http\",\"dmaapTopicName\":\"temp\","
+ + "\"dmaapUserName\":\"admin\",\"dmaapUserPassword\":\"admin\",\"messageLimit\":1000,"
+ + "\"timeoutMS\":1000},\"dmaapProducerConfiguration\":{\"dmaapContentType\":\"application/json\","
+ + "\"dmaapHostName\":\"localhost\",\"dmaapPortNumber\":2223,\"dmaapProtocol\":\"http\","
+ + "\"dmaapTopicName\":\"temp\",\"dmaapUserName\":\"admin\",\"dmaapUserPassword\":\"admin\"}}}}";
+ private static final String INCORRECT_JSON_STRING =
+ "{\"configs\":{\"dmaap\":{\"dmaapConsumerConfiguration\":{\"consumerGroup\":\"other\",\"consumerId\":\"1\","
+ + "\"dmaapContentType\":\"application/json\",\"dmaapHostName\":\"localhost\","
+ + "\"dmaapPortNumber\":2222,\"dmaapProtocol\":\"http\",\"dmaapTopicName\":\"temp\","
+ + "\"dmaapUserName\":\"admin\",\"dmaapUserPassword\":\"admin\",\"messageLimit\":1000,"
+ + "\"timeoutMS\":1000},\"dmaapProducerConfiguration\":{\"dmaapContentType\":\"application/json\","
+ + "\"dmaapHostName\":\"localhost\",\"dmaapPortNumber\":2223,\"dmaapProtocol\":\"http\","
+ + "\"FAULTY_PARAMETER_NAME\":\"temp\","
+ + "\"dmaapUserName\":\"admin\",\"dmaapUserPassword\":\"admin\"}}}}";
private static DatafileAppConfig datafileAppConfig;
private static AppConfig appConfig;
private static String filePath = Objects
- .requireNonNull(DatafileAppConfigTest.class.getClassLoader().getResource(DATAFILE_ENDPOINTS)).getFile();
+ .requireNonNull(DatafileAppConfigTest.class.getClassLoader().getResource(DATAFILE_ENDPOINTS)).getFile();
@BeforeEach
- void setUp() {
+ public void setUp() {
datafileAppConfig = spy(DatafileAppConfig.class);
appConfig = spy(new AppConfig());
}
@Test
- void whenApplicationWasStarted_FilePathIsSet() {
- //
+ public void whenApplicationWasStarted_FilePathIsSet() {
// When
- //
datafileAppConfig.setFilepath(filePath);
- //
+
// Then
- //
verify(datafileAppConfig, times(1)).setFilepath(anyString());
verify(datafileAppConfig, times(0)).initFileStreamReader();
Assertions.assertEquals(filePath, datafileAppConfig.getFilepath());
}
@Test
- void whenTheConfigurationFits_GetAaiAndDmaapObjectRepresentationConfiguration()
- throws IOException {
- //
+ public void whenTheConfigurationFits_GetAaiAndDmaapObjectRepresentationConfiguration() throws IOException {
// Given
- //
- InputStream inputStream = new ByteArrayInputStream((jsonString.getBytes(
- StandardCharsets.UTF_8)));
- //
+ InputStream inputStream = new ByteArrayInputStream((JSON_STRING.getBytes(StandardCharsets.UTF_8)));
+
// When
- //
datafileAppConfig.setFilepath(filePath);
doReturn(inputStream).when(datafileAppConfig).getInputStream(any());
datafileAppConfig.initFileStreamReader();
appConfig.dmaapConsumerConfiguration = datafileAppConfig.getDmaapConsumerConfiguration();
appConfig.dmaapPublisherConfiguration = datafileAppConfig.getDmaapPublisherConfiguration();
- appConfig.aaiClientConfiguration = datafileAppConfig.getAaiClientConfiguration();
- //
+
// Then
- //
verify(datafileAppConfig, times(1)).setFilepath(anyString());
verify(datafileAppConfig, times(1)).initFileStreamReader();
- Assertions.assertNotNull(datafileAppConfig.getAaiClientConfiguration());
Assertions.assertNotNull(datafileAppConfig.getDmaapConsumerConfiguration());
Assertions.assertNotNull(datafileAppConfig.getDmaapPublisherConfiguration());
- Assertions
- .assertEquals(appConfig.getDmaapPublisherConfiguration(), datafileAppConfig.getDmaapPublisherConfiguration());
- Assertions
- .assertEquals(appConfig.getDmaapConsumerConfiguration(), datafileAppConfig.getDmaapConsumerConfiguration());
- Assertions
- .assertEquals(appConfig.getAaiClientConfiguration(), datafileAppConfig.getAaiClientConfiguration());
+ Assertions.assertEquals(appConfig.getDmaapPublisherConfiguration(),
+ datafileAppConfig.getDmaapPublisherConfiguration());
+ Assertions.assertEquals(appConfig.getDmaapConsumerConfiguration(),
+ datafileAppConfig.getDmaapConsumerConfiguration());
}
@Test
- void whenFileIsNotExist_ThrowIoException() {
- //
+ public void whenFileIsNotExist_ThrowIoException() {
// Given
- //
filePath = "/temp.json";
datafileAppConfig.setFilepath(filePath);
- //
+
// When
- //
datafileAppConfig.initFileStreamReader();
- //
+
// Then
- //
verify(datafileAppConfig, times(1)).setFilepath(anyString());
verify(datafileAppConfig, times(1)).initFileStreamReader();
- Assertions.assertNull(datafileAppConfig.getAaiClientConfiguration());
Assertions.assertNull(datafileAppConfig.getDmaapConsumerConfiguration());
Assertions.assertNull(datafileAppConfig.getDmaapPublisherConfiguration());
}
@Test
- void whenFileIsExistsButJsonIsIncorrect() throws IOException {
- //
+ public void whenFileIsExistsButJsonIsIncorrect() throws IOException {
// Given
- //
- InputStream inputStream = new ByteArrayInputStream((incorrectJsonString.getBytes(
- StandardCharsets.UTF_8)));
- //
+ InputStream inputStream = new ByteArrayInputStream((INCORRECT_JSON_STRING.getBytes(StandardCharsets.UTF_8)));
+
// When
- //
datafileAppConfig.setFilepath(filePath);
doReturn(inputStream).when(datafileAppConfig).getInputStream(any());
datafileAppConfig.initFileStreamReader();
- //
// Then
- //
verify(datafileAppConfig, times(1)).setFilepath(anyString());
verify(datafileAppConfig, times(1)).initFileStreamReader();
- Assertions.assertNotNull(datafileAppConfig.getAaiClientConfiguration());
Assertions.assertNotNull(datafileAppConfig.getDmaapConsumerConfiguration());
Assertions.assertNull(datafileAppConfig.getDmaapPublisherConfiguration());
@@ -186,11 +150,9 @@ class DatafileAppConfigTest {
@Test
- void whenTheConfigurationFits_ButRootElementIsNotAJsonObject()
- throws IOException {
+ public void whenTheConfigurationFits_ButRootElementIsNotAJsonObject() throws IOException {
// Given
- InputStream inputStream = new ByteArrayInputStream((jsonString.getBytes(
- StandardCharsets.UTF_8)));
+ InputStream inputStream = new ByteArrayInputStream((JSON_STRING.getBytes(StandardCharsets.UTF_8)));
// When
datafileAppConfig.setFilepath(filePath);
doReturn(inputStream).when(datafileAppConfig).getInputStream(any());
@@ -200,13 +162,11 @@ class DatafileAppConfigTest {
datafileAppConfig.initFileStreamReader();
appConfig.dmaapConsumerConfiguration = datafileAppConfig.getDmaapConsumerConfiguration();
appConfig.dmaapPublisherConfiguration = datafileAppConfig.getDmaapPublisherConfiguration();
- appConfig.aaiClientConfiguration = datafileAppConfig.getAaiClientConfiguration();
// Then
verify(datafileAppConfig, times(1)).setFilepath(anyString());
verify(datafileAppConfig, times(1)).initFileStreamReader();
- Assertions.assertNull(datafileAppConfig.getAaiClientConfiguration());
Assertions.assertNull(datafileAppConfig.getDmaapConsumerConfiguration());
Assertions.assertNull(datafileAppConfig.getDmaapPublisherConfiguration());
}
-} \ No newline at end of file
+}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectorTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectorTest.java
new file mode 100644
index 00000000..5b9d0aaf
--- /dev/null
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectorTest.java
@@ -0,0 +1,116 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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.collectors.datafile.ftp;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+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 java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
+import org.onap.dcaegen2.collectors.datafile.service.FileData;
+import org.onap.dcaegen2.collectors.datafile.service.ImmutableFileData;
+
+import reactor.core.publisher.Mono;
+
+/**
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
+ *
+ */
+public class FileCollectorTest {
+
+ private static final String PM_MEAS_CHANGE_IDINTIFIER = "PM_MEAS_FILES";
+ private static final String FILE_READY_CHANGE_TYPE = "FileReady";
+ private static final String FTPES_SCHEME = "ftpes://";
+ private static final String SFTP_SCHEME = "sftp://";
+ private static final String SERVER_ADDRESS = "192.168.0.101";
+ private static final int PORT_22 = 22;
+ private static final String PM_FILE_NAME = "A20161224.1030-1045.bin.gz";
+ private static final String REMOTE_FILE_LOCATION = "/ftp/rop/" + PM_FILE_NAME;
+ private static final String LOCAL_FILE_LOCATION = "target/" + PM_FILE_NAME;
+ private static final String FTPES_LOCATION = FTPES_SCHEME + SERVER_ADDRESS + ":" + PORT_22 + REMOTE_FILE_LOCATION;
+ private static final String SFTP_LOCATION = SFTP_SCHEME + SERVER_ADDRESS + ":" + PORT_22 + REMOTE_FILE_LOCATION;
+ private static final String GZIP_COMPRESSION = "gzip";
+ private static final String MEAS_COLLECT_FILE_FORMAT_TYPE = "org.3GPP.32.435#measCollec";
+ private static final String FILE_FORMAT_VERSION = "V10";
+
+ private FtpsClient ftpsClientMock = mock(FtpsClient.class);
+
+ private SftpClient sftpClientMock = mock(SftpClient.class);
+
+ private FileCollector fileCollectorUndetTest = new FileCollector(ftpsClientMock, sftpClientMock);
+
+ @Test
+ public void whenSingleFtpesFile_returnCorrectResponse() {
+ List<FileData> listOfFileData = new ArrayList<FileData>();
+ listOfFileData.add(ImmutableFileData.builder().changeIdentifier(PM_MEAS_CHANGE_IDINTIFIER)
+ .changeType(FILE_READY_CHANGE_TYPE).location(FTPES_LOCATION).compression(GZIP_COMPRESSION)
+ .fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE).fileFormatVersion(FILE_FORMAT_VERSION).build());
+
+ FileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(SERVER_ADDRESS).port(PORT_22)
+ .userId("").password("").build();
+ when(ftpsClientMock.collectFile(fileServerData, REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION)).thenReturn(true);
+
+ Mono<List<ConsumerDmaapModel>> consumerModelsMono =
+ fileCollectorUndetTest.getFilesFromSender(listOfFileData);
+
+ List<ConsumerDmaapModel> consumerModels = consumerModelsMono.block();
+ assertEquals(1, consumerModels.size());
+ ConsumerDmaapModel consumerDmaapModel = consumerModels.get(0);
+ assertEquals(GZIP_COMPRESSION, consumerDmaapModel.getCompression());
+ assertEquals(MEAS_COLLECT_FILE_FORMAT_TYPE, consumerDmaapModel.getFileFormatType());
+ assertEquals(FILE_FORMAT_VERSION, consumerDmaapModel.getFileFormatVersion());
+ assertEquals(LOCAL_FILE_LOCATION, consumerDmaapModel.getLocation());
+ FileServerData expectedFileServerData = ImmutableFileServerData.builder().serverAddress(SERVER_ADDRESS)
+ .userId("").password("").port(PORT_22).build();
+ verify(ftpsClientMock, times(1)).collectFile(expectedFileServerData, REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
+ verifyNoMoreInteractions(ftpsClientMock);
+ }
+
+ @Test
+ public void whenSingleSftpFile_returnCorrectResponse() {
+ List<FileData> listOfFileData = new ArrayList<FileData>();
+ listOfFileData.add(ImmutableFileData.builder().changeIdentifier(PM_MEAS_CHANGE_IDINTIFIER)
+ .changeType(FILE_READY_CHANGE_TYPE).location(SFTP_LOCATION).compression(GZIP_COMPRESSION)
+ .fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE).fileFormatVersion(FILE_FORMAT_VERSION).build());
+
+ FileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(SERVER_ADDRESS).port(PORT_22)
+ .userId("").password("").build();
+ when(sftpClientMock.collectFile(fileServerData, REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION)).thenReturn(true);
+
+ Mono<List<ConsumerDmaapModel>> consumerModelsMono =
+ fileCollectorUndetTest.getFilesFromSender(listOfFileData);
+
+ List<ConsumerDmaapModel> consumerModels = consumerModelsMono.block();
+ assertEquals(1, consumerModels.size());
+ ConsumerDmaapModel consumerDmaapModel = consumerModels.get(0);
+ assertEquals(GZIP_COMPRESSION, consumerDmaapModel.getCompression());
+ assertEquals(MEAS_COLLECT_FILE_FORMAT_TYPE, consumerDmaapModel.getFileFormatType());
+ assertEquals(FILE_FORMAT_VERSION, consumerDmaapModel.getFileFormatVersion());
+ assertEquals(LOCAL_FILE_LOCATION, consumerDmaapModel.getLocation());
+ FileServerData expectedFileServerData = ImmutableFileServerData.builder().serverAddress(SERVER_ADDRESS)
+ .userId("").password("").port(PORT_22).build();
+ verify(sftpClientMock, times(1)).collectFile(expectedFileServerData, REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
+ verifyNoMoreInteractions(ftpsClientMock);
+ }
+}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpClientTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpClientTest.java
new file mode 100644
index 00000000..a95b80ed
--- /dev/null
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpClientTest.java
@@ -0,0 +1,57 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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.collectors.datafile.ftp;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.mockftpserver.fake.FakeFtpServer;
+import org.mockftpserver.fake.UserAccount;
+import org.mockftpserver.fake.filesystem.FileEntry;
+import org.mockftpserver.fake.filesystem.FileSystem;
+import org.mockftpserver.fake.filesystem.UnixFakeFileSystem;
+
+public class FtpClientTest {
+
+ private static final String HOME_DIR = "/";
+ private static final String FILE = "/dir/sample.txt";
+ private static final String CONTENTS = "abcdef 1234567890";
+ private static final int PORT = 8021;
+
+ private static final String USERNAME = "bob";
+ private static final String PASSWORD = "123";
+
+ private FakeFtpServer fakeFtpServer;
+
+ @BeforeAll
+ protected void setUp() throws Exception {
+ fakeFtpServer = new FakeFtpServer();
+ fakeFtpServer.setServerControlPort(PORT);
+
+ FileSystem fileSystem = new UnixFakeFileSystem();
+ fileSystem.add(new FileEntry(FILE, CONTENTS));
+ fakeFtpServer.setFileSystem(fileSystem);
+ UserAccount userAccount = new UserAccount(USERNAME, PASSWORD, HOME_DIR);
+ fakeFtpServer.addUserAccount(userAccount);
+
+ fakeFtpServer.start();
+ }
+
+ @AfterAll
+ protected void tearDown() throws Exception {
+ fakeFtpServer.stop();
+ }
+}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClientTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClientTest.java
new file mode 100644
index 00000000..13f1fbb9
--- /dev/null
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SftpClientTest.java
@@ -0,0 +1,103 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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.collectors.datafile.ftp;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.commons.io.IOUtils.toByteArray;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.github.stefanbirkner.fakesftpserver.rule.FakeSftpServerRule;
+import com.jcraft.jsch.ChannelSftp;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.SftpException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+public class SftpClientTest {
+ private static final String USERNAME = "bob";
+ private static final String PASSWORD = "123";
+ private static final String DUMMY_CONTENT = "dummy content";
+ private static final String LOCAL_DUMMY_FILE = "target/dummy.txt";
+ private static final String REMOTE_DUMMY_FILE = "/dummy_directory/dummy_file.txt";
+ private static final JSch JSCH = new JSch();
+ private static final int TIMEOUT = 2000;
+
+ @Rule
+ public final FakeSftpServerRule sftpServer = new FakeSftpServerRule().addUser(USERNAME, PASSWORD);
+
+ @Test
+ public void collectFile_withOKresponse() throws IOException, JSchException, SftpException {
+ SftpClient sftpClient = new SftpClient();
+ sftpServer.putFile(REMOTE_DUMMY_FILE, DUMMY_CONTENT, UTF_8);
+ byte[] file = downloadFile(sftpServer, REMOTE_DUMMY_FILE);
+ FileServerData expectedFileServerData = ImmutableFileServerData.builder().serverAddress("127.0.0.1")
+ .userId(USERNAME).password(PASSWORD).port(sftpServer.getPort()).build();
+ sftpClient.collectFile(expectedFileServerData, REMOTE_DUMMY_FILE,
+ LOCAL_DUMMY_FILE);
+ byte[] localFile = Files.readAllBytes(new File(LOCAL_DUMMY_FILE).toPath());
+ assertThat(new String(file, UTF_8)).isEqualTo(DUMMY_CONTENT);
+ assertThat(new String(localFile, UTF_8)).isEqualTo(DUMMY_CONTENT);
+ }
+
+ private static Session connectToServer(FakeSftpServerRule sftpServer) throws JSchException {
+ return connectToServerAtPort(sftpServer.getPort());
+ }
+
+ private static Session connectToServerAtPort(int port) throws JSchException {
+ Session session = createSessionWithCredentials(USERNAME, PASSWORD, port);
+ session.connect(TIMEOUT);
+ return session;
+ }
+
+ private static ChannelSftp connectSftpChannel(Session session) throws JSchException {
+ ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
+ channel.connect();
+ return channel;
+ }
+
+ private static Session createSessionWithCredentials(String username, String password, int port)
+ throws JSchException {
+ Session session = JSCH.getSession(username, "127.0.0.1", port);
+ session.setConfig("StrictHostKeyChecking", "no");
+ session.setPassword(password);
+ return session;
+ }
+
+ private static byte[] downloadFile(FakeSftpServerRule server, String path)
+ throws JSchException, SftpException, IOException {
+ Session session = connectToServer(server);
+ ChannelSftp channel = connectSftpChannel(session);
+ try {
+ InputStream is = channel.get(path);
+ return toByteArray(is);
+ } finally {
+ channel.disconnect();
+ session.disconnect();
+ }
+ }
+
+}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ScheduledXmlContextITest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ScheduledXmlContextITest.java
index b9aa2f78..b5f05a71 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ScheduledXmlContextITest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ScheduledXmlContextITest.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.integration;
@@ -26,6 +24,7 @@ import static org.mockito.Mockito.verify;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.dcaegen2.collectors.datafile.integration.junit5.mockito.MockitoExtension;
@@ -39,6 +38,7 @@ import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/27/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@Configuration
@@ -62,5 +62,3 @@ class ScheduledXmlContextITest extends AbstractTestNGSpringContextTests {
verify(scheduledTask, atLeast(1)).scheduleMainDatafileEventTask();
}
}
-
-
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ServiceMockProvider.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ServiceMockProvider.java
index 47107588..05a4f515 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ServiceMockProvider.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/ServiceMockProvider.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PROJECT
* ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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.
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/junit5/mockito/MockitoExtension.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/junit5/mockito/MockitoExtension.java
index df167425..bc4e6401 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/junit5/mockito/MockitoExtension.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/integration/junit5/mockito/MockitoExtension.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.integration.junit5.mockito;
@@ -36,9 +34,10 @@ 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 via Mockito 2.x's
+ * {@link Mock @Mock} annotation.
*/
public class MockitoExtension implements TestInstancePostProcessor, ParameterResolver {
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParserTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParserTest.java
index d7ceee82..dc51343d 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParserTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DmaapConsumerJsonParserTest.java
@@ -1,21 +1,17 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.service;
@@ -24,250 +20,161 @@ import static org.mockito.Mockito.spy;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
+
+import java.util.List;
import java.util.Optional;
+
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.dcaegen2.collectors.datafile.exceptions.DmaapNotFoundException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.DmaapConsumerJsonParser;
-import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
+import org.onap.dcaegen2.collectors.datafile.utils.JsonMessage;
+import org.onap.dcaegen2.collectors.datafile.utils.JsonMessage.AdditionalField;
+
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/8/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
class DmaapConsumerJsonParserTest {
@Test
- void whenPassingCorrectJson_validationNotThrowingAnException() {
- //given
- String message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\""
- + ":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":"
- + "3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":1517206400"
- + ",\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address\":"
- + "\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":"
- + "\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":"
- + "\"Nokia\"}}}]";
-
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":"
- + "3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":"
- + "1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address\":"
- + "\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":"
- + "\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":"
- + "\"Nokia\"}}}";
- ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
- .ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
- //when
+ void whenPassingCorrectJson_validationNotThrowingAnException() throws DmaapNotFoundException {
+ // given
+ AdditionalField additionalField = new JsonMessage.AdditionalFieldBuilder()
+ .location("ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz").compression("gzip")
+ .fileFormatType("org.3GPP.32.435#measCollec").fileFormatVersion("V10").build();
+ JsonMessage message = new JsonMessage.JsonMessageBuilder().changeIdentifier("PM_MEAS_FILES")
+ .changeType("FileReady").notificationFieldsVersion("1.0").addAdditionalField(additionalField).build();
+
+ String messageString = message.toString();
+
+ String parsedString = message.getParsed();
+
+ FileData expectedFileData = ImmutableFileData.builder().changeIdentifier("PM_MEAS_FILES")
+ .changeType("FileReady").location("ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz")
+ .compression("gzip").fileFormatType("org.3GPP.32.435#measCollec").fileFormatVersion("V10").build();
+ // when
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
- JsonElement jsonElement = new JsonParser().parse(parsed);
- Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
- .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- ConsumerDmaapModel consumerDmaapModel = dmaapConsumerJsonParser
- .getJsonObject(Mono.just((message))).block();
- //then
- Assertions.assertNotNull(consumerDmaapModel);
- Assertions.assertEquals(expectedObject, consumerDmaapModel);
+ JsonElement jsonElement = new JsonParser().parse(parsedString);
+ Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject())).when(dmaapConsumerJsonParser)
+ .getJsonObjectFromAnArray(jsonElement);
+ List<FileData> listOfFileData = dmaapConsumerJsonParser.getJsonObject(Mono.just((messageString))).block();
+ // then
+ Assertions.assertNotNull(listOfFileData);
+ Assertions.assertEquals(expectedFileData, listOfFileData.get(0));
}
@Test
- void whenPassingCorrectJsonWithoutIpv4_validationNotThrowingAnException() {
- //given
- String message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":"
- + "{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3}"
- + ",\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":1517206400,"
- + "\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv6Address\":"
- + "\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\""
- + ":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}]";
-
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3}"
- + ",\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":1517206400,"
- + "\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv6Address\":"
- + "\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\""
- + ":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}";
-
- //when
+ void whenPassingCorrectJsonWihoutLocation_validationThrowingAnException() {
+ AdditionalField additionalField = new JsonMessage.AdditionalFieldBuilder().compression("gzip")
+ .fileFormatType("org.3GPP.32.435#measCollec").fileFormatVersion("V10").build();
+ JsonMessage message = new JsonMessage.JsonMessageBuilder().changeIdentifier("PM_MEAS_FILES")
+ .changeType("FileReady").notificationFieldsVersion("1.0").addAdditionalField(additionalField).build();
+
+ String messageString = message.toString();
+
+ String parsedString = message.getParsed();
+
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
- JsonElement jsonElement = new JsonParser().parse(parsed);
- Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
- .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- dmaapConsumerJsonParser.getJsonObject(Mono.just((message)));
- ConsumerDmaapModel consumerDmaapModel = dmaapConsumerJsonParser.getJsonObject(Mono.just((message)))
- .block();
- //then
- ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder().ipv4("")
- .ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
- Assertions.assertNotNull(consumerDmaapModel);
- Assertions.assertEquals(expectedObject, consumerDmaapModel);
+ JsonElement jsonElement = new JsonParser().parse(parsedString);
+ Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject())).when(dmaapConsumerJsonParser)
+ .getJsonObjectFromAnArray(jsonElement);
+ StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(messageString))).expectSubscription()
+ .expectError(DmaapNotFoundException.class).verify();
}
@Test
- void whenPassingCorrectJsonWihoutIpv6_validationNotThrowingAnException() {
- //given
- String message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":"
- + "{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,"
- + "\"version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate"
- + "\":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address"
- + "\":\"10.16.123.234\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\","
- + "\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}]";
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,"
- + "\"version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate"
- + "\":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address"
- + "\":\"10.16.123.234\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\","
- + "\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}";
-
- ConsumerDmaapModel expectedObject = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234").ipv6("")
- .pnfName("NOKQTFCOC540002E").build();
- //when
+ void whenPassingCorrectJsonWihoutCompression_validationThrowingAnException() {
+ AdditionalField additionalField = new JsonMessage.AdditionalFieldBuilder()
+ .location("ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz")
+ .fileFormatType("org.3GPP.32.435#measCollec").fileFormatVersion("V10").build();
+ JsonMessage message = new JsonMessage.JsonMessageBuilder().changeIdentifier("PM_MEAS_FILES")
+ .changeType("FileReady").notificationFieldsVersion("1.0").addAdditionalField(additionalField).build();
+
+ String messageString = message.toString();
+
+ String parsedString = message.getParsed();
+
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
- JsonElement jsonElement = new JsonParser().parse(parsed);
- Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
- .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- ConsumerDmaapModel consumerDmaapModel = dmaapConsumerJsonParser.getJsonObject(Mono.just((message)))
- .block();
- //then
- Assertions.assertNotNull(consumerDmaapModel);
- Assertions.assertEquals(expectedObject, consumerDmaapModel);
+ JsonElement jsonElement = new JsonParser().parse(parsedString);
+ Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject())).when(dmaapConsumerJsonParser)
+ .getJsonObjectFromAnArray(jsonElement);
+ StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(messageString))).expectSubscription()
+ .expectError(DmaapNotFoundException.class).verify();
}
@Test
- void whenPassingCorrectJsonWihoutIpv4andIpv6_validationThrowingAnException() {
- String message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":"
- + "{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\""
- + ":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfSoftwareVersion\":"
- + "\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}]";
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\""
- + ":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfSoftwareVersion\":"
- + "\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":\"Nokia\"}}}";
- DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
- JsonElement jsonElement = new JsonParser().parse(parsed);
- Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
- .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(message)))
- .expectSubscription().expectError(DmaapNotFoundException.class).verify();
+ void whenPassingCorrectJsonWihoutFileFormatType_validationThrowingAnException() {
+ AdditionalField additionalField = new JsonMessage.AdditionalFieldBuilder()
+ .location("ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz").compression("gzip")
+ .fileFormatVersion("V10").build();
+ JsonMessage message = new JsonMessage.JsonMessageBuilder().changeIdentifier("PM_MEAS_FILES")
+ .changeType("FileReady").notificationFieldsVersion("1.0").addAdditionalField(additionalField).build();
+
+ String messageString = message.toString();
+ String parsedString = message.getParsed();
+
+ DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
+ JsonElement jsonElement = new JsonParser().parse(parsedString);
+ Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject())).when(dmaapConsumerJsonParser)
+ .getJsonObjectFromAnArray(jsonElement);
+ StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(messageString))).expectSubscription()
+ .expectError(DmaapNotFoundException.class).verify();
}
@Test
- void whenPassingJsonWithoutMandatoryHeaderInformation_validationThrowingAnException() {
- String parsed = "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\""
- + ",\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\",\"priority\""
- + ":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":\"<<SerialNumber>>\","
- + "\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3}}}";
+ void whenPassingCorrectJsonWihoutFileFormatVersion_validationThrowingAnException() {
+ AdditionalField additionalField = new JsonMessage.AdditionalFieldBuilder()
+ .location("ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz").compression("gzip")
+ .fileFormatType("org.3GPP.32.435#measCollec").build();
+ JsonMessage message = new JsonMessage.JsonMessageBuilder().changeIdentifier("PM_MEAS_FILES")
+ .changeType("FileReady").notificationFieldsVersion("1.0").addAdditionalField(additionalField).build();
+
+ String messageString = message.toString();
+
+ String parsedString = message.getParsed();
+
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
- JsonElement jsonElement = new JsonParser().parse(parsed);
- Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
- .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- String incorrectMessage =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\""
- + ",\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":"
- + "{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\":3"
- + "}}}]";
- StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(incorrectMessage)))
- .expectSubscription().expectError(DmaapNotFoundException.class).verify();
+ JsonElement jsonElement = new JsonParser().parse(parsedString);
+ Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject())).when(dmaapConsumerJsonParser)
+ .getJsonObjectFromAnArray(jsonElement);
+ StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(messageString))).expectSubscription()
+ .expectError(DmaapNotFoundException.class).verify();
}
+ // Fixed temprarily
@Test
- void whenPassingJsonWithoutPnfSerialNumberOrPnfVendorName_validationThrowingAnException() {
- String parsed = "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":"
- + "\"<<SerialNumber>>-reg\",\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\""
- + "internalHeaderFields\":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\","
- + "\"nfcNamingCode\":\"5DU\",\"priority\":\"Normal\",reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,"
- + "\"sourceId\":\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",startEpochMicrosec\":1519837825682,\""
- + "version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\""
- + ":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address\":"
- + "\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSoftwareVersion\":"
- + "\"v4.5.0.1\",\"pnfType\":\"AirScale\"}}}";
+ void whenPassingJsonWithoutMandatoryHeaderInformation_validationThrowingAnException() {
+ JsonMessage message = new JsonMessage.JsonMessageBuilder().changeIdentifier("PM_MEAS_FILES_INVALID")
+ .changeType("FileReady_INVALID").notificationFieldsVersion("1.0_INVALID").build();
+ String incorrectMessageString = message.toString();
+
+ String parsedString = message.getParsed();
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
- JsonElement jsonElement = new JsonParser().parse(parsed);
- Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
- .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- String jsonWithoutPnfVendorAndSerialNumber =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":"
- + "\"<<SerialNumber>>-reg\",\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\""
- + "internalHeaderFields\":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\","
- + "\"nfcNamingCode\":\"5DU\",\"priority\":\"Normal\",reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,"
- + "\"sourceId\":\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",startEpochMicrosec\":1519837825682,"
- + "\"version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\","
- + "\"pnfLastServiceDate\":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\","
- + "\"pnfOamIpv4Address\":\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
- + "\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\"}}}]";
- StepVerifier
- .create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutPnfVendorAndSerialNumber)))
- .expectSubscription().expectError(DmaapNotFoundException.class).verify();
+ JsonElement jsonElement = new JsonParser().parse(parsedString);
+ Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject())).when(dmaapConsumerJsonParser)
+ .getJsonObjectFromAnArray(jsonElement);
+ StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(incorrectMessageString)))
+ .expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
@Test
- void whenPassingJsonWithoutIpInformation_validationThrowingAnException() {
- String parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\""
- + ":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":"
- + "1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":"
- + "\"AJ02\",\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":"
- + "\"AirScale\"," + "\"pnfVendorName\":\"Nokia\"}}}";
+ void whenPassingJsonWithNullJsonElement_validationThrowingAnException() {
+ JsonMessage message = new JsonMessage.JsonMessageBuilder().build();
+ String incorrectMessageString = message.toString();
+
+ String parsedString = message.getParsed();
+
DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
- JsonElement jsonElement = new JsonParser().parse(parsed);
- Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
- .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- String jsonWithoutIpInformation =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\""
- + ":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\""
- + ":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfSerialNumber\""
- + ":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\","
- + "\"pnfVendorName\":\"Nokia\"}}}]";
- StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(jsonWithoutIpInformation)))
- .expectSubscription().expectError(DmaapNotFoundException.class).verify();
+ JsonElement jsonElement = new JsonParser().parse(parsedString);
+
+ Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject())).when(dmaapConsumerJsonParser)
+ .getJsonObjectFromAnArray(jsonElement);
+ StepVerifier.create(dmaapConsumerJsonParser.getJsonObject(Mono.just(incorrectMessageString)))
+ .expectSubscription().expectError(DmaapNotFoundException.class).verify();
}
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskImplTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskImplTest.java
deleted file mode 100644
index 05a99b43..00000000
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskImplTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-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 java.io.IOException;
-import java.util.Optional;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.function.Executable;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.exceptions.AaiNotFoundException;
-import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.AaiConsumerClient;
-import org.onap.dcaegen2.collectors.datafile.tasks.AaiConsumerTaskImpl;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableAaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/17/18
- */
-class AaiConsumerTaskImplTest {
-
- private static ConsumerDmaapModel consumerDmaapModel;
- private static AaiConsumerTaskImpl aaiConsumerTask;
-
- private static final String AAI_HOST = "/aai/v12/network/pnfs/pnf/NOKQTFCOC540002E";
- private static final Integer PORT = 1234;
- private static final String PROTOCOL = "https";
- private static final String USER_NAME_PASSWORD = "Datafile";
- private static final String BASE_PATH = "/aai/v12";
- private static final String PNF_PATH = "/network/pnfs/pnf";
-
- private static AaiClientConfiguration aaiClientConfiguration;
- private static AaiConsumerClient aaiConsumerClient;
- private static AppConfig appConfig;
-
- @BeforeAll
- static void setUp() {
- aaiClientConfiguration = new ImmutableAaiClientConfiguration.Builder()
- .aaiHost(AAI_HOST)
- .aaiPort(PORT)
- .aaiProtocol(PROTOCOL)
- .aaiUserName(USER_NAME_PASSWORD)
- .aaiUserPassword(USER_NAME_PASSWORD)
- .aaiIgnoreSslCertificateErrors(true)
- .aaiBasePath(BASE_PATH)
- .aaiPnfPath(PNF_PATH)
- .build();
- consumerDmaapModel = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
- .ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
- appConfig = mock(AppConfig.class);
-
- }
-
- @Test
- void whenPassedObjectDoesntFit_ThrowsDatafileTaskException() {
- //given/when
- when(appConfig.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration);
- aaiConsumerTask = new AaiConsumerTaskImpl(appConfig);
- Executable executableCode = () -> aaiConsumerTask.execute(null);
- //then
- Assertions
- .assertThrows(DatafileTaskException.class, executableCode, "Passing wrong object type to execute function");
-
- }
-
- @Test
- void whenPassedObjectFits_ReturnsCorrectStatus() throws DatafileTaskException, IOException {
- //given/when
- getAaiConsumerTask_WhenMockingHttpResponseCode("200", false);
- String response = aaiConsumerTask.execute(consumerDmaapModel);
-
- //then
- verify(aaiConsumerClient, times(1)).getHttpResponse(any(ConsumerDmaapModel.class));
- verifyNoMoreInteractions(aaiConsumerClient);
- Assertions.assertEquals("200", response);
- }
-
- @Test
- void whenPassedObjectFits_butIncorrectResponseReturns() throws IOException, AaiNotFoundException {
- //given/when
- getAaiConsumerTask_WhenMockingHttpResponseCode("400", false);
- String response = aaiConsumerTask.execute(consumerDmaapModel);
-
- //then
- verify(aaiConsumerClient, times(1)).getHttpResponse(any(ConsumerDmaapModel.class));
- verifyNoMoreInteractions(aaiConsumerClient);
- Assertions.assertEquals("400", response);
- }
-
- @Test
- void whenPassedObjectFits_ThrowsIoExceptionAndHandleIt() throws IOException {
- //given/when
- getAaiConsumerTask_WhenMockingHttpResponseCode(null, true);
- Executable executableCode = () -> aaiConsumerTask.execute(any(ConsumerDmaapModel.class));
- Assertions
- .assertThrows(DatafileTaskException.class, executableCode, "HttpClient throws IOException");
-
- //then
- verifyNoMoreInteractions(aaiConsumerClient);
- }
-
-
- private static void getAaiConsumerTask_WhenMockingHttpResponseCode(String httpResponseCode, boolean throwsException)
- throws IOException {
- aaiConsumerClient = mock(AaiConsumerClient.class);
- if (throwsException) {
- when(aaiConsumerClient.getHttpResponse(consumerDmaapModel)).thenThrow(IOException.class);
- } else {
- when(aaiConsumerClient.getHttpResponse(consumerDmaapModel)).thenReturn(Optional.of(httpResponseCode));
- }
- when(appConfig.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration);
- aaiConsumerTask = spy(new AaiConsumerTaskImpl(appConfig));
- when(aaiConsumerTask.resolveConfiguration()).thenReturn(aaiClientConfiguration);
- doReturn(aaiConsumerClient).when(aaiConsumerTask).resolveClient();
- }
-
-} \ No newline at end of file
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskSpy.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskSpy.java
deleted file mode 100644
index 9e1842b0..00000000
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiConsumerTaskSpy.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.tasks.AaiConsumerTask;
-import org.onap.dcaegen2.collectors.datafile.tasks.AaiConsumerTaskImpl;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-
-@Configuration
-public class AaiConsumerTaskSpy {
-
- /**
- * Mocking bean for tests.
- *
- * @return A&AI ConsumerTask spy
- */
- @Bean
- @Primary
- public AaiConsumerTask registerSimpleAaiPublisherTask() {
- AppConfig appConfig = mock(AppConfig.class);
- when(appConfig.getAaiClientConfiguration()).thenReturn(mock(AaiClientConfiguration.class));
- return spy(new AaiConsumerTaskImpl(appConfig));
- }
-} \ No newline at end of file
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTaskImplTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTaskImplTest.java
deleted file mode 100644
index f33fc931..00000000
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiProducerTaskImplTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-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.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.function.Executable;
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.producer.AaiProducerReactiveHttpClient;
-import org.onap.dcaegen2.collectors.datafile.tasks.AaiProducerTaskImpl;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableAaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
-
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/14/18
- */
-class AaiProducerTaskImplTest {
-
-
- private static final String AAI_HOST = "/aai/v11/network/pnfs/pnf/NOKQTFCOC540002E";
- private static final Integer PORT = 1234;
- private static final String PROTOCOL = "https";
- private static final String USER_NAME_PASSWORD = "Datafile";
- private static final String BASE_PATH = "/aai/v11";
- private static final String PNF_PATH = "/network/pnfs/pnf";
-
- private static ConsumerDmaapModel consumerDmaapModel;
- private static AaiProducerTaskImpl aaiProducerTask;
- private static AaiClientConfiguration aaiClientConfiguration;
- private static AaiProducerReactiveHttpClient aaiProducerReactiveHttpClient;
- private static AppConfig appConfig;
-
- @BeforeAll
- static void setUp() {
- aaiClientConfiguration = new ImmutableAaiClientConfiguration.Builder()
- .aaiHost(AAI_HOST)
- .aaiPort(PORT)
- .aaiProtocol(PROTOCOL)
- .aaiUserName(USER_NAME_PASSWORD)
- .aaiUserPassword(USER_NAME_PASSWORD)
- .aaiIgnoreSslCertificateErrors(true)
- .aaiBasePath(BASE_PATH)
- .aaiPnfPath(PNF_PATH)
- .build();
- consumerDmaapModel = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
- .ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
- appConfig = mock(AppConfig.class);
-
- }
-
- @Test
- void whenPassedObjectDoesntFit_ThrowsDatafileTaskException() {
- //given/when/
- when(appConfig.getAaiClientConfiguration()).thenReturn(aaiClientConfiguration);
- aaiProducerTask = new AaiProducerTaskImpl(appConfig);
- Executable executableCode = () -> aaiProducerTask.execute(null);
-
- //then
- Assertions
- .assertThrows(DatafileTaskException.class, executableCode, "Passing wrong object type to execute function");
- }
-
- @Test
- void whenPassedObjectFits_ReturnsCorrectStatus() throws DatafileTaskException {
- //given/when
- getAaiProducerTask_whenMockingResponseObject(200);
- Mono<ConsumerDmaapModel> response = aaiProducerTask.execute(Mono.just(consumerDmaapModel));
-
- //then
- verify(aaiProducerReactiveHttpClient, times(1)).getAaiProducerResponse(any());
- verifyNoMoreInteractions(aaiProducerReactiveHttpClient);
- Assertions.assertEquals(consumerDmaapModel, response.block());
-
- }
-
-
- @Test
- void whenPassedObjectFits_butIncorrectResponseReturns() throws DatafileTaskException {
- //given/when
- getAaiProducerTask_whenMockingResponseObject(400);
- StepVerifier.create(aaiProducerTask.execute(Mono.just(consumerDmaapModel))).expectSubscription()
- .expectError(DatafileTaskException.class).verify();
- //then
- 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/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiPublisherTaskSpy.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiPublisherTaskSpy.java
deleted file mode 100644
index 3beda94b..00000000
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/AaiPublisherTaskSpy.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-
-import org.onap.dcaegen2.collectors.datafile.config.AaiClientConfiguration;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.service.producer.AaiProducerReactiveHttpClient;
-import org.onap.dcaegen2.collectors.datafile.tasks.AaiProducerTask;
-import org.onap.dcaegen2.collectors.datafile.tasks.AaiProducerTaskImpl;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
- */
-@Configuration
-public class AaiPublisherTaskSpy {
-
- /**
- * Mocking bean for tests.
- *
- * @return A&AI ProducerTask spy
- */
- @Bean
- @Primary
- public AaiProducerTask registerSimpleAaiPublisherTask() {
- AppConfig appConfig = spy(AppConfig.class);
- doReturn(mock(AaiClientConfiguration.class)).when(appConfig).getAaiClientConfiguration();
- AaiProducerTaskImpl aaiProducerTask = spy(new AaiProducerTaskImpl(appConfig));
- AaiProducerReactiveHttpClient aaiProducerReactiveHttpClient = mock(AaiProducerReactiveHttpClient.class);
- doReturn(mock(AaiClientConfiguration.class)).when(aaiProducerTask).resolveConfiguration();
- doReturn(aaiProducerReactiveHttpClient).when(aaiProducerTask).resolveClient();
- return aaiProducerTask;
- }
-}
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 19ab1ab9..c21c5988 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
@@ -1,136 +1,190 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.tasks;
-import static org.junit.jupiter.api.Assertions.assertEquals;
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 com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import java.util.Optional;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
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;
+import org.onap.dcaegen2.collectors.datafile.ftp.FileCollector;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.DmaapConsumerJsonParser;
-import org.onap.dcaegen2.collectors.datafile.service.consumer.DMaaPConsumerReactiveHttpClient;
-import org.onap.dcaegen2.collectors.datafile.tasks.DmaapConsumerTaskImpl;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
+import org.onap.dcaegen2.collectors.datafile.service.DmaapConsumerJsonParser;
+import org.onap.dcaegen2.collectors.datafile.service.FileData;
+import org.onap.dcaegen2.collectors.datafile.service.ImmutableFileData;
+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 reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/17/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
class DmaapConsumerTaskImplTest {
+ private static final String PM_MEAS_CHANGE_IDINTIFIER = "PM_MEAS_FILES";
+ private static final String FILE_READY_CHANGE_TYPE = "FileReady";
+ private static final String FTPES_SCHEME = "ftpes://";
+ private static final String SFTP_SCHEME = "sftp://";
+ private static final String SERVER_ADDRESS = "192.168.0.101";
+ private static final String PORT_22 = "22";
+ private static final String PM_FILE_NAME = "A20161224.1030-1045.bin.gz";
+ private static final String REMOTE_FILE_LOCATION = "/ftp/rop/" + PM_FILE_NAME;
+ private static final String LOCAL_FILE_LOCATION = "target/" + PM_FILE_NAME;
+ private static final String FTPES_LOCATION = FTPES_SCHEME + SERVER_ADDRESS + ":" + PORT_22 + REMOTE_FILE_LOCATION;
+ private static final String SFTP_LOCATION = SFTP_SCHEME + SERVER_ADDRESS + ":" + PORT_22 + REMOTE_FILE_LOCATION;
+ private static final String GZIP_COMPRESSION = "gzip";
+ private static final String MEAS_COLLECT_FILE_FORMAT_TYPE = "org.3GPP.32.435#measCollec";
+ private static final String FILE_FORMAT_VERSION = "V10";
+
+ private static List<ConsumerDmaapModel> listOfConsumerDmaapModel = new ArrayList<ConsumerDmaapModel>();
- private static ConsumerDmaapModel consumerDmaapModel;
- private static DmaapConsumerTaskImpl dmaapConsumerTask;
- private static DMaaPConsumerReactiveHttpClient dMaaPConsumerReactiveHttpClient;
private static AppConfig appConfig;
private static DmaapConsumerConfiguration dmaapConsumerConfiguration;
- private static String message;
- private static String parsed;
+ private DmaapConsumerTaskImpl dmaapConsumerTask;
+ private DmaapConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient;
+
+ private static FileCollector fileCollectorMock;
+
+ private static String ftpesMessage;
+ private static List<FileData> ftpesFileDataAfterConsume = new ArrayList<FileData>();
+
+ private static String sftpMessage;
+ private static List<FileData> sftpFileDataAfterConsume = new ArrayList<FileData>();
@BeforeAll
- static void setUp() {
+ public static void setUp() {
dmaapConsumerConfiguration = new ImmutableDmaapConsumerConfiguration.Builder().consumerGroup("OpenDCAE-c12")
- .consumerId("c12").dmaapContentType("application/json").dmaapHostName("54.45.33.2").dmaapPortNumber(1234)
- .dmaapProtocol("https").dmaapUserName("Datafile").dmaapUserPassword("Datafile")
- .dmaapTopicName("unauthenticated.SEC_OTHER_OUTPUT").timeoutMs(-1).messageLimit(-1).build();
+ .consumerId("c12").dmaapContentType("application/json").dmaapHostName("54.45.33.2")
+ .dmaapPortNumber(1234).dmaapProtocol("https").dmaapUserName("Datafile").dmaapUserPassword("Datafile")
+ .dmaapTopicName("unauthenticated.NOTIFICATION").timeoutMS(-1).messageLimit(-1).build();
- consumerDmaapModel = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
- .ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
appConfig = mock(AppConfig.class);
- message =
- "[{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\""
- + ":{},\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,\"version\""
- + ":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\",\"pnfLastServiceDate\":"
- + "1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\",\"pnfOamIpv4Address\":"
- + "\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\",\"pnfSerialNumber\":"
- + "\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\",\"pnfVendorName\":"
- + "\"Nokia\"}}}]";
- parsed =
- "{\"event\":{\"commonEventHeader\":{\"domain\":\"other\",\"eventId\":\"<<SerialNumber>>-reg\",\"eventName\""
- + ":\"pnfRegistration_5GDU\",\"eventType\":\"pnfRegistration\",\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,\"nfNamingCode\":\"5GRAN\",\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\",\"reportingEntityName\":\"5GRAN_DU\",\"sequence\":0,\"sourceId\":"
- + "\"<<SerialNumber>>\",\"sourceName\":\"5GRAN_DU\",\"startEpochMicrosec\":1519837825682,"
- + "\"version\":3},\"otherFields\":{\"otherFieldsVersion\":1,\"pnfFamily\":\"BBU\","
- + "\"pnfLastServiceDate\":1517206400,\"pnfManufactureDate\":1516406400,\"pnfModelNumber\":\"AJ02\","
- + "\"pnfOamIpv4Address\":\"10.16.123.234\",\"pnfOamIpv6Address\":\"0:0:0:0:0:FFFF:0A10:7BEA\","
- + "\"pnfSerialNumber\":\"QTFCOC540002E\",\"pnfSoftwareVersion\":\"v4.5.0.1\",\"pnfType\":\"AirScale\","
- + "\"pnfVendorName\":\"Nokia\"}}}";
+
+ AdditionalField ftpesAdditionalField =
+ new JsonMessage.AdditionalFieldBuilder().location(FTPES_LOCATION).compression(GZIP_COMPRESSION)
+ .fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE).fileFormatVersion(FILE_FORMAT_VERSION).build();
+ JsonMessage ftpesJsonMessage = new JsonMessage.JsonMessageBuilder().changeIdentifier(PM_MEAS_CHANGE_IDINTIFIER)
+ .changeType(FILE_READY_CHANGE_TYPE).notificationFieldsVersion("1.0")
+ .addAdditionalField(ftpesAdditionalField).build();
+ ftpesMessage = ftpesJsonMessage.toString();
+ FileData ftpesFileData = ImmutableFileData.builder().changeIdentifier(PM_MEAS_CHANGE_IDINTIFIER)
+ .changeType(FILE_READY_CHANGE_TYPE).location(FTPES_LOCATION).compression(GZIP_COMPRESSION)
+ .fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE).fileFormatVersion(FILE_FORMAT_VERSION).build();
+ ftpesFileDataAfterConsume.add(ftpesFileData);
+
+ AdditionalField sftpAdditionalField =
+ new JsonMessage.AdditionalFieldBuilder().location(SFTP_LOCATION).compression(GZIP_COMPRESSION)
+ .fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE).fileFormatVersion(FILE_FORMAT_VERSION).build();
+ JsonMessage sftpJsonMessage = new JsonMessage.JsonMessageBuilder().changeIdentifier(PM_MEAS_CHANGE_IDINTIFIER)
+ .changeType(FILE_READY_CHANGE_TYPE).notificationFieldsVersion("1.0")
+ .addAdditionalField(sftpAdditionalField).build();
+ sftpMessage = sftpJsonMessage.toString();
+ FileData sftpFileData = ImmutableFileData.builder().changeIdentifier(PM_MEAS_CHANGE_IDINTIFIER)
+ .changeType(FILE_READY_CHANGE_TYPE).location(SFTP_LOCATION).compression(GZIP_COMPRESSION)
+ .fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE).fileFormatVersion(FILE_FORMAT_VERSION).build();
+ sftpFileDataAfterConsume.add(sftpFileData);
+
+
+ ImmutableConsumerDmaapModel consumerDmaapModel =
+ ImmutableConsumerDmaapModel.builder().location(LOCAL_FILE_LOCATION).compression(GZIP_COMPRESSION)
+ .fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE).fileFormatVersion(FILE_FORMAT_VERSION).build();
+ listOfConsumerDmaapModel.add(consumerDmaapModel);
+
+ fileCollectorMock = mock(FileCollector.class);
}
@Test
- void whenPassedObjectDoesntFit_DoesNotThrowDatafileTaskException() {
- //given
- prepareMocksForDmaapConsumer(Optional.empty());
+ public void whenPassedObjectDoesntFit_ThrowsDatafileTaskException() {
+ // given
+ prepareMocksForDmaapConsumer("", new ArrayList<FileData>());
- //then
+ // then
StepVerifier.create(dmaapConsumerTask.execute("Sample input")).expectSubscription()
- .expectError(DmaapEmptyResponseException.class).verify();
+ .expectError(DmaapEmptyResponseException.class).verify();
- verify(dMaaPConsumerReactiveHttpClient, times(1)).getDMaaPConsumerResponse();
+ verify(dmaapConsumerReactiveHttpClient, times(1)).getDmaapConsumerResponse();
}
@Test
- void whenPassedObjectFits_ReturnsCorrectResponse() {
- //given
- prepareMocksForDmaapConsumer(Optional.of(message));
- //when
- Mono<ConsumerDmaapModel> response = dmaapConsumerTask.execute("Sample input");
+ public void whenFtpes_ReturnsCorrectResponse() throws DatafileTaskException {
+ // given
+ prepareMocksForDmaapConsumer(ftpesMessage, ftpesFileDataAfterConsume);
+ // when
+ final List<ConsumerDmaapModel> arrayOfResponse = dmaapConsumerTask.execute("Sample input").block();
+ // then
+ verify(dmaapConsumerReactiveHttpClient, times(1)).getDmaapConsumerResponse();
+ verifyNoMoreInteractions(dmaapConsumerReactiveHttpClient);
+ verify(fileCollectorMock, times(1)).getFilesFromSender(ftpesFileDataAfterConsume);
+ verifyNoMoreInteractions(fileCollectorMock);
+ Assertions.assertEquals(listOfConsumerDmaapModel, arrayOfResponse);
- //then
- verify(dMaaPConsumerReactiveHttpClient, times(1)).getDMaaPConsumerResponse();
- assertEquals(consumerDmaapModel, response.block());
+ }
+ @Test
+ public void whenSftp_ReturnsCorrectResponse() throws DatafileTaskException {
+ // given
+ prepareMocksForDmaapConsumer(sftpMessage, sftpFileDataAfterConsume);
+ // when
+ final List<ConsumerDmaapModel> arrayOfResponse = dmaapConsumerTask.execute("Sample input").block();
+ // then
+ verify(dmaapConsumerReactiveHttpClient, times(1)).getDmaapConsumerResponse();
+ verifyNoMoreInteractions(dmaapConsumerReactiveHttpClient);
+ verify(fileCollectorMock, times(1)).getFilesFromSender(sftpFileDataAfterConsume);
+ verifyNoMoreInteractions(fileCollectorMock);
+ Assertions.assertEquals(listOfConsumerDmaapModel, arrayOfResponse);
}
- private void prepareMocksForDmaapConsumer(Optional<String> message) {
- DmaapConsumerJsonParser dmaapConsumerJsonParser = spy(new DmaapConsumerJsonParser());
- JsonElement jsonElement = new JsonParser().parse(parsed);
- Mockito.doReturn(Optional.of(jsonElement.getAsJsonObject()))
- .when(dmaapConsumerJsonParser).getJsonObjectFromAnArray(jsonElement);
- dMaaPConsumerReactiveHttpClient = mock(DMaaPConsumerReactiveHttpClient.class);
- when(dMaaPConsumerReactiveHttpClient.getDMaaPConsumerResponse()).thenReturn(Mono.just(message.orElse("")));
- when(appConfig.getDmaapConsumerConfiguration()).thenReturn(dmaapConsumerConfiguration);
- dmaapConsumerTask = spy(new DmaapConsumerTaskImpl(appConfig, dmaapConsumerJsonParser));
+ private void prepareMocksForDmaapConsumer(String message, List<FileData> fileDataAfterConsume) {
+ Mono<String> messageAsMono = Mono.just(message);
+ DmaapConsumerJsonParser dmaapConsumerJsonParserMock = mock(DmaapConsumerJsonParser.class);
+ dmaapConsumerReactiveHttpClient = mock(DmaapConsumerReactiveHttpClient.class);
+ when(dmaapConsumerReactiveHttpClient.getDmaapConsumerResponse()).thenReturn(messageAsMono);
+
+ if (!message.isEmpty()) {
+ when(dmaapConsumerJsonParserMock.getJsonObject(messageAsMono)).thenReturn(Mono.just(fileDataAfterConsume));
+ } else {
+ when(dmaapConsumerJsonParserMock.getJsonObject(messageAsMono))
+ .thenReturn(Mono.error(new DmaapEmptyResponseException()));
+ }
+ when(fileCollectorMock.getFilesFromSender(fileDataAfterConsume))
+ .thenReturn(Mono.just(listOfConsumerDmaapModel));
+
+ dmaapConsumerTask = spy(new DmaapConsumerTaskImpl(appConfig, dmaapConsumerReactiveHttpClient,
+ dmaapConsumerJsonParserMock, fileCollectorMock));
when(dmaapConsumerTask.resolveConfiguration()).thenReturn(dmaapConsumerConfiguration);
- doReturn(dMaaPConsumerReactiveHttpClient).when(dmaapConsumerTask).resolveClient();
+ doReturn(dmaapConsumerReactiveHttpClient).when(dmaapConsumerTask).resolveClient();
}
-} \ No newline at end of file
+}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskSpy.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskSpy.java
deleted file mode 100644
index de5c8535..00000000
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapConsumerTaskSpy.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-
-import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.service.consumer.DMaaPConsumerReactiveHttpClient;
-import org.onap.dcaegen2.collectors.datafile.tasks.DmaapConsumerTask;
-import org.onap.dcaegen2.collectors.datafile.tasks.DmaapConsumerTaskImpl;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/27/18
- */
-@Configuration
-public class DmaapConsumerTaskSpy {
-
- /**
- * Mocking bean for tests.
- *
- * @return DMaaP ConsumerTask spy
- */
- @Bean
- @Primary
- public DmaapConsumerTask registerSimpleDmaapConsumerTask() {
- AppConfig appConfig = spy(AppConfig.class);
- doReturn(mock(DmaapConsumerConfiguration.class)).when(appConfig).getDmaapConsumerConfiguration();
- DmaapConsumerTaskImpl dmaapConsumerTask = spy(new DmaapConsumerTaskImpl(appConfig));
- DMaaPConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient = mock(
- DMaaPConsumerReactiveHttpClient.class);
- doReturn(mock(DmaapConsumerConfiguration.class)).when(dmaapConsumerTask).resolveConfiguration();
- doReturn(dmaapConsumerReactiveHttpClient).when(dmaapConsumerTask).resolveClient();
- return dmaapConsumerTask;
- }
-}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapProducerTaskSpy.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapProducerTaskSpy.java
deleted file mode 100644
index 870c712e..00000000
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DmaapProducerTaskSpy.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
-import org.onap.dcaegen2.collectors.datafile.service.producer.DMaaPProducerReactiveHttpClient;
-import org.onap.dcaegen2.collectors.datafile.tasks.DmaapPublisherTask;
-import org.onap.dcaegen2.collectors.datafile.tasks.DmaapPublisherTaskImpl;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
- */
-@Configuration
-public class DmaapProducerTaskSpy {
-
- /**
- * Mocking bean for tests.
- *
- * @return DMaaP PublisherTask spy
- */
- @Bean
- @Primary
- public DmaapPublisherTask registerSimpleDmaapPublisherTask() {
- AppConfig appConfig = spy(AppConfig.class);
- doReturn(mock(DmaapPublisherConfiguration.class)).when(appConfig).getDmaapPublisherConfiguration();
- DmaapPublisherTaskImpl dmaapPublisherTask = spy(new DmaapPublisherTaskImpl(appConfig));
- DMaaPProducerReactiveHttpClient extendedDmaapProducerHttpClient = mock(
- DMaaPProducerReactiveHttpClient.class);
- doReturn(mock(DmaapPublisherConfiguration.class)).when(dmaapPublisherTask).resolveConfiguration();
- doReturn(extendedDmaapProducerHttpClient).when(dmaapPublisherTask).resolveClient();
- return dmaapPublisherTask;
- }
-}
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 2b79bc40..4f7787e9 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
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,12 +13,11 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.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;
@@ -30,95 +27,96 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
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.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.producer.DMaaPProducerReactiveHttpClient;
-import org.onap.dcaegen2.collectors.datafile.tasks.DmaapPublisherTaskImpl;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapPublisherConfiguration;
import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
+import org.onap.dcaegen2.collectors.datafile.service.producer.DmaapProducerReactiveHttpClient;
import org.springframework.http.HttpStatus;
+
import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/17/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
class DmaapPublisherTaskImplTest {
private static ConsumerDmaapModel consumerDmaapModel;
+ private static List<ConsumerDmaapModel> listOfConsumerDmaapModel;
private static DmaapPublisherTaskImpl dmaapPublisherTask;
- private static DMaaPProducerReactiveHttpClient dMaaPProducerReactiveHttpClient;
+ private static DmaapProducerReactiveHttpClient dMaaPProducerReactiveHttpClient;
private static AppConfig appConfig;
private static DmaapPublisherConfiguration dmaapPublisherConfiguration;
@BeforeAll
- static void setUp() {
- dmaapPublisherConfiguration = new ImmutableDmaapPublisherConfiguration.Builder()
- .dmaapContentType("application/json").dmaapHostName("54.45.33.2").dmaapPortNumber(1234)
- .dmaapProtocol("https").dmaapUserName("Datafile").dmaapUserPassword("Datafile")
- .dmaapTopicName("unauthenticated.SEC_OTHER_OUTPUT").build();
- consumerDmaapModel = ImmutableConsumerDmaapModel.builder().ipv4("10.16.123.234")
- .ipv6("0:0:0:0:0:FFFF:0A10:7BEA")
- .pnfName("NOKQTFCOC540002E").build();
+ public static void setUp() {
+ dmaapPublisherConfiguration =
+ new ImmutableDmaapPublisherConfiguration.Builder().dmaapContentType("application/json")
+ .dmaapHostName("54.45.33.2").dmaapPortNumber(1234).dmaapProtocol("https").dmaapUserName("DFC")
+ .dmaapUserPassword("DFC").dmaapTopicName("unauthenticated.VES_NOTIFICATION_OUTPUT").build();
+ consumerDmaapModel = ImmutableConsumerDmaapModel.builder().location("target/A20161224.1030-1045.bin.gz")
+ .compression("gzip").fileFormatType("org.3GPP.32.435#measCollec").fileFormatVersion("V10").build();
+ listOfConsumerDmaapModel = new ArrayList<ConsumerDmaapModel>();
+ listOfConsumerDmaapModel.add(consumerDmaapModel);
appConfig = mock(AppConfig.class);
}
@Test
- void whenPassedObjectDoesntFit_ThrowsDatafileTaskException() {
- //given
+ public void whenPassedObjectDoesntFit_ThrowsDatafileTaskException() {
+ // given
when(appConfig.getDmaapPublisherConfiguration()).thenReturn(dmaapPublisherConfiguration);
dmaapPublisherTask = new DmaapPublisherTaskImpl(appConfig);
- //when
+ // when
Executable executableFunction = () -> dmaapPublisherTask.execute(null);
- //then
- assertThrows(DatafileTaskException.class, executableFunction, "The specified parameter is incorrect");
+ // then
+ Assertions.assertThrows(DatafileTaskException.class, executableFunction,
+ "The specified parameter is incorrect");
}
@Test
- void whenPassedObjectFits_ReturnsCorrectStatus() throws DatafileTaskException {
- //given
+ public void whenPassedObjectFits_ReturnsCorrectStatus() throws DatafileTaskException {
+ // given
prepareMocksForTests(HttpStatus.OK.value());
- //when
- StepVerifier.create(dmaapPublisherTask.execute(Mono.just(consumerDmaapModel))).expectSubscription()
- .expectNext(HttpStatus.OK.toString()).verifyComplete();
+ // when
+ dmaapPublisherTask.execute(Mono.just(listOfConsumerDmaapModel));
- //then
- verify(dMaaPProducerReactiveHttpClient, times(1))
- .getDMaaPProducerResponse(any(Mono.class));
+ // then
+ verify(dMaaPProducerReactiveHttpClient, times(1)).getDmaapProducerResponse(any());
verifyNoMoreInteractions(dMaaPProducerReactiveHttpClient);
}
-
@Test
- void whenPassedObjectFits_butIncorrectResponseReturns() throws DmaapNotFoundException {
- //given
- prepareMocksForTests(HttpStatus.UNAUTHORIZED.value());
+ public void whenPassedObjectFits_ReturnsNoContent() throws DatafileTaskException {
+ // given
+ prepareMocksForTests(HttpStatus.NO_CONTENT.value());
- //when
- StepVerifier.create(dmaapPublisherTask.execute(Mono.just(consumerDmaapModel))).expectSubscription()
- .expectNext(String.valueOf(HttpStatus.UNAUTHORIZED.value())).verifyComplete();
+ dmaapPublisherTask.execute(Mono.just(listOfConsumerDmaapModel));
- //then
- verify(dMaaPProducerReactiveHttpClient, times(1)).getDMaaPProducerResponse(any(Mono.class));
+ // then
+ verify(dMaaPProducerReactiveHttpClient, times(1)).getDmaapProducerResponse(any());
verifyNoMoreInteractions(dMaaPProducerReactiveHttpClient);
}
-
private void prepareMocksForTests(Integer httpResponseCode) {
- dMaaPProducerReactiveHttpClient = mock(DMaaPProducerReactiveHttpClient.class);
- when(dMaaPProducerReactiveHttpClient.getDMaaPProducerResponse(any(Mono.class)))
- .thenReturn(Mono.just(httpResponseCode.toString()));
+ dMaaPProducerReactiveHttpClient = mock(DmaapProducerReactiveHttpClient.class);
+ when(dMaaPProducerReactiveHttpClient.getDmaapProducerResponse(any()))
+ .thenReturn(Mono.just(httpResponseCode.toString()));
+ when(appConfig.getDmaapPublisherConfiguration()).thenReturn(dmaapPublisherConfiguration);
dmaapPublisherTask = spy(new DmaapPublisherTaskImpl(appConfig));
when(dmaapPublisherTask.resolveConfiguration()).thenReturn(dmaapPublisherConfiguration);
doReturn(dMaaPProducerReactiveHttpClient).when(dmaapPublisherTask).resolveClient();
}
-} \ No newline at end of file
+}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduleControllerSpy.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduleControllerSpy.java
deleted file mode 100644
index d47d31d1..00000000
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduleControllerSpy.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.tasks;
-
-import static org.mockito.Mockito.spy;
-
-import org.onap.dcaegen2.collectors.datafile.tasks.AaiProducerTask;
-import org.onap.dcaegen2.collectors.datafile.tasks.DmaapConsumerTask;
-import org.onap.dcaegen2.collectors.datafile.tasks.DmaapPublisherTask;
-import org.onap.dcaegen2.collectors.datafile.tasks.ScheduledTasks;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/5/18
- */
-@Configuration
-public class ScheduleControllerSpy {
-
- @Autowired
- private DmaapConsumerTask dmaapConsumerTaskImplSpy;
-
- @Autowired
- private DmaapPublisherTask dmaapPublisherTaskImplSpy;
-
- @Autowired
- private AaiProducerTask aaiPublisherTaskImplSpy;
-
- @Bean
- @Primary
- public ScheduledTasks registerSimpleScheduledTask() {
- return spy(new ScheduledTasks(dmaapConsumerTaskImplSpy, dmaapPublisherTaskImplSpy, aaiPublisherTaskImplSpy));
- }
-}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java
new file mode 100644
index 00000000..264a9945
--- /dev/null
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java
@@ -0,0 +1,204 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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.collectors.datafile.utils;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Utility class to produce correctly formatted fileReady event Json messages.
+ *
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a> on 7/25/18
+ *
+ */
+public class JsonMessage {
+ private String changeIdentifier;
+ private String changeType;
+ private String notificationFieldsVersion;
+ private List<AdditionalField> arrayOfAdditionalFields;
+
+
+ @Override
+ public String toString() {
+ return "[" + getParsed() + "]";
+ }
+
+ /**
+ * Gets the message in parsed format.
+ * @return the massage in parsed format.
+ */
+ public String getParsed() {
+ StringBuffer additionalFieldsString = new StringBuffer();
+ if (arrayOfAdditionalFields.size() > 0) {
+ additionalFieldsString.append("\"arrayOfAdditionalFields\": [");
+ for (Iterator<AdditionalField> iterator = arrayOfAdditionalFields.iterator(); iterator.hasNext();) {
+ AdditionalField additionalField = iterator.next();
+ additionalFieldsString.append(additionalField.toString());
+ if (iterator.hasNext()) {
+ additionalFieldsString.append(",");
+ }
+ }
+ additionalFieldsString.append("]");
+ }
+
+ return "{" + "\"event\":{" + "\"commonEventHeader\":{" + "\"domain\":\"notification\","
+ + "\"eventId\":\"<<SerialNumber>>-reg\"," + "\"eventName\":\"EriNoti_RnNode_FileReady\","
+ + "\"eventType\":\"fileReady\"," + "\"internalHeaderFields\":{},"
+ + "\"lastEpochMicrosec\":1519837825682," + "\"nfNamingCode\":\"5GRAN\"," + "\"nfcNamingCode\":\"5DU\","
+ + "\"priority\":\"Normal\"," + "\"reportingEntityName\":\"5GRAN_DU\"," + "\"sequence\":0,"
+ + "\"sourceId\":\"<<SerialNumber>>\"," + "\"sourceName\":\"5GRAN_DU\","
+ + "\"startEpochMicrosec\":\"1519837825682\"," + "\"version\":3" + "}," + "\"notificationFields\":{"
+ + getAsStringIfParameterIsSet("changeIdentifier", changeIdentifier,
+ changeType != null || notificationFieldsVersion != null || arrayOfAdditionalFields.size() > 0)
+ + getAsStringIfParameterIsSet("changeType", changeType,
+ notificationFieldsVersion != null || arrayOfAdditionalFields.size() > 0)
+ + getAsStringIfParameterIsSet("notificationFieldsVersion", notificationFieldsVersion,
+ arrayOfAdditionalFields.size() > 0)
+ + additionalFieldsString.toString() + "}" + "}" + "}";
+ }
+
+ private JsonMessage(final JsonMessageBuilder builder) {
+ this.changeIdentifier = builder.changeIdentifier;
+ this.changeType = builder.changeType;
+ this.notificationFieldsVersion = builder.notificationFieldsVersion;
+ this.arrayOfAdditionalFields = builder.arrayOfAdditionalFields;
+ }
+
+ public static class AdditionalField {
+ private String location;
+ private String compression;
+ private String fileFormatType;
+ private String fileFormatVersion;
+
+ @Override
+ public String toString() {
+ return "{"
+ + getAsStringIfParameterIsSet("location", location,
+ compression != null || fileFormatType != null || fileFormatVersion != null)
+ + getAsStringIfParameterIsSet("compression", compression,
+ fileFormatType != null || fileFormatVersion != null)
+ + getAsStringIfParameterIsSet("fileFormatType", fileFormatType, fileFormatVersion != null)
+ + getAsStringIfParameterIsSet("fileFormatVersion", fileFormatVersion, false) + "}";
+ }
+
+
+ private AdditionalField(AdditionalFieldBuilder builder) {
+ this.location = builder.location;
+ this.compression = builder.compression;
+ this.fileFormatType = builder.fileFormatType;
+ this.fileFormatVersion = builder.fileFormatVersion;
+ }
+
+ }
+
+ public static class AdditionalFieldBuilder {
+ private String location;
+ private String compression;
+ private String fileFormatType;
+ private String fileFormatVersion;
+
+ public AdditionalFieldBuilder location(String location) {
+ this.location = location;
+ return this;
+ }
+
+ public AdditionalFieldBuilder compression(String compression) {
+ this.compression = compression;
+ return this;
+ }
+
+ public AdditionalFieldBuilder fileFormatType(String fileFormatType) {
+ this.fileFormatType = fileFormatType;
+ return this;
+ }
+
+ public AdditionalFieldBuilder fileFormatVersion(String fileFormatVersion) {
+ this.fileFormatVersion = fileFormatVersion;
+ return this;
+ }
+
+ public AdditionalField build() {
+ return new AdditionalField(this);
+ }
+ }
+
+ public static class JsonMessageBuilder {
+ private String changeIdentifier;
+ private String changeType;
+ private String notificationFieldsVersion;
+ private List<AdditionalField> arrayOfAdditionalFields = new ArrayList<AdditionalField>();
+
+ public JsonMessageBuilder changeIdentifier(String changeIdentifier) {
+ this.changeIdentifier = changeIdentifier;
+ return this;
+ }
+
+ public JsonMessageBuilder changeType(String changeType) {
+ this.changeType = changeType;
+ return this;
+ }
+
+ public JsonMessageBuilder notificationFieldsVersion(String notificationFieldsVersion) {
+ this.notificationFieldsVersion = notificationFieldsVersion;
+ return this;
+ }
+
+ public JsonMessageBuilder addAdditionalField(AdditionalField additionalField) {
+ this.arrayOfAdditionalFields.add(additionalField);
+ return this;
+ }
+
+ public JsonMessage build() {
+ return new JsonMessage(this);
+ }
+ }
+
+ private static String getAsStringIfParameterIsSet(String parameterName, String parameterValue,
+ boolean withSeparator) {
+ String result = "";
+ if (parameterValue != null) {
+ result = "\"" + parameterName + "\":\"" + parameterValue + "\"";
+
+ if (withSeparator) {
+ result = result + ",";
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Can be used to produce a correct test Json message. Tip! Check the formatting with
+ * <a href="https://jsonformatter.org/">Json fomatter</a>
+ *
+ * @param args Not used
+ */
+ public static void main(String[] args) {
+ AdditionalField additionalField = new JsonMessage.AdditionalFieldBuilder()
+ .location("ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz").compression("gzip")
+ .fileFormatType("org.3GPP.32.435#measCollec").fileFormatVersion("V10").build();
+ AdditionalField secondAdditionalField = new JsonMessage.AdditionalFieldBuilder()
+ .location("sftp://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz").compression("gzip")
+ .fileFormatType("org.3GPP.32.435#measCollec").fileFormatVersion("V10").build();
+ JsonMessage message = new JsonMessage.JsonMessageBuilder().changeIdentifier("PM_MEAS_FILES")
+ .changeType("FileReady").notificationFieldsVersion("1.0").addAdditionalField(additionalField)
+ .addAdditionalField(secondAdditionalField).build();
+ System.out.println(message.toString());
+ }
+}
diff --git a/datafile-app-server/src/test/resources/datafile_endpoints.json b/datafile-app-server/src/test/resources/datafile_endpoints.json
index 599315b6..f6b65fba 100644
--- a/datafile-app-server/src/test/resources/datafile_endpoints.json
+++ b/datafile-app-server/src/test/resources/datafile_endpoints.json
@@ -1,47 +1,28 @@
{
- "configs": {
- "aai": {
- "aaiClientConfiguration": {
- "aaiHost": "localhost",
- "aaiPort": 8080,
- "aaiIgnoreSSLCertificateErrors": true,
- "aaiProtocol": "https",
- "aaiUserName": "AAI",
- "aaiUserPassword": "AAI",
- "aaiBasePath": "/aai/v11",
- "aaiPnfPath": "/network/pnfs/pnf",
- "aaiHeaders": {
- "X-FromAppId": "datafile",
- "X-TransactionId": "9999",
- "Accept": "application/json",
- "Real-Time": "true",
- "Content-Type":"application/merge-patch+json"
+ "configs": {
+ "dmaap": {
+ "dmaapConsumerConfiguration": {
+ "consumerGroup": "notification",
+ "consumerId": "1",
+ "dmaapContentType": "application/json",
+ "dmaapHostName": "localhost",
+ "dmaapPortNumber": 3904,
+ "dmaapProtocol": "http",
+ "dmaapTopicName": "/events/unauthenticated.VES_NOTIFICATION_OUTPUT",
+ "dmaapUserName": "admin",
+ "dmaapUserPassword": "admin",
+ "messageLimit": 1000,
+ "timeoutMS": 1000
+ },
+ "dmaapProducerConfiguration": {
+ "dmaapContentType": "application/octet-stream",
+ "dmaapHostName": "localhost",
+ "dmaapPortNumber": 3905,
+ "dmaapProtocol": "http",
+ "dmaapTopicName": "/events/unauthenticated.VES_NOTIFICATION_OUTPUT",
+ "dmaapUserName": "admin",
+ "dmaapUserPassword": "admin"
+ }
}
- }
- },
- "dmaap": {
- "dmaapConsumerConfiguration": {
- "consumerGroup": "other",
- "consumerId": "1",
- "dmaapContentType": "application/json",
- "dmaapHostName": "localhost",
- "dmaapPortNumber": 2222,
- "dmaapProtocol": "http",
- "dmaapTopicName": "/events/pnfReady",
- "dmaapUserName": "admin",
- "dmaapUserPassword": "admin",
- "messageLimit": 1000,
- "timeoutMS": 1000
- },
- "dmaapProducerConfiguration": {
- "dmaapContentType": "application/json",
- "dmaapHostName": "localhost",
- "dmaapPortNumber": 2223,
- "dmaapProtocol": "http",
- "dmaapTopicName": "/events/pnfReady",
- "dmaapUserName": "admin",
- "dmaapUserPassword": "admin"
- }
}
- }
-} \ No newline at end of file
+}
diff --git a/datafile-commons/pom.xml b/datafile-commons/pom.xml
index 1af046b9..3f551542 100644
--- a/datafile-commons/pom.xml
+++ b/datafile-commons/pom.xml
@@ -1,23 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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=========================================================
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>datafile</artifactId>
<groupId>org.onap.dcaegen2.collectors</groupId>
+ <artifactId>datafile</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
- <artifactId>datafile-commons</artifactId>
<groupId>org.onap.dcaegen2.collectors.datafile</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <artifactId>datafile-commons</artifactId>
<packaging>jar</packaging>
<properties>
<main.basedir>${project.parent.basedir}</main.basedir>
</properties>
+
<dependencies>
<dependency>
<groupId>org.immutables</groupId>
@@ -36,7 +53,7 @@
<artifactId>commons-lang3</artifactId>
</dependency>
- <!-- TEST DEPENDENCIES-->
+ <!-- TEST DEPENDENCIES -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
@@ -53,7 +70,7 @@
<scope>test</scope>
</dependency>
- <!-- LOGGING DEPENDENCIES-->
+ <!-- LOGGING DEPENDENCIES -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
@@ -67,4 +84,4 @@
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java
index cc46ab80..d7bcbe4b 100644
--- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java
+++ b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,34 +13,28 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.model;
+import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.TypeAdapterFactory;
-import java.util.ServiceLoader;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CommonFunctions {
- private CommonFunctions() {
- }
+ private static final Logger logger = LoggerFactory.getLogger(CommonFunctions.class);
+
+ private static Gson gson = new GsonBuilder().create();
+
+
+ private CommonFunctions() {}
- /**
- * Method for serialization object by GSON.
- *
- * @param consumerDmaapModel - object which will be serialized
- * @return string from serialization
- */
public static String createJsonBody(ConsumerDmaapModel consumerDmaapModel) {
- GsonBuilder gsonBuilder = new GsonBuilder();
- ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
- return gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder().ipv4(consumerDmaapModel.getIpv4())
- .ipv6(consumerDmaapModel.getIpv6()).pnfName(consumerDmaapModel.getPnfName()).build());
+ return gson.toJson(consumerDmaapModel);
}
}
diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java
index 3da08d7c..94e7ccd7 100644
--- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java
+++ b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java
@@ -1,43 +1,46 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.model;
-import com.google.gson.annotations.SerializedName;
import org.immutables.gson.Gson;
import org.immutables.value.Value;
+import com.google.gson.annotations.SerializedName;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/8/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
@Value.Immutable
-@Gson.TypeAdapters(fieldNamingStrategy = true)
+@Gson.TypeAdapters
public interface ConsumerDmaapModel {
- @SerializedName(value = "pnf-name", alternate = "pnf-name")
- String getPnfName();
+ @SerializedName("location")
+ String getLocation();
+
+ @SerializedName("compression")
+ String getCompression();
+
+ @SerializedName("fileFormatType")
+ String getFileFormatType();
+
+ @SerializedName("fileFormatVersion")
+ String getFileFormatVersion();
- @SerializedName(value = "ipaddress-v4-oam", alternate = "ipaddress-v4-oam")
- String getIpv4();
- @SerializedName(value = "ipaddress-v6-oam", alternate = "ipaddress-v6-oam")
- String getIpv6();
}
diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelForUnitTest.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelForUnitTest.java
index ad7bbd8e..103a70e8 100644
--- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelForUnitTest.java
+++ b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelForUnitTest.java
@@ -1,53 +1,51 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.model;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-
public class ConsumerDmaapModelForUnitTest implements ConsumerDmaapModel {
+ private final String location;
+ private final String compression;
+ private final String fileFormatType;
+ private final String fileFormatVersion;
- private final String pnfName;
- private final String ipv4;
- private final String ipv6;
-
- /**
- * Class for testing serialization of ConsumerDmaapModel.
- */
public ConsumerDmaapModelForUnitTest() {
- this.pnfName = "NOKnhfsadhff";
- this.ipv4 = "256.22.33.155";
- this.ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
-
+ this.location = "target/A20161224.1030-1045.bin.gz";
+ this.compression = "gzip";
+ this.fileFormatType = "org.3GPP.32.435#measCollec";
+ this.fileFormatVersion = "V10";
}
- public String getPnfName() {
- return pnfName;
+ @Override
+ public String getLocation() {
+ return location;
}
- public String getIpv4() {
- return ipv4;
+ @Override
+ public String getCompression() {
+ return compression;
}
- public String getIpv6() {
- return ipv6;
+ @Override
+ public String getFileFormatType() {
+ return fileFormatType;
}
+ @Override
+ public String getFileFormatVersion() {
+ return fileFormatVersion;
+ }
}
diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtils.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtils.java
index 0b351ae6..af41b356 100644
--- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtils.java
+++ b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtils.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.model.utils;
diff --git a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java
index d3a0fb18..675589fb 100644
--- a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java
+++ b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java
@@ -1,21 +1,17 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.model;
@@ -29,14 +25,13 @@ import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.model.CommonFunctions;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModelForUnitTest;
class CommonFunctionsTest {
-
// Given
private ConsumerDmaapModel model = new ConsumerDmaapModelForUnitTest();
+ private static final String EXPECTED_RESULT =
+ "{\"location\":\"target/A20161224.1030-1045.bin.gz\",\"compression\":\"gzip\","
+ + "\"fileFormatType\":\"org.3GPP.32.435#measCollec\",\"fileFormatVersion\":\"V10\"}";
private static final HttpResponse httpResponseMock = mock(HttpResponse.class);
private static final HttpEntity httpEntityMock = mock(HttpEntity.class);
@@ -50,8 +45,6 @@ class CommonFunctionsTest {
@Test
void createJsonBody_shouldReturnJsonInString() {
- String expectedResult = "{\"pnf-name\":\"NOKnhfsadhff\",\"ipaddress-v4-oam\":\"256.22.33.155\""
- + ",\"ipaddress-v6-oam\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"}";
- assertEquals(expectedResult, CommonFunctions.createJsonBody(model));
+ assertEquals(EXPECTED_RESULT, CommonFunctions.createJsonBody(model));
}
}
diff --git a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelTest.java b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelTest.java
index 50eb434b..dcccd5f5 100644
--- a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelTest.java
+++ b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelTest.java
@@ -1,50 +1,45 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ * 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=========================================================
+ * 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.collectors.datafile.model;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.model.ImmutableConsumerDmaapModel;
-class ConsumerDmaapModelTest {
+public class ConsumerDmaapModelTest {
+
+ // Given
+ private ConsumerDmaapModel consumerDmaapModel;
+ private static final String LOCATION = "target/A20161224.1030-1045.bin.gz";
+ private static final String COMPRESSION = "gzip";
+ private static final String FILE_FORMAT_TYPE = "org.3GPP.32.435#measCollec";
+ private static final String FILE_FORMAT_VERSION = "V10";
@Test
- void consumerDmaapModelBuilder_shouldBuildAnObject() {
+ public void consumerDmaapModelBuilder_shouldBuildAnObject() {
// When
- // Given
- String pnfName = "NOKnhfsadhff";
- String ipv4 = "11.22.33.155";
- String ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
- ConsumerDmaapModel consumerDmaapModel = ImmutableConsumerDmaapModel.builder()
- .pnfName(pnfName)
- .ipv4(ipv4)
- .ipv6(ipv6)
- .build();
+ consumerDmaapModel = ImmutableConsumerDmaapModel.builder().location(LOCATION).compression(COMPRESSION)
+ .fileFormatType(FILE_FORMAT_TYPE).fileFormatVersion(FILE_FORMAT_VERSION).build();
// Then
Assertions.assertNotNull(consumerDmaapModel);
- Assertions.assertEquals(pnfName, consumerDmaapModel.getPnfName());
- Assertions.assertEquals(ipv4, consumerDmaapModel.getIpv4());
- Assertions.assertEquals(ipv6, consumerDmaapModel.getIpv6());
+ Assertions.assertEquals(LOCATION, consumerDmaapModel.getLocation());
+ Assertions.assertEquals(COMPRESSION, consumerDmaapModel.getCompression());
+ Assertions.assertEquals(FILE_FORMAT_TYPE, consumerDmaapModel.getFileFormatType());
+ Assertions.assertEquals(FILE_FORMAT_VERSION, consumerDmaapModel.getFileFormatVersion());
}
}
diff --git a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtilsTest.java b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtilsTest.java
index 544470a4..83fe14a7 100644
--- a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtilsTest.java
+++ b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/utils/HttpUtilsTest.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.model.utils;
@@ -25,17 +23,17 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.model.utils.HttpUtils;
-class HttpUtilsTest {
+
+public class HttpUtilsTest {
@Test
- void isSuccessfulResponseCode_shouldReturnTrue() {
+ public void isSuccessfulResponseCode_shouldReturnTrue() {
assertTrue(HttpUtils.isSuccessfulResponseCode(HttpUtils.SC_ACCEPTED));
}
@Test
- void isSuccessfulResponseCode_shouldReturnFalse() {
+ public void isSuccessfulResponseCode_shouldReturnFalse() {
assertFalse(HttpUtils.isSuccessfulResponseCode(HttpStatus.SC_BAD_GATEWAY));
}
-} \ No newline at end of file
+}
diff --git a/datafile-dmaap-client/pom.xml b/datafile-dmaap-client/pom.xml
index 86e41c38..d458eca3 100644
--- a/datafile-dmaap-client/pom.xml
+++ b/datafile-dmaap-client/pom.xml
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ ============LICENSE_START=======================================================
- ~ Datafile Collector Service
- ~ ================================================================================
- ~ Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ ~ Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ ~ 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,
@@ -22,20 +20,21 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>datafile</artifactId>
<groupId>org.onap.dcaegen2.collectors</groupId>
+ <artifactId>datafile</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>datafile-dmaap-client</artifactId>
<groupId>org.onap.dcaegen2.collectors.datafile</groupId>
+ <artifactId>datafile-dmaap-client</artifactId>
<packaging>jar</packaging>
<properties>
<main.basedir>${project.parent.basedir}</main.basedir>
</properties>
+
<dependencies>
<!-- DEVELOPMENT DEPENDENCIES -->
@@ -50,13 +49,15 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
- <version>5.0.5.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-reactor-netty</artifactId>
- <version>2.0.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.onap.dcaegen2.collectors.datafile</groupId>
@@ -64,23 +65,7 @@
<version>1.0.0-SNAPSHOT</version>
</dependency>
-
- <!-- LOGGING DEPENDENCIES -->
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- </dependency>
-
-
- <!-- TEST DEPENDENCIES-->
+ <!-- TEST DEPENDENCIES -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
@@ -110,10 +95,27 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+
+ <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher -->
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-launcher</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ </dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <version>2.0.1</version>
+ </dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java
index 57b11127..dd7519f9 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,14 +13,13 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.config;
import org.immutables.gson.Gson;
import org.immutables.value.Value;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
import org.springframework.stereotype.Component;
/**
@@ -43,20 +40,20 @@ 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();
- public interface Builder extends
- DmaapCustomConfig.Builder<DmaapConsumerConfiguration, DmaapConsumerConfiguration.Builder> {
+ public interface Builder
+ extends DmaapCustomConfig.Builder<DmaapConsumerConfiguration, DmaapConsumerConfiguration.Builder> {
Builder consumerId(String consumerId);
Builder consumerGroup(String consumerGroup);
- Builder timeoutMs(Integer timeoutMs);
+ Builder timeoutMS(Integer timeoutMS);
Builder messageLimit(Integer messageLimit);
}
@@ -65,4 +62,4 @@ public abstract class DmaapConsumerConfiguration implements DmaapCustomConfig {
return ImmutableDmaapConsumerConfiguration.builder();
}
-} \ No newline at end of file
+}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java
index 31bbfc0e..0b1d99eb 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.config;
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java
index cd520569..d0918446 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,16 +13,13 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.config;
import org.immutables.gson.Gson;
import org.immutables.value.Value;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapCustomConfig;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapPublisherConfiguration;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
@@ -36,8 +31,8 @@ public abstract class DmaapPublisherConfiguration implements DmaapCustomConfig {
private static final long serialVersionUID = 1L;
- interface Builder extends
- DmaapCustomConfig.Builder<DmaapPublisherConfiguration, DmaapPublisherConfiguration.Builder> {
+ interface Builder
+ extends DmaapCustomConfig.Builder<DmaapPublisherConfiguration, DmaapPublisherConfiguration.Builder> {
}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DMaaPReactiveWebClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClient.java
index b4cbfeea..d5878b0d 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DMaaPReactiveWebClient.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClient.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.service;
@@ -23,18 +21,18 @@ package org.onap.dcaegen2.collectors.datafile.service;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
import org.onap.dcaegen2.collectors.datafile.config.DmaapCustomConfig;
-import org.onap.dcaegen2.collectors.datafile.service.DMaaPReactiveWebClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.WebClient;
+
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18
*/
-public class DMaaPReactiveWebClient {
+public class DmaapReactiveWebClient {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -43,12 +41,12 @@ public class DMaaPReactiveWebClient {
private String dmaaPUserPassword;
/**
- * Creating DMaaPReactiveWebClient passing to them basic DMaaPConfig.
+ * Creating DmaapReactiveWebClient passing to them basic DmaapConfig.
*
* @param dmaapCustomConfig - configuration object
- * @return DMaaPReactiveWebClient
+ * @return DmaapReactiveWebClient
*/
- public DMaaPReactiveWebClient fromConfiguration(DmaapCustomConfig dmaapCustomConfig) {
+ public DmaapReactiveWebClient fromConfiguration(DmaapCustomConfig dmaapCustomConfig) {
this.dmaaPUserName = dmaapCustomConfig.dmaapUserName();
this.dmaaPUserPassword = dmaapCustomConfig.dmaapUserPassword();
this.dmaaPContentType = dmaapCustomConfig.dmaapContentType();
diff --git a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/HttpUtils.java
index 5ab9b4a6..2b44233f 100644
--- a/datafile-aai-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/AaiClient.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/HttpUtils.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 Nordix Foundation. 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
@@ -15,15 +13,18 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.service;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.HttpStatus;
-@FunctionalInterface
-public interface AaiClient {
- CloseableHttpClient getAaiHttpClient();
-}
+public final class HttpUtils implements HttpStatus {
+
+ private HttpUtils() {}
+ public static boolean isSuccessfulResponseCode(Integer statusCode) {
+ return statusCode >= 200 && statusCode < 300;
+ }
+}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DMaaPConsumerReactiveHttpClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClient.java
index 1fcebeac..ad9e6fe7 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DMaaPConsumerReactiveHttpClient.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClient.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,26 +13,28 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.service.consumer;
import java.net.URI;
import java.net.URISyntaxException;
+
import org.apache.http.client.utils.URIBuilder;
import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.collectors.datafile.service.consumer.DMaaPConsumerReactiveHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.client.WebClient;
+
import reactor.core.publisher.Mono;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 6/26/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
-public class DMaaPConsumerReactiveHttpClient {
+public class DmaapConsumerReactiveHttpClient {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -47,11 +47,11 @@ public class DMaaPConsumerReactiveHttpClient {
private final String consumerId;
/**
- * Constructor of DMaaPConsumerReactiveHttpClient.
+ * Constructor of DmaapConsumerReactiveHttpClient.
*
* @param consumerConfiguration - DMaaP consumer configuration object
*/
- public DMaaPConsumerReactiveHttpClient(DmaapConsumerConfiguration consumerConfiguration) {
+ public DmaapConsumerReactiveHttpClient(DmaapConsumerConfiguration consumerConfiguration) {
this.dmaapHostName = consumerConfiguration.dmaapHostName();
this.dmaapProtocol = consumerConfiguration.dmaapProtocol();
this.dmaapPortNumber = consumerConfiguration.dmaapPortNumber();
@@ -65,7 +65,7 @@ public class DMaaPConsumerReactiveHttpClient {
*
* @return reactive response from DMaaP in string format
*/
- public Mono<String> getDMaaPConsumerResponse() {
+ public Mono<String> getDmaapConsumerResponse() {
try {
return webClient
.get()
@@ -78,7 +78,7 @@ public class DMaaPConsumerReactiveHttpClient {
Mono.error(new Exception("HTTP 500")))
.bodyToMono(String.class);
} catch (URISyntaxException e) {
- logger.warn("Exception while evaluating URI ");
+ logger.error("Unable to parse URI in message from xNF.", e);
return Mono.error(e);
}
}
@@ -87,7 +87,7 @@ public class DMaaPConsumerReactiveHttpClient {
return dmaapTopicName + "/" + consumerGroup + "/" + consumerId;
}
- public DMaaPConsumerReactiveHttpClient createDMaaPWebClient(WebClient webClient) {
+ public DmaapConsumerReactiveHttpClient createDmaapWebClient(WebClient webClient) {
this.webClient = webClient;
return this;
}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DMaaPProducerReactiveHttpClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DMaaPProducerReactiveHttpClient.java
deleted file mode 100644
index c6889df4..00000000
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DMaaPProducerReactiveHttpClient.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service.producer;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import org.apache.http.client.utils.URIBuilder;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.service.producer.DMaaPProducerReactiveHttpClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.client.WebClient;
-import reactor.core.publisher.Mono;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18
- */
-public class DMaaPProducerReactiveHttpClient {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private WebClient webClient;
- private final String dmaapHostName;
- private final Integer dmaapPortNumber;
- private final String dmaapProtocol;
- private final String dmaapTopicName;
-
- /**
- * Constructor DMaaPProducerReactiveHttpClient.
- *
- * @param dmaapPublisherConfiguration - DMaaP producer configuration object
- */
- public DMaaPProducerReactiveHttpClient(DmaapPublisherConfiguration dmaapPublisherConfiguration) {
- this.dmaapHostName = dmaapPublisherConfiguration.dmaapHostName();
- this.dmaapProtocol = dmaapPublisherConfiguration.dmaapProtocol();
- this.dmaapPortNumber = dmaapPublisherConfiguration.dmaapPortNumber();
- this.dmaapTopicName = dmaapPublisherConfiguration.dmaapTopicName();
- }
-
- /**
- * Function for calling DMaaP HTTP producer - post request to DMaaP.
- *
- * @param consumerDmaapModelMono - object which will be sent to DMaaP
- * @return status code of operation
- */
- public Mono<String> getDMaaPProducerResponse(Mono<ConsumerDmaapModel> consumerDmaapModelMono) {
- try {
- return webClient
- .post()
- .uri(getUri())
- .body(BodyInserters.fromObject(consumerDmaapModelMono))
- .retrieve()
- .onStatus(HttpStatus::is4xxClientError, clientResponse ->
- Mono.error(new Exception("HTTP 400"))
- )
- .onStatus(HttpStatus::is5xxServerError, clientResponse ->
- Mono.error(new Exception("HTTP 500")))
- .bodyToMono(String.class);
- } catch (URISyntaxException e) {
- logger.warn("Exception while evaluating URI");
- return Mono.error(e);
- }
- }
-
- public DMaaPProducerReactiveHttpClient createDMaaPWebClient(WebClient webClient) {
- this.webClient = webClient;
- return this;
- }
-
- URI getUri() throws URISyntaxException {
- return new URIBuilder().setScheme(dmaapProtocol).setHost(dmaapHostName).setPort(dmaapPortNumber)
- .setPath(dmaapTopicName).build();
- }
-
-}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java
new file mode 100644
index 00000000..8010bdc1
--- /dev/null
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java
@@ -0,0 +1,151 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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.collectors.datafile.service.producer;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.apache.http.HttpHeaders;
+import org.apache.http.client.utils.URIBuilder;
+import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
+import org.onap.dcaegen2.collectors.datafile.model.CommonFunctions;
+import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.reactive.function.BodyInserters;
+import org.springframework.web.reactive.function.client.ClientResponse;
+import org.springframework.web.reactive.function.client.WebClient;
+import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec;
+import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
+
+import reactor.core.publisher.Mono;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18
+ * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
+ */
+public class DmaapProducerReactiveHttpClient {
+
+ private static final String X_ATT_DR_META = "X-ATT-DR-META";
+ private static final String LOCATION = "location";
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ private WebClient webClient;
+ private final String dmaapHostName;
+ private final Integer dmaapPortNumber;
+ private final String dmaapProtocol;
+ private final String dmaapTopicName;
+ private final String dmaapContentType;
+
+ /**
+ * Constructor DmaapProducerReactiveHttpClient.
+ *
+ * @param dmaapPublisherConfiguration - DMaaP producer configuration object
+ */
+ public DmaapProducerReactiveHttpClient(DmaapPublisherConfiguration dmaapPublisherConfiguration) {
+
+ this.dmaapHostName = dmaapPublisherConfiguration.dmaapHostName();
+ this.dmaapProtocol = dmaapPublisherConfiguration.dmaapProtocol();
+ this.dmaapPortNumber = dmaapPublisherConfiguration.dmaapPortNumber();
+ this.dmaapTopicName = dmaapPublisherConfiguration.dmaapTopicName();
+ this.dmaapContentType = dmaapPublisherConfiguration.dmaapContentType();
+ }
+
+ /**
+ * Function for calling DMaaP HTTP producer - post request to DMaaP.
+ *
+ * @param consumerDmaapModelMono - object which will be sent to DMaaP
+ * @return status code of operation
+ */
+ public Mono<String> getDmaapProducerResponse(Mono<List<ConsumerDmaapModel>> consumerDmaapModelMono) {
+ consumerDmaapModelMono.subscribe(models -> postFilesAndData(models));
+ return Mono.just(HttpStatus.OK.toString());
+ }
+
+ public DmaapProducerReactiveHttpClient createDmaapWebClient(WebClient webClient) {
+ this.webClient = webClient;
+ return this;
+ }
+
+ private void postFilesAndData(List<ConsumerDmaapModel> models) {
+ for (ConsumerDmaapModel consumerDmaapModel : models) {
+ postFileAndData(consumerDmaapModel);
+ }
+ }
+
+ private void postFileAndData(ConsumerDmaapModel model) {
+ RequestBodyUriSpec post = webClient.post();
+
+ boolean headPrepared = prepareHead(model, post);
+
+ if (headPrepared) {
+ prepareBody(model, post);
+
+ ResponseSpec responseSpec = post.retrieve();
+ responseSpec.onStatus(HttpStatus::is4xxClientError,
+ clientResponse -> handlePostErrors(model, clientResponse));
+ responseSpec.onStatus(HttpStatus::is5xxServerError,
+ clientResponse -> handlePostErrors(model, clientResponse));
+ String bodyToMono = responseSpec.bodyToMono(String.class).block();
+ }
+ }
+
+ private boolean prepareHead(ConsumerDmaapModel model, RequestBodyUriSpec post) {
+ boolean result = true;
+ try {
+ post.header(HttpHeaders.CONTENT_TYPE, dmaapContentType);
+
+ JsonElement metaData = new JsonParser().parse(CommonFunctions.createJsonBody(model));
+ metaData.getAsJsonObject().remove(LOCATION);
+ post.header(X_ATT_DR_META, metaData.toString());
+
+ post.uri(getUri());
+ } catch (Exception e) {
+ logger.error("Unable to post file to Data Router. " + model, e);
+ result = false;
+ }
+
+ return result;
+ }
+
+ private void prepareBody(ConsumerDmaapModel model, RequestBodyUriSpec post) {
+ String fileLocation = model.getLocation();
+ File fileResource = new File(fileLocation);
+ FileSystemResource httpResource = new FileSystemResource(fileResource);
+ post.body(BodyInserters.fromResource(httpResource));
+ }
+
+ private URI getUri() throws URISyntaxException {
+ return new URIBuilder().setScheme(dmaapProtocol).setHost(dmaapHostName).setPort(dmaapPortNumber)
+ .setPath(dmaapTopicName).build();
+ }
+
+ private Mono<Exception> handlePostErrors(ConsumerDmaapModel model, ClientResponse clientResponse) {
+ String errorMessage = "Unable to post file to Data Router. " + model + "Reason: " + clientResponse.toString();
+ logger.error(errorMessage);
+
+ return Mono.error(new Exception(errorMessage));
+ }
+}
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DMaaPReactiveWebClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DMaaPReactiveWebClientTest.java
deleted file mode 100644
index dea22340..00000000
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/DMaaPReactiveWebClientTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.collectors.datafile.service.DMaaPReactiveWebClient;
-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
- */
-class DMaaPReactiveWebClientTest {
-
-
- @Test
- void builder_shouldBuildDMaaPReactiveWebClient() {
- //given
- DmaapConsumerConfiguration dmaapConsumerConfiguration = mock(DmaapConsumerConfiguration.class);
- String dmaaPContentType = "*/*";
- String dmaaPUserName = "DMaaP";
- String dmaaPUserPassword = "DMaaP";
-
- //when
- 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);
-
- }
-} \ No newline at end of file
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java
index d0943709..b67946b2 100644
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapConsumerConfigurationTest.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.service.config;
@@ -25,10 +23,10 @@ import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
-class DmaapConsumerConfigurationTest {
+public class DmaapConsumerConfigurationTest {
@Test
- void builder_shouldBuildConfigurationObject() {
+ public void builder_shouldBuildConfigurationObject() {
// Given
DmaapConsumerConfiguration configuration;
@@ -45,19 +43,11 @@ class DmaapConsumerConfigurationTest {
Integer messageLimit = 1000;
// When
- configuration = new ImmutableDmaapConsumerConfiguration.Builder()
- .consumerId(consumerId)
- .dmaapHostName(dmaapHostName)
- .dmaapPortNumber(dmaapPortNumber)
- .dmaapTopicName(dmaapTopicName)
- .dmaapProtocol(dmaapProtocol)
- .dmaapUserName(dmaapUserName)
- .dmaapUserPassword(dmaapUserPassword)
- .dmaapContentType(dmaapContentType)
- .consumerGroup(consumerGroup)
- .timeoutMs(timeoutMs)
- .messageLimit(messageLimit)
- .build();
+ configuration = new ImmutableDmaapConsumerConfiguration.Builder().consumerId(consumerId)
+ .dmaapHostName(dmaapHostName).dmaapPortNumber(dmaapPortNumber).dmaapTopicName(dmaapTopicName)
+ .dmaapProtocol(dmaapProtocol).dmaapUserName(dmaapUserName).dmaapUserPassword(dmaapUserPassword)
+ .dmaapContentType(dmaapContentType).consumerGroup(consumerGroup).timeoutMS(timeoutMs)
+ .messageLimit(messageLimit).build();
// Then
Assertions.assertNotNull(configuration);
@@ -69,7 +59,7 @@ 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/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java
index a188921c..fb8e8751 100644
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/config/DmaapPublisherConfigurationTest.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.service.config;
@@ -25,11 +23,11 @@ import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapPublisherConfiguration;
-class DmaapPublisherConfigurationTest {
+public class DmaapPublisherConfigurationTest {
@Test
- void builder_shouldBuildConfigurationObject() {
+ public void builder_shouldBuildConfigurationObject() {
// Given
DmaapPublisherConfiguration configuration;
@@ -42,15 +40,10 @@ class DmaapPublisherConfigurationTest {
String dmaapContentType = "application/json";
// When
- configuration = new ImmutableDmaapPublisherConfiguration.Builder()
- .dmaapHostName(dmaapHostName)
- .dmaapPortNumber(dmaapPortNumber)
- .dmaapTopicName(dmaapTopicName)
- .dmaapProtocol(dmaapProtocol)
- .dmaapUserName(dmaapUserName)
- .dmaapUserPassword(dmaapUserPassword)
- .dmaapContentType(dmaapContentType)
- .build();
+ configuration = new ImmutableDmaapPublisherConfiguration.Builder().dmaapHostName(dmaapHostName)
+ .dmaapPortNumber(dmaapPortNumber).dmaapTopicName(dmaapTopicName).dmaapProtocol(dmaapProtocol)
+ .dmaapUserName(dmaapUserName).dmaapUserPassword(dmaapUserPassword).dmaapContentType(dmaapContentType)
+ .build();
// Then
Assertions.assertNotNull(configuration);
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DMaaPConsumerReactiveHttpClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java
index abac3cd5..4f96a903 100644
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DMaaPConsumerReactiveHttpClientTest.java
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClientTest.java
@@ -1,9 +1,7 @@
/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
@@ -15,7 +13,7 @@
* 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=========================================================
+ * ============LICENSE_END========================================================================
*/
package org.onap.dcaegen2.collectors.datafile.service.consumer;
@@ -29,24 +27,25 @@ import static org.springframework.web.reactive.function.client.ExchangeFilterFun
import java.net.URI;
import java.net.URISyntaxException;
+
+import org.apache.http.HttpHeaders;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.collectors.datafile.service.consumer.DMaaPConsumerReactiveHttpClient;
-import org.springframework.http.HttpHeaders;
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;
+
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 6/27/18
*/
-class DMaaPConsumerReactiveHttpClientTest {
+class DmaapConsumerReactiveHttpClientTest {
- private DMaaPConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient;
+ private DmaapConsumerReactiveHttpClient dmaapConsumerReactiveHttpClient;
private DmaapConsumerConfiguration consumerConfigurationMock = mock(DmaapConsumerConfiguration.class);
private static final String JSON_MESSAGE = "{ \"responseFromDmaap\": \"Success\"}";
@@ -61,14 +60,14 @@ class DMaaPConsumerReactiveHttpClientTest {
when(consumerConfigurationMock.dmaapHostName()).thenReturn("54.45.33.2");
when(consumerConfigurationMock.dmaapProtocol()).thenReturn("https");
when(consumerConfigurationMock.dmaapPortNumber()).thenReturn(1234);
- when(consumerConfigurationMock.dmaapUserName()).thenReturn("Datafile");
- when(consumerConfigurationMock.dmaapUserPassword()).thenReturn("Datafile");
+ when(consumerConfigurationMock.dmaapUserName()).thenReturn("DATAFILE");
+ when(consumerConfigurationMock.dmaapUserPassword()).thenReturn("DATFILE");
when(consumerConfigurationMock.dmaapContentType()).thenReturn("application/json");
- when(consumerConfigurationMock.dmaapTopicName()).thenReturn("unauthenticated.SEC_OTHER_OUTPUT");
+ when(consumerConfigurationMock.dmaapTopicName()).thenReturn("unauthenticated.VES_NOTIFICATION_OUTPUT");
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(),
@@ -87,8 +86,8 @@ class DMaaPConsumerReactiveHttpClientTest {
//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()
@@ -104,11 +103,11 @@ class DMaaPConsumerReactiveHttpClientTest {
dmaapConsumerReactiveHttpClient = spy(dmaapConsumerReactiveHttpClient);
//when
when(webClient.get()).thenReturn(requestHeadersSpec);
- dmaapConsumerReactiveHttpClient.createDMaaPWebClient(webClient);
+ 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/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DMaaPProducerReactiveHttpClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DMaaPProducerReactiveHttpClientTest.java
deleted file mode 100644
index bb1ce19d..00000000
--- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DMaaPProducerReactiveHttpClientTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Datafile Collector Service
- * ================================================================================
- * 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.collectors.datafile.service.producer;
-
-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.when;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModelForUnitTest;
-import org.onap.dcaegen2.collectors.datafile.service.producer.DMaaPProducerReactiveHttpClient;
-import org.springframework.http.HttpHeaders;
-import org.springframework.web.reactive.function.client.WebClient;
-import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec;
-import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec;
-import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18
- */
-class DMaaPProducerReactiveHttpClientTest {
-
- private DMaaPProducerReactiveHttpClient dmaapProducerReactiveHttpClient;
-
- private DmaapPublisherConfiguration dmaapPublisherConfigurationMock = mock(
- DmaapPublisherConfiguration.class);
- private ConsumerDmaapModel consumerDmaapModel = new ConsumerDmaapModelForUnitTest();
- private WebClient webClient = mock(WebClient.class);
- private RequestBodyUriSpec requestBodyUriSpec;
- private ResponseSpec responseSpec;
-
-
- @BeforeEach
- void setUp() {
- when(dmaapPublisherConfigurationMock.dmaapHostName()).thenReturn("54.45.33.2");
- when(dmaapPublisherConfigurationMock.dmaapProtocol()).thenReturn("https");
- when(dmaapPublisherConfigurationMock.dmaapPortNumber()).thenReturn(1234);
- when(dmaapPublisherConfigurationMock.dmaapUserName()).thenReturn("Datafile");
- when(dmaapPublisherConfigurationMock.dmaapUserPassword()).thenReturn("Datafile");
- when(dmaapPublisherConfigurationMock.dmaapContentType()).thenReturn("application/json");
- when(dmaapPublisherConfigurationMock.dmaapTopicName()).thenReturn("pnfReady");
-
- dmaapProducerReactiveHttpClient = new DMaaPProducerReactiveHttpClient(dmaapPublisherConfigurationMock);
-
- webClient = spy(WebClient.builder()
- .defaultHeader(HttpHeaders.CONTENT_TYPE, dmaapPublisherConfigurationMock.dmaapContentType())
- .filter(basicAuthentication(dmaapPublisherConfigurationMock.dmaapUserName(),
- dmaapPublisherConfigurationMock.dmaapUserPassword()))
- .build());
- requestBodyUriSpec = mock(RequestBodyUriSpec.class);
- responseSpec = mock(ResponseSpec.class);
- }
-
- @Test
- void getHttpResponse_Success() {
- //given
- 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));
-
- //then
- Assertions.assertEquals(response.block(), expectedResult.block());
- }
-
- @Test
- void getHttpResponse_whenUriSyntaxExceptionHasBeenThrown() throws URISyntaxException {
- //given
- dmaapProducerReactiveHttpClient = spy(dmaapProducerReactiveHttpClient);
- //when
- when(webClient.post()).thenReturn(requestBodyUriSpec);
- dmaapProducerReactiveHttpClient.createDMaaPWebClient(webClient);
- when(dmaapProducerReactiveHttpClient.getUri()).thenThrow(URISyntaxException.class);
-
- //then
- StepVerifier.create(dmaapProducerReactiveHttpClient.getDMaaPProducerResponse(any())).expectSubscription()
- .expectError(Exception.class).verify();
- }
-
- private void mockWebClientDependantObject() {
- RequestHeadersSpec requestHeadersSpec = mock(RequestHeadersSpec.class);
- when(webClient.post()).thenReturn(requestBodyUriSpec);
- when(requestBodyUriSpec.uri((URI) any())).thenReturn(requestBodyUriSpec);
- when(requestBodyUriSpec.body(any())).thenReturn(requestHeadersSpec);
- doReturn(responseSpec).when(requestHeadersSpec).retrieve();
- doReturn(responseSpec).when(responseSpec).onStatus(any(), any());
- }
-} \ No newline at end of file
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java
new file mode 100644
index 00000000..213e8d77
--- /dev/null
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClientTest.java
@@ -0,0 +1,129 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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.collectors.datafile.service.producer;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.client.utils.URIBuilder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
+import org.onap.dcaegen2.collectors.datafile.model.CommonFunctions;
+import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
+import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModelForUnitTest;
+import org.springframework.http.HttpHeaders;
+import org.springframework.web.reactive.function.client.WebClient;
+import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec;
+import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
+
+import reactor.core.publisher.Mono;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 7/4/18
+ */
+class DmaapProducerReactiveHttpClientTest {
+
+ private static final String LOCATION = "location";
+ private static final String X_ATT_DR_META = "X-ATT-DR-META";
+
+ private static final String HOST = "54.45.33.2";
+ private static final String HTTPS_SCHEME = "https";
+ private static final int PORT = 1234;
+ private static final String APPLICATION_OCTET_STREAM_CONTENT_TYPE = "application/octet-stream";
+ private static final String FILE_READY_TOPIC = "fileReady";
+
+ private DmaapProducerReactiveHttpClient dmaapProducerReactiveHttpClient;
+
+ private DmaapPublisherConfiguration dmaapPublisherConfigurationMock = mock(DmaapPublisherConfiguration.class);
+ private ConsumerDmaapModel consumerDmaapModel = new ConsumerDmaapModelForUnitTest();
+ private WebClient webClientMock = mock(WebClient.class);
+ private RequestBodyUriSpec requestBodyUriSpecMock;
+ private ResponseSpec responseSpecMock;
+
+
+ @BeforeEach
+ void setUp() {
+ when(dmaapPublisherConfigurationMock.dmaapHostName()).thenReturn(HOST);
+ when(dmaapPublisherConfigurationMock.dmaapProtocol()).thenReturn(HTTPS_SCHEME);
+ when(dmaapPublisherConfigurationMock.dmaapPortNumber()).thenReturn(PORT);
+ when(dmaapPublisherConfigurationMock.dmaapUserName()).thenReturn("DATAFILE");
+ when(dmaapPublisherConfigurationMock.dmaapUserPassword()).thenReturn("DATAFILE");
+ when(dmaapPublisherConfigurationMock.dmaapContentType()).thenReturn(APPLICATION_OCTET_STREAM_CONTENT_TYPE);
+ when(dmaapPublisherConfigurationMock.dmaapTopicName()).thenReturn(FILE_READY_TOPIC);
+
+ dmaapProducerReactiveHttpClient = new DmaapProducerReactiveHttpClient(dmaapPublisherConfigurationMock);
+
+ webClientMock = spy(WebClient.builder()
+ .defaultHeader(HttpHeaders.CONTENT_TYPE, dmaapPublisherConfigurationMock.dmaapContentType())
+ .filter(basicAuthentication(dmaapPublisherConfigurationMock.dmaapUserName(),
+ dmaapPublisherConfigurationMock.dmaapUserPassword()))
+ .build());
+ requestBodyUriSpecMock = mock(RequestBodyUriSpec.class);
+ responseSpecMock = mock(ResponseSpec.class);
+ }
+
+ @Test
+ void getHttpResponse_Success() {
+ // given
+
+ // when
+ mockWebClientDependantObject();
+ dmaapProducerReactiveHttpClient.createDmaapWebClient(webClientMock);
+ List<ConsumerDmaapModel> consumerDmaapModelList = new ArrayList<ConsumerDmaapModel>();
+ consumerDmaapModelList.add(consumerDmaapModel);
+
+ dmaapProducerReactiveHttpClient.getDmaapProducerResponse(Mono.just(consumerDmaapModelList));
+
+ // then
+ verify(requestBodyUriSpecMock).header(HttpHeaders.CONTENT_TYPE, APPLICATION_OCTET_STREAM_CONTENT_TYPE);
+ JsonElement metaData = new JsonParser().parse(CommonFunctions.createJsonBody(consumerDmaapModel));
+ metaData.getAsJsonObject().remove(LOCATION);
+ verify(requestBodyUriSpecMock).header(X_ATT_DR_META, metaData.toString());
+ URI expectedUri = null;
+ try {
+ expectedUri = new URIBuilder().setScheme(HTTPS_SCHEME).setHost(HOST).setPort(1234).setPath(FILE_READY_TOPIC)
+ .build();
+ } catch (URISyntaxException e) {
+ // Nothing
+ }
+ verify(requestBodyUriSpecMock).uri(expectedUri);
+ verify(requestBodyUriSpecMock).body(any());
+ }
+
+ private void mockWebClientDependantObject() {
+ when(webClientMock.post()).thenReturn(requestBodyUriSpecMock);
+ when(requestBodyUriSpecMock.uri((URI) any())).thenReturn(requestBodyUriSpecMock);
+
+ when(requestBodyUriSpecMock.retrieve()).thenReturn(responseSpecMock);
+ when(responseSpecMock.onStatus(any(), any())).thenReturn(responseSpecMock);
+ Mono<String> expectedResult = Mono.just("200");
+ when(responseSpecMock.bodyToMono(String.class)).thenReturn(expectedResult);
+ }
+}
diff --git a/pom.xml b/pom.xml
index accfee74..190c62a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,37 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- ~ ============LICENSE_START=======================================================
- ~ Datafile Collector Service
- ~ ================================================================================
- ~ Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- ~ ================================================================================
+ ~ ============LICENSE_START=====================================================================
+ ~ Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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
+ ~ 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=========================================================
+ ~ ============LICENSE_END=======================================================================
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
<modelVersion>4.0.0</modelVersion>
+
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
<version>1.2.0</version>
- <relativePath/>
+ <relativePath />
</parent>
+
<groupId>org.onap.dcaegen2.collectors</groupId>
<artifactId>datafile</artifactId>
<version>1.0.0-SNAPSHOT</version>
- <name>dcaegen2-collectors-datafile</name>
- <description>Datafile Collector Service</description>
+ <name>dcaegen2-collectors.datafile</name>
+ <description>datafile collector</description>
<packaging>pom</packaging>
<licenses>
@@ -46,14 +45,15 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <!-- JAVA VERSION-->
+ <!-- JAVA VERSION -->
<java.version>8</java.version>
<compiler.plugin.version>3.7.0</compiler.plugin.version>
<tomcat.version>8.5.28</tomcat.version>
+ <spring-boot.version>2.0.4.RELEASE</spring-boot.version>
<docker.maven.version>1.0.0</docker.maven.version>
<resource.maven.plugin.version>3.1.0</resource.maven.plugin.version>
<!-- DEVELOPMENT SETTINGS -->
- <immutable.version>2.5.6</immutable.version>
+ <immutable.version>2.7.1</immutable.version>
<!-- LOGGING SETTINGS -->
<slf4j.version>1.7.25</slf4j.version>
@@ -62,345 +62,67 @@
<!--TEST SETTINGS -->
<surefire.redirectTestOutputToFile>true</surefire.redirectTestOutputToFile>
<junit.version>4.12</junit.version>
- <junit.jupiter.version>5.1.0</junit.jupiter.version>
- <junit.vintage.version>5.1.0</junit.vintage.version>
- <junit.platform.version>1.1.0</junit.platform.version>
-
- <!--PLUGIN SETTINGS -->
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshots.path>content/repositories/snapshots/</snapshots.path>
- <releases.path>content/repositories/releases/</releases.path>
- <site.path>
- content/sites/site/org/onap/dcaegen2/collectors/datafile/${project.artifactId}/${project.version}
- </site.path>
+ <junit-jupiter.version>5.1.0</junit-jupiter.version>
+ <junit-vintage.version>5.1.0</junit-vintage.version>
+ <junit-platform.version>1.1.0</junit-platform.version>
</properties>
- <pluginRepositories>
-
-
- <pluginRepository>
- <id>40_openecomp-release</id>
- <name>40_openecomp-release</name>
- <url>https://nexus.onap.org/content/repositories/releases/</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </pluginRepository>
-
- <!-- Black Duck plugin dependencies -->
- <pluginRepository>
- <id>JCenter</id>
- <name>JCenter Repository</name>
- <url>http://jcenter.bintray.com</url>
- </pluginRepository>
- <pluginRepository>
- <id>Restlet</id>
- <name>Restlet Repository</name>
- <url>http://maven.restlet.com</url>
- </pluginRepository>
- </pluginRepositories>
-
-
- <repositories>
- <repository>
- <id>external-repository</id>
- <url>https://oss.sonatype.org/content/repositories</url>
- </repository>
- <repository>
- <id>40_openecomp-release</id>
- <name>40_openecomp-release</name>
- <url>https://nexus.onap.org/content/repositories/releases/</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
+ <modules>
+ <module>datafile-app-server</module>
+ <module>datafile-dmaap-client</module>
+ <module>datafile-commons</module>
+ </modules>
<build>
-
- <extensions>
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav-jackrabbit</artifactId>
- <version>3.0.0</version>
- </extension>
- </extensions>
-
<pluginManagement>
<plugins>
-
- <!-- COMPILER PLUGIN -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${compiler.plugin.version}</version>
- <configuration>
- <source>${java.version}</source>
- <target>${java.version}</target>
- <showWarnings>true</showWarnings>
- <showDeprecation>true</showDeprecation>
- </configuration>
- </plugin>
-
- <!-- MAVEN SOURCE PLUGIN -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>3.0.1</version>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.1.0</version>
<configuration>
- <excludeResources>true</excludeResources>
+ <encoding>${project.build.sourceEncoding}</encoding>
</configuration>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>verify</phase>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
</plugin>
-
- <!-- MAVEN JAVADOC PLUGIN -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>3.0.0</version>
- <configuration>
- <!-- minimize console output messages -->
- <quiet>true</quiet>
- <verbose>false</verbose>
- <useStandardDocletOptions>false</useStandardDocletOptions>
- </configuration>
- <executions>
- <execution>
- <id>aggregate</id>
- <phase>site</phase>
- <goals>
- <goal>aggregate</goal>
- </goals>
- </execution>
- <execution>
- <id>attach-javadoc</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- MAVEN BUNDLE PLUGIN -->
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>3.5.0</version>
- <extensions>true</extensions>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.7.0</version>
<configuration>
- <instructions>
- <Embed-Dependency>*;inline=false;scope=compile</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
- <Embed-Directory>lib</Embed-Directory>
- </instructions>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ <showWarnings>true</showWarnings>
+ <showDeprecation>true</showDeprecation>
</configuration>
- <executions>
- <execution>
- <id>Bundling Datafile Jar</id>
- <phase>package</phase>
- <goals>
- <goal>bundle</goal>
- </goals>
- </execution>
- </executions>
</plugin>
-
- <!-- maven-surefire-plugin which is used during the test phase of build lifecycle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
- <configuration>
- <argLine>-Xmx2048m -Djava.awt.headless=true -XX:+UseConcMarkSweepGC
- -XX:OnOutOfMemoryError="kill -9 %p" -XX:+HeapDumpOnOutOfMemoryError
- </argLine>
- <redirectTestOutputToFile>${surefire.redirectTestOutputToFile}
- </redirectTestOutputToFile>
- <parallel>methods</parallel>
- <threadCount>8</threadCount>
- <forkCount>8</forkCount>
- <reuseForks>true</reuseForks>
- <reportFormat>xml</reportFormat>
- <trimStackTrace>false</trimStackTrace>
- <systemPropertyVariables>
- <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
- <logback.configurationFile>
- ${basedir}/src/test/resources/logback-test.xml
- </logback.configurationFile>
- <HADOOP_HOME>${project.build.directory}</HADOOP_HOME>
- </systemPropertyVariables>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- <excludes>
- <exclude>**/*IT.java</exclude>
- </excludes>
- <!-- Sets the VM argument line used when unit tests are run. -->
- <argLine>${argLine}</argLine>
- </configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
- <version>${junit.platform.version}</version>
+ <version>${junit-platform.version}</version>
</dependency>
</dependencies>
</plugin>
-
- <!-- FIND BUGS (STATIC CODE ANALYSIS) PLUGIN -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>${findbugs.plugin.version}</version>
- <configuration>
- <effort>Max</effort>
- <threshold>Low</threshold>
- <xmlOutput>true</xmlOutput>
- <!-- BUILD FAIL ON FINDBUGS ERRORS -->
- <failOnError>true</failOnError>
- <excludeFilterFile>${project.basedir}/findbugs-exclude.xml</excludeFilterFile>
- <outputDirectory>${project.reporting.outputDirectory}/findbugs</outputDirectory>
- <findbugsXmlOutputDirectory>${project.reporting.outputDirectory}/findbugs
- </findbugsXmlOutputDirectory>
- </configuration>
- <executions>
- <execution>
- <id>analyze-compile</id>
- <phase>compile</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.0.2</version>
- <configuration>
- <archive>
- <manifest>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Implementation-Build-Version>${project.version}</Implementation-Build-Version>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.6</version>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.5</version>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.9</version>
- <configuration>
- <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
- <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.21.0</version>
- </plugin>
-
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
- <version>${docker.maven.version}</version>
- <configuration>
- <skipDockerBuild>true</skipDockerBuild>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>${resource.maven.plugin.version}</version>
+ <version>1.1.1</version>
</plugin>
<plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/Immutable*</exclude>
- <exclude>**/GsonAdapters*</exclude>
- <exclude>**/*ForUnitTest*</exclude>
- </excludes>
- </configuration>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring-boot.version}</version>
<executions>
<execution>
- <id>default-prepare-agent</id>
<goals>
- <goal>prepare-agent</goal>
+ <goal>repackage</goal>
</goals>
</execution>
- <execution>
- <id>report</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>report</goal>
- </goals>
- </execution>
- <execution>
- <id>check</id>
- <goals>
- <goal>check</goal>
- </goals>
- <configuration>
- <excludes>
- <exclude>**/Immutable*</exclude>
- <exclude>**/GsonAdapters*</exclude>
- <exclude>**/*ForUnitTest*</exclude>
- <exclude>**/AAIConsumer*</exclude>
- </excludes>
- <rules>
- <rule>
- <element>CLASS</element>
- <limits>
- <limit>
- <value>COVEREDRATIO</value>
- <!--<minimum>0.70</minimum>-->
- </limit>
- <limit>
- <counter>BRANCH</counter>
- <value>COVEREDRATIO</value>
- <!--<minimum>0.70</minimum>-->
- </limit>
- </limits>
- </rule>
- </rules>
- </configuration>
- </execution>
</executions>
</plugin>
<plugin>
@@ -412,87 +134,9 @@
</plugin>
</plugins>
</pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- </plugin>
- </plugins>
</build>
- <reporting>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
- <docletArtifact>
- <groupId>org.umlgraph</groupId>
- <artifactId>umlgraph</artifactId>
- <version>5.6</version>
- </docletArtifact>
- <additionalparam>-views</additionalparam>
- <useStandardDocletOptions>true</useStandardDocletOptions>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
- <dependencyManagement>
+ <dependencyManagement>
<dependencies>
<!-- DEVELOPMENT TOOLS DEPENDENCIES -->
@@ -545,11 +189,21 @@
<version>4.5.4</version>
</dependency>
<dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>4.3.1</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.0.5.RELEASE</version>
@@ -560,6 +214,17 @@
<version>5.0.5.RELEASE</version>
</dependency>
<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webflux</artifactId>
+ <version>5.0.5.RELEASE</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-reactor-netty</artifactId>
+ <version>2.0.4.RELEASE</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat.version}</version>
@@ -597,7 +262,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
- <version>${junit.jupiter.version}</version>
+ <version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -609,13 +274,13 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
- <version>${junit.jupiter.version}</version>
+ <version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
- <version>${junit.vintage.version}</version>
+ <version>${junit-vintage.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -648,6 +313,17 @@
<version>2.0.1.RELEASE</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockftpserver</groupId>
+ <artifactId>MockFtpServer</artifactId>
+ <version>2.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.github.stefanbirkner</groupId>
+ <artifactId>fake-sftp-server-rule</artifactId>
+ <version>2.0.1</version>
+ </dependency>
<!--REQUIRED TO GENERATE DOCUMENTATION -->
<dependency>
@@ -661,21 +337,21 @@
<version>2.8.0</version>
</dependency>
+ <!-- https://mvnrepository.com/artifact/commons-net/commons-net -->
+ <dependency>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
+ <version>3.3</version>
+ </dependency>
+
<!-- ONLY REQUIRED TO RUN TESTS IN AN IDE THAT BUNDLES AN OLDER VERSION -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
- <version>${junit.platform.version}</version>
+ <version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
-
- <modules>
- <module>datafile-app-server</module>
- <module>datafile-aai-client</module>
- <module>datafile-dmaap-client</module>
- <module>datafile-commons</module>
- </modules>
</project>
diff --git a/swagger.yaml b/swagger.yaml
index b0430487..7f56ca55 100644
--- a/swagger.yaml
+++ b/swagger.yaml
@@ -1,14 +1,14 @@
---
swagger: '2.0'
info:
- description: This page lists all the rest apis for Datafile app server.
+ description: This page lists all the rest apis for DATAFILE app server.
version: '1.0'
- title: Datafile app server
+ title: DATAFILE app server
host: localhost:8100
basePath: "/"
tags:
- name: heartbeat-controller
- description: Check liveness of Datafile service
+ description: Check liveness of DATAFILE service
- name: schedule-controller
description: Schedule Controller
paths:
@@ -16,13 +16,13 @@ paths:
get:
tags:
- heartbeat-controller
- summary: Returns liveness of Datafile service
+ summary: Returns liveness of DATAFILE service
operationId: heartbeatUsingGET
produces:
- "*/*"
responses:
'200':
- description: Datafile sevice is living
+ description: DATAFILE service is living
schema:
"$ref": "#/definitions/Mono«ResponseEntity«string»»"
'401':
diff --git a/version.properties b/version.properties
index 2ddebb39..1b043102 100644
--- a/version.properties
+++ b/version.properties
@@ -1,6 +1,6 @@
-major=1
-minor=0
-patch=0
-base_version=${major}.${minor}.${patch}
-release_version=${base_version}
-snapshot_version=${base_version}-SNAPSHOT
+major=1
+minor=0
+patch=0
+base_version=${major}.${minor}.${patch}
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT