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";
throw new ServiceException(
"Configuration error, controller configuration not found: " + ric.controllerName());
}
-
}
}
.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;
}
.password("password") //
.build(); //
assertEquals(expectedControllerConfig, controllers.get("controller1"), "controller contents");
+
+ assertEquals(2, result.ricConfigs().size());
}
private JsonObject getJsonRootObject() throws JsonIOException, JsonSyntaxException, IOException {
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));
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));