Ignoring RiConfigs with empty baseUrl 96/119896/1
authorPatrikBuhr <patrik.buhr@est.tech>
Fri, 26 Mar 2021 10:47:37 +0000 (11:47 +0100)
committerPatrikBuhr <patrik.buhr@est.tech>
Fri, 26 Mar 2021 10:49:54 +0000 (11:49 +0100)
Illegal message from A1 policy management causing flood of log messages

Change-Id: I851f36f499255dbd82714d39caa77e771d39d282
Issue-ID: CCSDK-3227
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java
a1-policy-management/src/test/resources/test_application_configuration_with_dmaap_config.json

index bc1f62a..a6af202 100644 (file)
@@ -39,11 +39,14 @@ import javax.validation.constraints.NotNull;
 import org.immutables.gson.Gson;
 import org.immutables.value.Value;
 import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Parser for the Json representing of the component configuration.
  */
 public class ApplicationConfigParser {
+    private static final Logger logger = LoggerFactory.getLogger(ApplicationConfigParser.class);
 
     private static final String CONFIG = "config";
     private static final String CONTROLLER = "controller";
@@ -109,7 +112,6 @@ public class ApplicationConfigParser {
                 throw new ServiceException(
                         "Configuration error, controller configuration not found: " + ric.controllerName());
             }
-
         }
     }
 
@@ -124,7 +126,11 @@ public class ApplicationConfigParser {
                     .managedElementIds(parseManagedElementIds(get(ricAsJson, "managedElementIds").getAsJsonArray())) //
                     .controllerName(controllerNameElement != null ? controllerNameElement.getAsString() : "") //
                     .build();
-            result.add(ricConfig);
+            if (!ricConfig.baseUrl().isEmpty()) {
+                result.add(ricConfig);
+            } else {
+                logger.error("RIC configuration error {}, baseUrl is empty", ricConfig.ricId());
+            }
         }
         return result;
     }
index 0a75fd3..fe2fb27 100644 (file)
@@ -69,6 +69,8 @@ class ApplicationConfigParserTest {
                 .password("password") //
                 .build(); //
         assertEquals(expectedControllerConfig, controllers.get("controller1"), "controller contents");
+
+        assertEquals(2, result.ricConfigs().size());
     }
 
     private JsonObject getJsonRootObject() throws JsonIOException, JsonSyntaxException, IOException {
@@ -91,8 +93,8 @@ class ApplicationConfigParserTest {
         fake_info_object.addProperty("fake_info", "fake");
         json.add("fake_info_object", new Gson().toJsonTree(fake_info_object));
         DataPublishing data = new Gson().fromJson(json.toString(), DataPublishing.class);
-        final String expectedMessage =
-                "Invalid configuration. Number of streams must be one, config: " + data.toString();
+        final String expectedMessage = "Invalid configuration. Number of streams must be one, config: "
+                + data.toString();
 
         Exception actualException = assertThrows(ServiceException.class, () -> parserUnderTest.parse(jsonRootObject));
 
@@ -119,8 +121,8 @@ class ApplicationConfigParserTest {
         fake_info_object.addProperty("fake_info", "fake");
         json.add("fake_info_object", new Gson().toJsonTree(fake_info_object));
         DataSubscribing data = new Gson().fromJson(json.toString(), DataSubscribing.class);
-        final String expectedMessage =
-                "Invalid configuration. Number of streams must be one, config: " + data.toString();
+        final String expectedMessage = "Invalid configuration. Number of streams must be one, config: "
+                + data.toString();
 
         Exception actualException = assertThrows(ServiceException.class, () -> parserUnderTest.parse(jsonRootObject));
 
index 61ab31e..ed1501d 100644 (file)
                "kista_3",
                "kista_4"
             ]
+         },
+         {
+            "name": "ric3_noBaseURL",
+            "baseUrl": "",
+            "managedElementIds": [
+               "kista_3",
+               "kista_4"
+            ]
          }
       ],
       "streams_publishes": {
@@ -44,4 +52,4 @@
          }
       }
    }
-}
\ No newline at end of file
+}