From 7e6809152a93be1621eca57bf8776dbbb11807a5 Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Thu, 9 Mar 2023 15:11:37 +0100 Subject: [PATCH] Some tidying up Mainly in pom files Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-853 Change-Id: I534852c768733d96031ff28a8c1a31bd4ba53d02 --- datafilecollector/pom.xml | 89 ++++-------------- .../datafile/controllers/StatusController.java | 24 ++--- .../datafile/tasks/CollectAndReportFiles.java | 2 - .../collectors/datafile/tasks/FileCollector.java | 4 +- .../dcaegen2/collectors/datafile/MockDatafile.java | 100 +++++++++++---------- .../datafile/http/HttpClientResponseHelper.java | 1 - .../http/HttpsClientConnectionManagerUtilTest.java | 2 +- influxlogger/pom.xml | 11 +-- pmproducer/pom.xml | 30 +------ .../oran/pmproducer/filter/PmReportFilterTest.java | 49 ---------- 10 files changed, 94 insertions(+), 218 deletions(-) diff --git a/datafilecollector/pom.xml b/datafilecollector/pom.xml index c122253..6c869bd 100644 --- a/datafilecollector/pom.xml +++ b/datafilecollector/pom.xml @@ -27,21 +27,33 @@ org.o-ran-sc.nonrtric.plt.ranpm datafile-app-server + 1.0.0-SNAPSHOT jar 17 yyyyMMdd'T'HHmmss - 8.7.1 - 3.0.0 - 2.9.0 + 2.9.1 0.30.0 0.8.8 + 2.0.2 + 1.6.14 + true + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc.version} + + + org.springdoc + springdoc-openapi-ui + ${springdoc.openapi-ui.version} + com.google.code.gson gson - 2.9.1 + ${gson.version} io.projectreactor.kafka @@ -78,11 +90,6 @@ org.springframework spring-webmvc - - com.spotify - docker-client - ${docker-client.version} - org.springframework spring-webflux @@ -122,54 +129,15 @@ spring-boot-starter-test test - - org.junit.vintage - junit-vintage-engine - 5.7.0 - test - org.mockito mockito-junit-jupiter test - - - io.springfox - springfox-spring-web - ${springfox.version} - - - io.springfox - springfox-spi - ${springfox.version} - - - io.springfox - springfox-core - ${springfox.version} - - - org.springdoc - springdoc-openapi-ui - 1.6.3 - test - - - io.springfox - springfox-swagger2 - ${springfox.version} - - - io.springfox - springfox-swagger-ui - ${springfox.version} - commons-net commons-net - 3.6 + 3.9.0 com.jcraft @@ -262,27 +230,6 @@ - - pl.project13.maven - git-commit-id-plugin - - - get-the-git-infos - - revision - - - - - true - ${project.basedir}/.git - MM-dd-yyyy '@' HH:mm:ss Z - true - ${project.build.outputDirectory}/git.properties - - true - - com.diffplug.spotless spotless-maven-plugin @@ -331,4 +278,4 @@ - \ No newline at end of file + diff --git a/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusController.java b/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusController.java index d1f615b..f4baeaf 100644 --- a/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusController.java +++ b/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusController.java @@ -17,9 +17,9 @@ package org.onap.dcaegen2.collectors.datafile.controllers; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import org.onap.dcaegen2.collectors.datafile.model.Counters; @@ -58,10 +58,12 @@ public class StatusController { @Operation(summary = "Returns liveness of DATAFILE service") @ApiResponses( value = { // - @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")}) + @ApiResponse(responseCode = "200", description = "DATAFILE service is living"), + @ApiResponse(responseCode = "401", description = "You are not authorized to view the resource"), + @ApiResponse( + responseCode = "403", + description = "Accessing the resource you were trying to reach is forbidden"), + @ApiResponse(responseCode = "404", description = "The resource you were trying to reach is not found")}) public Mono> heartbeat(@RequestHeader HttpHeaders headers) { logger.info("ENTRY {}", "Heartbeat request"); @@ -83,10 +85,12 @@ public class StatusController { @Operation(summary = "Returns status and statistics of DATAFILE service") @ApiResponses( value = { // - @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")}) + @ApiResponse(responseCode = "200", description = "DATAFILE service is living"), + @ApiResponse(responseCode = "401", description = "You are not authorized to view the resource"), + @ApiResponse( + responseCode = "403", + description = "Accessing the resource you were trying to reach is forbidden"), + @ApiResponse(responseCode = "404", description = "The resource you were trying to reach is not found")}) public Mono> status(@RequestHeader HttpHeaders headers) { logger.info("ENTRY {}", "Status request"); diff --git a/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/CollectAndReportFiles.java b/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/CollectAndReportFiles.java index c127948..c4f2ac3 100644 --- a/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/CollectAndReportFiles.java +++ b/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/CollectAndReportFiles.java @@ -45,7 +45,6 @@ import org.onap.dcaegen2.collectors.datafile.model.FilePublishInformation; import org.onap.dcaegen2.collectors.datafile.model.FileReadyMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import reactor.core.publisher.Flux; @@ -90,7 +89,6 @@ public class CollectAndReportFiles { * * @param applicationConfiguration - application configuration */ - @Autowired public CollectAndReportFiles(AppConfig applicationConfiguration) { this.appConfig = applicationConfiguration; this.kafkaSender = KafkaSender.create(kafkaSenderOptions()); diff --git a/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java b/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java index b6c07e5..2b3ce53 100644 --- a/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java +++ b/datafilecollector/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java @@ -17,12 +17,12 @@ package org.onap.dcaegen2.collectors.datafile.tasks; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; import java.util.Optional; -import org.apache.commons.io.FileUtils; import org.onap.dcaegen2.collectors.datafile.commons.FileCollectClient; import org.onap.dcaegen2.collectors.datafile.commons.Scheme; import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig; @@ -103,7 +103,7 @@ public class FileCollector { try (FileCollectClient currentClient = createClient(fileData)) { currentClient.open(); - FileUtils.forceMkdirParent(localFile.toFile()); + Files.createDirectories(localFile.getParent()); currentClient.collectFile(remoteFile, localFile); counters.incNoOfCollectedFiles(); return Mono.just(Optional.of(createFilePublishInformation(fileData))); diff --git a/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/MockDatafile.java b/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/MockDatafile.java index 16a36c0..30a7975 100644 --- a/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/MockDatafile.java +++ b/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/MockDatafile.java @@ -26,14 +26,15 @@ import static org.awaitility.Awaitility.await; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.List; -import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -54,16 +55,18 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.context.annotation.Bean; import org.springframework.test.context.TestPropertySource; +import org.springframework.util.FileSystemUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) -@TestPropertySource(properties = { // +@TestPropertySource( + properties = { // "app.ssl.key-store-password-file=./config/ftps_keystore.pass", // "app.ssl.key-store=./config/ftps_keystore.p12", // "app.ssl.trust-store-password-file=./config/truststore.pass", // @@ -75,7 +78,7 @@ import reactor.core.publisher.Mono; "app.s3.accessKeyId=minio", // "app.s3.secretAccessKey=miniostorage", // "app.s3.bucket=ropfiles", // - "app.s3.locksBucket=locks" }) + "app.s3.locksBucket=locks"}) @SuppressWarnings("squid:S3577") // Not containing any tests since it is a mock. class MockDatafile { @@ -86,8 +89,10 @@ class MockDatafile { private static final String PM_FILE_NAME = "PM_FILE_NAME"; // This can be any downloadable file on the net - private static final String FTPES_LOCATION = "ftpes:// onap:pano@ftp-ftpes-6:2021/A20000626.2315+0200-2330+0200_GNODEB-15-4.xml.gz"; - private static final String LOCATION = "https://launchpad.net/ubuntu/+source/perf-tools-unstable/1.0+git7ffb3fd-1ubuntu1/+build/13630748/+files/perf-tools-unstable_1.0+git7ffb3fd-1ubuntu1_all.deb"; + private static final String FTPES_LOCATION = + "ftpes:// onap:pano@ftp-ftpes-6:2021/A20000626.2315+0200-2330+0200_GNODEB-15-4.xml.gz"; + private static final String LOCATION = + "https://launchpad.net/ubuntu/+source/perf-tools-unstable/1.0+git7ffb3fd-1ubuntu1/+build/13630748/+files/perf-tools-unstable_1.0+git7ffb3fd-1ubuntu1_all.deb"; private static final String GZIP_COMPRESSION = "gzip"; private static final String FILE_FORMAT_TYPE = "org.3GPP.32.435#measCollec"; private static final String FILE_FORMAT_VERSION = "V10"; @@ -96,8 +101,8 @@ class MockDatafile { private static final Logger logger = LoggerFactory.getLogger(MockDatafile.class); private static Gson gson = new GsonBuilder() // - .disableHtmlEscaping() // - .create(); // + .disableHtmlEscaping() // + .create(); // @LocalServerPort private int port; @@ -123,13 +128,13 @@ class MockDatafile { // Create a listener to the output topic. The KafkaTopicListener happens to be // suitable for that, - KafkaTopicListener topicListener = new KafkaTopicListener(applicationConfig.getKafkaBootStrapServers(), - "MockDatafile", outputTopic); + KafkaTopicListener topicListener = + new KafkaTopicListener(applicationConfig.getKafkaBootStrapServers(), "MockDatafile", outputTopic); topicListener.getFlux() // - .doOnNext(this::set) // - .doFinally(sig -> logger.info("Finally " + sig)) // - .subscribe(); + .doOnNext(this::set) // + .doFinally(sig -> logger.info("Finally " + sig)) // + .subscribe(); } private void set(DataFromTopic receivedKafkaOutput) { @@ -166,10 +171,10 @@ class MockDatafile { FilePublishInformation i = fc.createFilePublishInformation(fileData); try { - File from = new File("config/application.yaml"); - File to = new File(this.appConfig.collectedFilesPath + "/" + fileData.name()); - FileUtils.forceMkdirParent(to); - com.google.common.io.Files.copy(from, to); + Path from = Path.of("config/application.yaml"); + Path to = Path.of(this.appConfig.collectedFilesPath, fileData.name()); + Files.createDirectories(to.getParent()); + Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING); } catch (Exception e) { logger.error("Could not copy file {}", e.getMessage()); } @@ -219,9 +224,8 @@ class MockDatafile { } private void deleteAllFiles() { - try { - FileUtils.deleteDirectory(new File(this.appConfig.collectedFilesPath)); + FileSystemUtils.deleteRecursively(Path.of(this.appConfig.collectedFilesPath)); } catch (IOException e) { } } @@ -259,10 +263,10 @@ class MockDatafile { Instant startTime = Instant.now(); Flux.range(1, NO_OF_OBJECTS) // - .map(i -> gson.toJson(fileReadyMessage("testS3Concurrency_" + i))) // - .flatMap(fileReadyMessage -> scheduledTask.sendDataToStream(appConfig.fileReadyEventTopic, "key", - fileReadyMessage)) // - .blockLast(); // + .map(i -> gson.toJson(fileReadyMessage("testS3Concurrency_" + i))) // + .flatMap(fileReadyMessage -> scheduledTask.sendDataToStream(appConfig.fileReadyEventTopic, "key", + fileReadyMessage)) // + .blockLast(); // while (kafkaReceiver.count < NO_OF_OBJECTS) { logger.info("sleeping {}", kafkaReceiver.count); @@ -292,45 +296,45 @@ class MockDatafile { FileReadyMessage.Event event(String fileName) { MessageMetaData messageMetaData = MessageMetaData.builder() // - .lastEpochMicrosec(LAST_EPOCH_MICROSEC) // - .sourceName(SOURCE_NAME) // - .startEpochMicrosec(START_EPOCH_MICROSEC) // - .timeZoneOffset(TIME_ZONE_OFFSET) // - .changeIdentifier(CHANGE_IDENTIFIER) // - .eventName("Noti_RnNode-Ericsson_FileReady").build(); + .lastEpochMicrosec(LAST_EPOCH_MICROSEC) // + .sourceName(SOURCE_NAME) // + .startEpochMicrosec(START_EPOCH_MICROSEC) // + .timeZoneOffset(TIME_ZONE_OFFSET) // + .changeIdentifier(CHANGE_IDENTIFIER) // + .eventName("Noti_RnNode-Ericsson_FileReady").build(); FileReadyMessage.FileInfo fileInfo = FileReadyMessage.FileInfo // - .builder() // - .fileFormatType(FILE_FORMAT_TYPE) // - .location(LOCATION) // - .fileFormatVersion(FILE_FORMAT_VERSION) // - .compression(GZIP_COMPRESSION) // - .build(); + .builder() // + .fileFormatType(FILE_FORMAT_TYPE) // + .location(LOCATION) // + .fileFormatVersion(FILE_FORMAT_VERSION) // + .compression(GZIP_COMPRESSION) // + .build(); FileReadyMessage.ArrayOfNamedHashMap arrayOfNamedHashMap = FileReadyMessage.ArrayOfNamedHashMap // - .builder() // - .name(fileName) // - .hashMap(fileInfo) // - .build(); + .builder() // + .name(fileName) // + .hashMap(fileInfo) // + .build(); List arrayOfNamedHashMapList = new ArrayList<>(); arrayOfNamedHashMapList.add(arrayOfNamedHashMap); FileReadyMessage.NotificationFields notificationFields = FileReadyMessage.NotificationFields // - .builder().notificationFieldsVersion("notificationFieldsVersion") // - .changeType(CHANGE_TYPE).changeIdentifier(CHANGE_IDENTIFIER) // - .arrayOfNamedHashMap(arrayOfNamedHashMapList) // - .build(); + .builder().notificationFieldsVersion("notificationFieldsVersion") // + .changeType(CHANGE_TYPE).changeIdentifier(CHANGE_IDENTIFIER) // + .arrayOfNamedHashMap(arrayOfNamedHashMapList) // + .build(); return FileReadyMessage.Event.builder() // - .commonEventHeader(messageMetaData) // - .notificationFields(notificationFields).build(); + .commonEventHeader(messageMetaData) // + .notificationFields(notificationFields).build(); } private FileReadyMessage fileReadyMessage(String fileName) { FileReadyMessage message = FileReadyMessage.builder() // - .event(event(fileName)) // - .build(); + .event(event(fileName)) // + .build(); return message; } diff --git a/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpClientResponseHelper.java b/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpClientResponseHelper.java index 3df2cad..73c377a 100644 --- a/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpClientResponseHelper.java +++ b/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpClientResponseHelper.java @@ -414,6 +414,5 @@ public class HttpClientResponseHelper { @Override public void setParams(HttpParams params) { } - }; } diff --git a/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java b/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java index bb1a93f..be3e8be 100644 --- a/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java +++ b/datafilecollector/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java @@ -18,7 +18,7 @@ package org.onap.dcaegen2.collectors.datafile.http; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException; diff --git a/influxlogger/pom.xml b/influxlogger/pom.xml index 89f9902..2ac0b92 100644 --- a/influxlogger/pom.xml +++ b/influxlogger/pom.xml @@ -57,6 +57,7 @@ 0.8.8 3.0.11 2.0.2 + 1.6.14 true @@ -68,7 +69,7 @@ org.springdoc springdoc-openapi-ui - ${springdoc.version} + ${springdoc.openapi-ui.version} com.influxdb @@ -118,12 +119,6 @@ - - org.springdoc - springdoc-openapi-ui - 1.6.3 - test - com.github.erosb everit-json-schema @@ -360,4 +355,4 @@ JIRA https://jira.o-ran-sc.org/ - \ No newline at end of file + diff --git a/pmproducer/pom.xml b/pmproducer/pom.xml index 0aa07e5..06724d7 100644 --- a/pmproducer/pom.xml +++ b/pmproducer/pom.xml @@ -31,7 +31,7 @@ org.o-ran-sc.nonrtric.plt pmproducer - 1.3.0-SNAPSHOT + 1.0.0-SNAPSHOT The Apache Software License, Version 2.0 @@ -56,10 +56,9 @@ 0.30.0 3.7.0.1746 0.8.8 - true - 4.0.0-rc-2 - 1.4 2.0.2 + 1.6.14 + true @@ -70,22 +69,7 @@ org.springdoc springdoc-openapi-ui - ${springdoc.version} - - - com.google.protobuf - protobuf-java - ${protobuf.version} - - - com.googlecode.protobuf-java-format - protobuf-java-format - ${protobuf-java-format.version} - - - com.google.protobuf - protobuf-java-util - 3.21.5 + ${springdoc.openapi-ui.version} org.springframework.boot @@ -130,12 +114,6 @@ - - org.springdoc - springdoc-openapi-ui - 1.6.3 - test - com.github.erosb everit-json-schema diff --git a/pmproducer/src/test/java/org/oran/pmproducer/filter/PmReportFilterTest.java b/pmproducer/src/test/java/org/oran/pmproducer/filter/PmReportFilterTest.java index 01efe47..541a2ba 100644 --- a/pmproducer/src/test/java/org/oran/pmproducer/filter/PmReportFilterTest.java +++ b/pmproducer/src/test/java/org/oran/pmproducer/filter/PmReportFilterTest.java @@ -24,14 +24,8 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.protobuf.AbstractMessage.Builder; -import com.google.protobuf.Message; -import com.google.protobuf.MessageOrBuilder; -import com.google.protobuf.util.JsonFormat; -import java.io.IOException; import java.lang.invoke.MethodHandles; -import java.lang.reflect.InvocationTargetException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; @@ -45,49 +39,6 @@ import org.slf4j.LoggerFactory; class PmReportFilterTest { - public static class ProtoJsonUtil { - - /** - * Makes a Json from a given message or builder - * - * @param messageOrBuilder is the instance - * @return The string representation - * @throws IOException if any error occurs - */ - public static String toJson(MessageOrBuilder messageOrBuilder) throws IOException { - return JsonFormat.printer().print(messageOrBuilder); - } - - /** - * Makes a new instance of message based on the json and the class - * - * @param is the class type - * @param json is the json instance - * @param clazz is the class instance - * @return An instance of T based on the json values - * @throws IOException if any error occurs - */ - @SuppressWarnings({"unchecked", "rawtypes"}) - public static T fromJson(String json, Class clazz) throws IOException { - // https://stackoverflow.com/questions/27642021/calling-parsefrom-method-for-generic-protobuffer-class-in-java/33701202#33701202 - Builder builder = null; - try { - // Since we are dealing with a Message type, we can call newBuilder() - builder = (Builder) clazz.getMethod("newBuilder").invoke(null); - - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException - | NoSuchMethodException | SecurityException e) { - return null; - } - - // The instance is placed into the builder values - JsonFormat.parser().ignoringUnknownFields().merge(json, builder); - - // the instance will be from the build - return (T) builder.build(); - } - } - private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static Gson gson = new GsonBuilder() // -- 2.16.6