summaryrefslogtreecommitdiffstats
path: root/datafile-app-server/src
diff options
context:
space:
mode:
authortkogut <tomasz.kogut@nokia.com>2020-12-02 11:53:06 +0100
committertkogut <tomasz.kogut@nokia.com>2020-12-02 12:54:15 +0100
commit8ad1127f32d03c25a1d0936638e3bd046a5ef6df (patch)
tree3b129afacf2fbbd775e4efd40d8d2b162b0287ab /datafile-app-server/src
parente9d10ba113a9f540d3e3c29177b27dd561f77869 (diff)
Upgrade Reactor and SpringBoot1.5.0
Issue-ID: DCAEGEN2-2537 Signed-off-by: tkogut <tomasz.kogut@nokia.com> Change-Id: Ide560554f11d01737b351d6138430efe6005791d
Diffstat (limited to 'datafile-app-server/src')
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java3
-rw-r--r--datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java3
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java2
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfigTest.java3
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleControllerTest.java11
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusControllerTest.java11
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java4
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java49
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerHttpClientTest.java4
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java30
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java20
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/PublishedCheckerTest.java3
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java38
13 files changed, 89 insertions, 92 deletions
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java
index 8b86440a..c24c6c96 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java
@@ -50,6 +50,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.util.DefaultUriBuilderFactory;
import reactor.core.publisher.Mono;
+import reactor.util.retry.Retry;
/**
* Publishes a file to the DataRouter.
@@ -85,7 +86,7 @@ public class DataRouterPublisher {
.cache() //
.flatMap(this::publishFile) //
.flatMap(httpStatus -> handleHttpResponse(httpStatus, publishInfo)) //
- .retryBackoff(numRetries, firstBackoff);
+ .retryWhen(Retry.backoff(numRetries,firstBackoff));
}
private Mono<HttpStatus> publishFile(FilePublishInformation publishInfo) {
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java
index b151b042..4b89f169 100644
--- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java
+++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import reactor.core.publisher.Mono;
+import reactor.util.retry.Retry;
/**
* Collects a file from a PNF.
@@ -79,7 +80,7 @@ public class FileCollector {
return Mono.just(fileData) //
.cache() //
.flatMap(fd -> tryCollectFile(fileData, contextMap)) //
- .retryBackoff(numRetries, firstBackoff) //
+ .retryWhen(Retry.backoff(numRetries,firstBackoff))
.flatMap(FileCollector::checkCollectedFile);
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java
index dc8a1229..7f0c6422 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java
@@ -50,7 +50,7 @@ import java.util.Properties;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfigTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfigTest.java
index 7b03e00e..cca563f6 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfigTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/SchedulerConfigTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2020 Nokia. 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.
@@ -20,7 +21,7 @@
package org.onap.dcaegen2.collectors.datafile.configuration;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleControllerTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleControllerTest.java
index 345c411c..b9816194 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleControllerTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/ScheduleControllerTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2020 Nokia. 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.
@@ -20,10 +21,10 @@
package org.onap.dcaegen2.collectors.datafile.controllers;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
import ch.qos.logback.classic.spi.ILoggingEvent;
@@ -118,7 +119,7 @@ public class ScheduleControllerTest {
assertEquals("ENTRY", logAppender.list.get(0).getMarker().getName());
assertNotNull(logAppender.list.get(0).getMDCPropertyMap().get("InvocationID"));
assertNotNull(logAppender.list.get(0).getMDCPropertyMap().get("RequestID"));
- assertTrue("Info missing in log", logAppender.list.toString().contains("[INFO] " + infoMessage));
+ assertTrue(logAppender.list.toString().contains("[INFO] " + infoMessage),"Info missing in log");
assertEquals("EXIT", logAppender.list.get(1).getMarker().getName());
logAppender.stop();
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusControllerTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusControllerTest.java
index 998bb17f..fbff041a 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusControllerTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/controllers/StatusControllerTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2020 Nokia. 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.
@@ -20,10 +21,10 @@
package org.onap.dcaegen2.collectors.datafile.controllers;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doReturn;
import ch.qos.logback.classic.spi.ILoggingEvent;
@@ -92,7 +93,7 @@ public class StatusControllerTest {
assertEquals("ENTRY", logAppender.list.get(0).getMarker().getName());
assertNotNull(logAppender.list.get(0).getMDCPropertyMap().get("InvocationID"));
assertNotNull(logAppender.list.get(0).getMDCPropertyMap().get("RequestID"));
- assertTrue("Info missing in log", logAppender.list.toString().contains("[INFO] Heartbeat request"));
+ assertTrue(logAppender.list.toString().contains("[INFO] Heartbeat request"),"Info missing in log");
assertEquals("EXIT", logAppender.list.get(1).getMarker().getName());
logAppender.stop();
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java
index 99bf1cd4..feeeb474 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java
@@ -19,8 +19,8 @@
package org.onap.dcaegen2.collectors.datafile.model;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java
index bfb9b13e..9e642b7d 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java
@@ -19,7 +19,7 @@
package org.onap.dcaegen2.collectors.datafile.service;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.spy;
import ch.qos.logback.classic.spi.ILoggingEvent;
@@ -47,7 +47,6 @@ import org.onap.dcaegen2.collectors.datafile.utils.JsonMessage.AdditionalField;
import org.onap.dcaegen2.collectors.datafile.utils.LoggingUtils;
import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
/**
@@ -241,12 +240,11 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectNextCount(0).verifyComplete();
- assertTrue("Error missing in log",
- logAppender.list.toString()
+ assertTrue(logAppender.list.toString()
.contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
+ Scheme.DFC_DOES_NOT_SUPPORT_PROTOCOL_ERROR_MSG + "http" + Scheme.SUPPORTED_PROTOCOLS_ERROR_MESSAGE
- + ". Location: http://location.xml"));
- assertTrue("Missing sourceName in log", logAppender.list.toString().contains("sourceName=5GRAN_DU"));
+ + ". Location: http://location.xml"),"Error missing in log");
+ assertTrue(logAppender.list.toString().contains("sourceName=5GRAN_DU"),"Missing sourceName in log");
}
@Test
@@ -326,9 +324,8 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectComplete().verify();
- assertTrue("Error missing in log",
- logAppender.list.toString().contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
- + "Can not get PRODUCT_NAME from eventName, eventName is not in correct format: Faulty event name"));
+ assertTrue(logAppender.list.toString().contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
+ + "Can not get PRODUCT_NAME from eventName, eventName is not in correct format: Faulty event name"),"Error missing in log");
}
@Test
@@ -357,11 +354,10 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectNextCount(0).verifyComplete();
- assertTrue("Error missing in log",
- logAppender.list.toString()
+ assertTrue(logAppender.list.toString()
.contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
+ "File information wrong. Missing data: [name] Data: "
- + message.getAdditionalFields().get(0).toString()));
+ + message.getAdditionalFields().get(0).toString()),"Error missing in log");
}
@Test
@@ -383,9 +379,8 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectNextCount(0).verifyComplete();
- assertTrue("Error missing in log",
- logAppender.list.toString().contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
- + "Missing arrayOfNamedHashMap in message. " + message.getParsed()));
+ assertTrue(logAppender.list.toString().contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
+ + "Missing arrayOfNamedHashMap in message. " + message.getParsed()),"Error missing in log");
}
@Test
@@ -414,11 +409,10 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectNextCount(0).verifyComplete();
- assertTrue("Error missing in log",
- logAppender.list.toString()
+ assertTrue(logAppender.list.toString()
.contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
+ "File information wrong. Missing data: [compression] Data: "
- + message.getAdditionalFields().get(0).toString()));
+ + message.getAdditionalFields().get(0).toString()),"Error missing in log");
}
@Test
@@ -447,11 +441,10 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectNextCount(0).verifyComplete();
- assertTrue("Error missing in log",
- logAppender.list.toString()
+ assertTrue(logAppender.list.toString()
.contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
+ "File information wrong. Missing data: [fileFormatType] Data: "
- + message.getAdditionalFields().get(0).toString()));
+ + message.getAdditionalFields().get(0).toString()),"Error missing in log");
}
@Test
@@ -529,11 +522,10 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectComplete().verify();
- assertTrue("Error missing in log",
- logAppender.list.toString()
+ assertTrue(logAppender.list.toString()
.contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING
+ "Missing data: [changeIdentifier, changeType, notificationFieldsVersion]. "
- + "Change type is wrong: Expected: FileReady Message: " + message.getParsed()));
+ + "Change type is wrong: Expected: FileReady Message: " + message.getParsed()),"Error missing in log");
}
@Test
@@ -548,8 +540,8 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectComplete().verify();
- assertTrue("Error missing in log",
- logAppender.list.toString().contains(ERROR_LOG_TAG + "Incorrect JsonObject - missing header. "));
+ assertTrue(logAppender.list.toString().contains(ERROR_LOG_TAG + "Incorrect JsonObject - missing header. ")
+ ,"Error missing in log");
}
@Test
@@ -578,10 +570,9 @@ class JsonMessageParserTest {
StepVerifier.create(jsonMessageParserUnderTest.getMessagesFromJson(Flux.just(jsonElement))).expectSubscription()
.expectNextCount(0).expectComplete().verify();
- assertTrue("Error missing in log",
- logAppender.list.toString()
+ assertTrue(logAppender.list.toString()
.contains(ERROR_LOG_TAG + JsonMessageParser.ERROR_MSG_VES_EVENT_PARSING + " Change type is wrong: "
- + INCORRECT_CHANGE_TYPE + " Expected: FileReady Message: " + message.getParsed()));
+ + INCORRECT_CHANGE_TYPE + " Expected: FileReady Message: " + message.getParsed()),"Error missing in log");
}
@Test
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerHttpClientTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerHttpClientTest.java
index 1ddb3a5c..addd77d2 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerHttpClientTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerHttpClientTest.java
@@ -16,8 +16,8 @@
package org.onap.dcaegen2.collectors.datafile.service.producer;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java
index 4a4c4e83..8cf5fa97 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START======================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property, 2018-2019 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2018-2020 NOKIA Intellectual Property, 2018-2019 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
@@ -16,8 +16,8 @@
package org.onap.dcaegen2.collectors.datafile.tasks;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -177,8 +177,8 @@ class DataRouterPublisherTest {
// This should be 10 unless the API is updated (which is the fields checked above)
assertEquals(10, metaHash.size());
- assertEquals("totalPublishedFiles should have been 1", 1, counters.getTotalPublishedFiles());
- assertEquals("noOfFailedPublishAttempts should have been 0", 0, counters.getNoOfFailedPublishAttempts());
+ assertEquals(1, counters.getTotalPublishedFiles(),"totalPublishedFiles should have been 1");
+ assertEquals(0, counters.getNoOfFailedPublishAttempts(),"noOfFailedPublishAttempts should have been 0");
}
@Test
@@ -190,11 +190,11 @@ class DataRouterPublisherTest {
.expectNext(filePublishInformation) //
.verifyComplete();
- assertTrue("Warning missing in log",
- logAppender.list.toString().contains("[WARN] Publishing file " + PM_FILE_NAME + " to DR unsuccessful."));
+ assertTrue(logAppender.list.toString().contains("[WARN] Publishing file " + PM_FILE_NAME + " to DR unsuccessful.")
+ ,"Warning missing in log");
- assertEquals("totalPublishedFiles should have been 1", 1, counters.getTotalPublishedFiles());
- assertEquals("noOfFailedPublishAttempts should have been 1", 1, counters.getNoOfFailedPublishAttempts());
+ assertEquals(1, counters.getTotalPublishedFiles(),"totalPublishedFiles should have been 1");
+ assertEquals(1, counters.getNoOfFailedPublishAttempts(),"noOfFailedPublishAttempts should have been 1");
}
@Test
@@ -211,8 +211,8 @@ class DataRouterPublisherTest {
verify(httpClientMock, times(2)).getDmaapProducerResponseWithRedirect(any(HttpUriRequest.class), any());
verifyNoMoreInteractions(httpClientMock);
- assertEquals("totalPublishedFiles should have been 1", 1, counters.getTotalPublishedFiles());
- assertEquals("noOfFailedPublishAttempts should have been 1", 1, counters.getNoOfFailedPublishAttempts());
+ assertEquals(1, counters.getTotalPublishedFiles(),"totalPublishedFiles should have been 1");
+ assertEquals(1, counters.getNoOfFailedPublishAttempts(),"noOfFailedPublishAttempts should have been 1");
}
@Test
@@ -225,15 +225,15 @@ class DataRouterPublisherTest {
.expectErrorMessage("Retries exhausted: 1/1") //
.verify();
- assertTrue("Warning missing in log", logAppender.list.toString().contains("[WARN] Publishing file "
- + PM_FILE_NAME + " to DR unsuccessful. Response code: " + HttpStatus.BAD_GATEWAY));
+ assertTrue(logAppender.list.toString().contains("[WARN] Publishing file "
+ + PM_FILE_NAME + " to DR unsuccessful. Response code: " + HttpStatus.BAD_GATEWAY),"Warning missing in log");
verify(httpClientMock, times(2)).addUserCredentialsToHead(any(HttpUriRequest.class));
verify(httpClientMock, times(2)).getDmaapProducerResponseWithRedirect(any(HttpUriRequest.class), any());
verifyNoMoreInteractions(httpClientMock);
- assertEquals("totalPublishedFiles should have been 0", 0, counters.getTotalPublishedFiles());
- assertEquals("noOfFailedPublishAttempts should have been 2", 2, counters.getNoOfFailedPublishAttempts());
+ assertEquals(0, counters.getTotalPublishedFiles(),"totalPublishedFiles should have been 0");
+ assertEquals(2, counters.getNoOfFailedPublishAttempts(),"noOfFailedPublishAttempts should have been 2");
}
@SafeVarargs
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java
index b7b69e8d..a98e2baf 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java
@@ -17,7 +17,7 @@
package org.onap.dcaegen2.collectors.datafile.tasks;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -176,8 +176,8 @@ public class FileCollectorTest {
verify(ftpesClientMock, times(1)).close();
verifyNoMoreInteractions(ftpesClientMock);
- assertEquals("collectedFiles should have been 1", 1, counters.getNoOfCollectedFiles());
- assertEquals("failedFtpAttempts should have been 0", 0, counters.getNoOfFailedFtpAttempts());
+ assertEquals(1, counters.getNoOfCollectedFiles(),"collectedFiles should have been 1");
+ assertEquals(0, counters.getNoOfFailedFtpAttempts(),"failedFtpAttempts should have been 0");
}
@Test
@@ -206,7 +206,7 @@ public class FileCollectorTest {
verify(sftpClientMock, times(2)).close();
verifyNoMoreInteractions(sftpClientMock);
- assertEquals("collectedFiles should have been 2", 2, counters.getNoOfCollectedFiles());
+ assertEquals(2, counters.getNoOfCollectedFiles(),"collectedFiles should have been 2");
}
@Test
@@ -224,8 +224,8 @@ public class FileCollectorTest {
verify(ftpesClientMock, times(4)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
- assertEquals("collectedFiles should have been 0", 0, counters.getNoOfCollectedFiles());
- assertEquals("failedFtpAttempts should have been 4", 4, counters.getNoOfFailedFtpAttempts());
+ assertEquals(0, counters.getNoOfCollectedFiles(),"collectedFiles should have been 0");
+ assertEquals(4, counters.getNoOfFailedFtpAttempts(),"failedFtpAttempts should have been 4");
}
@Test
@@ -243,8 +243,8 @@ public class FileCollectorTest {
verify(ftpesClientMock, times(1)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
- assertEquals("collectedFiles should have been 0", 0, counters.getNoOfCollectedFiles());
- assertEquals("failedFtpAttempts should have been 1", 1, counters.getNoOfFailedFtpAttempts());
+ assertEquals(0, counters.getNoOfCollectedFiles(),"collectedFiles should have been 0");
+ assertEquals(1, counters.getNoOfFailedFtpAttempts(),"failedFtpAttempts should have been 1");
}
@Test
@@ -265,7 +265,7 @@ public class FileCollectorTest {
verify(ftpesClientMock, times(2)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
- assertEquals("collectedFiles should have been 1", 1, counters.getNoOfCollectedFiles());
- assertEquals("failedFtpAttempts should have been 1", 1, counters.getNoOfFailedFtpAttempts());
+ assertEquals(1, counters.getNoOfCollectedFiles(),"collectedFiles should have been 1");
+ assertEquals(1, counters.getNoOfFailedFtpAttempts(),"failedFtpAttempts should have been 1");
}
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/PublishedCheckerTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/PublishedCheckerTest.java
index 3a387e28..2389c154 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/PublishedCheckerTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/PublishedCheckerTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+* Copyright (C) 2020 Nokia. 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.
@@ -20,7 +21,7 @@
package org.onap.dcaegen2.collectors.datafile.tasks;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java
index 199ac9f6..d5a9a92c 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java
@@ -22,9 +22,9 @@
package org.onap.dcaegen2.collectors.datafile.tasks;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
@@ -74,6 +74,7 @@ import org.slf4j.MDC;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
+import reactor.test.scheduler.VirtualTimeScheduler;
public class ScheduledTasksTest {
@@ -247,7 +248,7 @@ public class ScheduledTasksTest {
testedObject.executeDatafileMainTask();
- await().untilAsserted(() -> assertEquals("currentNumberOfSubscriptions should have been 0", 0,
+ await().untilAsserted(() -> assertEquals(0,
testedObject.getCurrentNumberOfSubscriptions()));
assertFalse(StringUtils.isBlank(MDC.get(MdcVariables.REQUEST_ID)));
@@ -256,7 +257,7 @@ public class ScheduledTasksTest {
verify(appConfig).isFeedConfigured(CHANGE_IDENTIFIER);
verifyNoMoreInteractions(appConfig);
- assertEquals("totalReceivedEvents should have been 1", 1, testedObject.getCounters().getTotalReceivedEvents());
+ assertEquals(1, testedObject.getCounters().getTotalReceivedEvents(),"totalReceivedEvents should have been 1");
}
@Test
@@ -289,11 +290,10 @@ public class ScheduledTasksTest {
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(ScheduledTasks.class);
testedObject.executeDatafileMainTask();
- await().untilAsserted(() -> assertEquals("currentNumberOfSubscriptions should have been 0", 0,
- testedObject.getCurrentNumberOfSubscriptions()));
+ await().untilAsserted(() -> assertEquals(0, testedObject.getCurrentNumberOfSubscriptions(),"currentNumberOfSubscriptions should have been 0"));
- assertTrue("Error missing in log", logAppender.list.toString().contains(
- "[INFO] No feed is configured for: " + CHANGE_IDENTIFIER + ", file ignored: " + PM_FILE_NAME + "1"));
+ assertTrue(logAppender.list.toString().contains(
+ "[INFO] No feed is configured for: " + CHANGE_IDENTIFIER + ", file ignored: " + PM_FILE_NAME + "1"),"Error missing in log");
}
@Test
@@ -309,8 +309,8 @@ public class ScheduledTasksTest {
.expectComplete() //
.verify(); //
- assertTrue("Error missing in log", logAppender.list.toString()
- .contains("[ERROR] Polling for file ready message failed, " + "exception: java.lang.Exception: Failed"));
+ assertTrue(logAppender.list.toString()
+ .contains("[ERROR] Polling for file ready message failed, " + "exception: java.lang.Exception: Failed"),"Error missing in log");
}
@Test
@@ -349,8 +349,8 @@ public class ScheduledTasksTest {
verify(dataRouterMock, times(noOfFiles)).publishFile(notNull(), anyLong(), notNull());
verifyNoMoreInteractions(dataRouterMock);
- assertEquals("totalReceivedEvents should have been 200", 200,
- testedObject.getCounters().getTotalReceivedEvents());
+ assertEquals(200,
+ testedObject.getCounters().getTotalReceivedEvents(),"totalReceivedEvents should have been 200");
}
@Test
@@ -391,8 +391,8 @@ public class ScheduledTasksTest {
verify(dataRouterMock, times(3)).publishFile(notNull(), anyLong(), notNull());
verifyNoMoreInteractions(dataRouterMock);
- assertEquals("totalReceivedEvents should have been 2", 2, testedObject.getCounters().getTotalReceivedEvents());
- assertEquals("failedFtp should have been 1", 1, testedObject.getCounters().getNoOfFailedFtp());
+ assertEquals(2, testedObject.getCounters().getTotalReceivedEvents(),"totalReceivedEvents should have been 2");
+ assertEquals(1, testedObject.getCounters().getNoOfFailedFtp(),"failedFtp should have been 1");
}
@Test
@@ -421,7 +421,7 @@ public class ScheduledTasksTest {
.expectComplete() //
.verify(); //
- assertTrue("Error missing in log", logAppender.list.toString().contains("[ERROR] File publishing failed: "));
+ assertTrue(logAppender.list.toString().contains("[ERROR] File publishing failed: "));
assertEquals(0, testedObject.getCurrentNumberOfTasks());
@@ -434,8 +434,8 @@ public class ScheduledTasksTest {
verify(dataRouterMock, times(4)).publishFile(notNull(), anyLong(), notNull());
verifyNoMoreInteractions(dataRouterMock);
- assertEquals("totalReceivedEvents should have been 2", 2, testedObject.getCounters().getTotalReceivedEvents());
- assertEquals("noOfFailedPublish should have been 1", 1, testedObject.getCounters().getNoOfFailedPublish());
+ assertEquals(2, testedObject.getCounters().getTotalReceivedEvents(),"totalReceivedEvents should have been 2");
+ assertEquals(1, testedObject.getCounters().getNoOfFailedPublish(),"noOfFailedPublish should have been 1");
}
@Test
@@ -475,6 +475,6 @@ public class ScheduledTasksTest {
verify(publishedCheckerMock, times(1)).isFilePublished(notNull(), anyString(), notNull());
verifyNoMoreInteractions(publishedCheckerMock);
- assertEquals("totalReceivedEvents should have been 1", 1, testedObject.getCounters().getTotalReceivedEvents());
+ assertEquals(1, testedObject.getCounters().getTotalReceivedEvents(),"totalReceivedEvents should have been 1");
}
}