NONRTRIC - bugfix 59/8859/2
authorPatrikBuhr <patrik.buhr@est.tech>
Fri, 12 Aug 2022 07:54:56 +0000 (09:54 +0200)
committerPatrikBuhr <patrik.buhr@est.tech>
Fri, 12 Aug 2022 07:59:54 +0000 (09:59 +0200)
Discarding of empty output filtering.

Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Issue-ID: NONRTRIC-773
Change-Id: I141ed9aea0cb6d893f014ce49bb1d70a0dbaa8f0

src/main/java/org/oran/dmaapadapter/filter/Filter.java
src/main/java/org/oran/dmaapadapter/tasks/JobDataDistributor.java
src/test/java/org/oran/dmaapadapter/ApplicationTest.java

index afb424c..9d29663 100644 (file)
@@ -35,6 +35,10 @@ public interface Filter {
         public final String key;
         public final String value;
 
+        public boolean isEmpty() {
+            return value.isEmpty() && key.isEmpty();
+        }
+
         public FilteredData(String key, String value) {
             this.key = key;
             this.value = value;
index 54b8831..ae1f413 100644 (file)
@@ -104,7 +104,8 @@ public abstract class JobDataDistributor {
     }
 
     private Flux<Filter.FilteredData> filterAndBuffer(Flux<TopicListener.DataFromTopic> inputFlux, Job job) {
-        Flux<Filter.FilteredData> filtered = inputFlux.map(job::filter); //
+        Flux<Filter.FilteredData> filtered = inputFlux.map(job::filter) //
+                .filter(f -> !f.isEmpty());
 
         if (job.isBuffered()) {
             filtered = filtered.map(input -> quoteNonJson(input.value, job)) //
index 014de25..635fa65 100644 (file)
@@ -268,6 +268,7 @@ class ApplicationTest {
 
     @Test
     void testTrustValidation() throws IOException {
+
         String url = "https://localhost:" + applicationConfig.getLocalServerHttpPort() + "/v3/api-docs";
         ResponseEntity<String> resp = restClient(true).getForEntity(url).block();
         assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK);
@@ -404,6 +405,8 @@ class ApplicationTest {
         // filtered PM message
         String path = "./src/test/resources/pm_report.json";
         String pmReportJson = Files.readString(Path.of(path), Charset.defaultCharset());
+        DmaapSimulatorController.addPmResponse("{}"); // This should just be discarded
+
         DmaapSimulatorController.addPmResponse(pmReportJson);
 
         ConsumerController.TestResults consumer = this.consumerController.testResults;