* ========================LICENSE_START=================================
* ONAP : ccsdk oran
* ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2019-2025 OpenInfra Foundation Europe. 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.
"Configuration error, controller configuration not found: " + controllerName);
}
- RicConfig ricConfig = RicConfig.builder() //
- .ricId(get(ricJsonObj, "name", "id", "ricId").getAsString()) //
- .baseUrl(get(ricJsonObj, "baseUrl").getAsString()) //
- .managedElementIds(parseManagedElementIds(get(ricJsonObj, "managedElementIds").getAsJsonArray())) //
+ RicConfig.RicConfigBuilder ricConfigBuilder = RicConfig.builder()
+ .ricId(get(ricJsonObj, "name", "id", "ricId").getAsString())
+ .baseUrl(get(ricJsonObj, "baseUrl").getAsString())
.controllerConfig(controllerConfig)
- .customAdapterClass(getString(ricJsonObj, "customAdapterClass", "")) //
- .build();
+ .customAdapterClass(getString(ricJsonObj, "customAdapterClass", ""));
+
+ if (ricJsonObj.has("managedElementIds")) {
+ ricConfigBuilder
+ .managedElementIds(parseManagedElementIds(get(ricJsonObj, "managedElementIds").getAsJsonArray()));
+ } else {
+ ricConfigBuilder.managedElementIds(null);
+ }
+
+ RicConfig ricConfig = ricConfigBuilder.build();
if (!ricConfig.getBaseUrl().isEmpty()) {
result.add(ricConfig);
} else {
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
@RestController("ricRepositoryControllerV2")
@RequiredArgsConstructor
}
private RicInfo toRicInfo(Ric ric) {
- return new RicInfo().ricId(ric.id())
- .managedElementIds((List<String>) ric.getManagedElementIds())
+ RicInfo ricInfo = new RicInfo().ricId(ric.id())
.policytypeIds((List<String>) ric.getSupportedPolicyTypeNames())
.state(toRicState(ric.getState()));
+
+ if (ric.getConfig().getManagedElementIds() == null) {
+ ricInfo.setManagedElementIds(new ArrayList<>());
+ } else {
+ ricInfo.managedElementIds((List<String>) ric.getConfig().getManagedElementIds());
+ }
+
+ return ricInfo;
}
}
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
@RestController("ricRepositoryControllerV3")
@RequiredArgsConstructor
}
private RicInfo toRicInfo(Ric ric) {
- return new RicInfo().ricId(ric.id())
- .managedElementIds((List<String>) ric.getManagedElementIds())
+ RicInfo ricInfo = new RicInfo().ricId(ric.id())
.policyTypeIds((List<String>) ric.getSupportedPolicyTypeNames())
.state(toRicState(ric.getState()));
+
+ if (ric.getConfig().getManagedElementIds() == null) {
+ ricInfo.setManagedElementIds(new ArrayList<>());
+ } else {
+ ricInfo.managedElementIds((List<String>) ric.getConfig().getManagedElementIds());
+ }
+
+ return ricInfo;
}
private RicInfo.StateEnum toRicState(Ric.RicState state) {
/*-
* ========================LICENSE_START=================================
- * Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2020-2025 OpenInfra Foundation Europe. 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.
"app.config-file-schema-path=/application_configuration_schema.json" //
})
class ConfigurationControllerV3Test {
+
+ @Autowired
+ private RefreshConfigTask refreshConfigTask;
+
@Autowired
ApplicationContext context;
testHelperTest.testSuccessResponse(responseGetConfigMono, HttpStatus.OK, responseBody -> responseBody.contains("config"));
}
+ @Test
+ void testPutConfigurationMeNull() throws Exception {
+ Mono<ResponseEntity<String>> responseEntityMono = testHelperTest.restClientV3().putForEntity("/configuration",
+ testHelperTest.configAsStringMeNull());
+ testHelperTest.testSuccessResponse(responseEntityMono, HttpStatus.OK, Objects::isNull);
+ //put Valid Configuration With New Ric should Update Repository. So, will wait until the ric size is 2
+ await().until(rics::size, equalTo(2));
+ //test Get Configuration
+ Mono<ResponseEntity<String>> responseGetConfigMono = testHelperTest.restClientV3().getForEntity("/configuration");
+ testHelperTest.testSuccessResponse(responseGetConfigMono, HttpStatus.OK, responseBody -> !responseBody.contains("\"managedElementIds\""));
+
+ refreshConfigTask.start();
+
+ Mono<ResponseEntity<String>> responseGetRicsMono = testHelperTest.restClientV3().getForEntity("/rics");
+ testHelperTest.testSuccessResponse(responseGetRicsMono, HttpStatus.OK, responseBody -> responseBody.contains("\"managedElementIds\":[]"));
+
+ Mono<ResponseEntity<String>> responseGetRicMono = testHelperTest.restClientV3().getForEntity("/rics/ric1");
+ testHelperTest.testSuccessResponse(responseGetRicMono, HttpStatus.OK, responseBody -> responseBody.contains("\"managedElementIds\":[]"));
+ }
+
+ @Test
+ void testPutConfigurationMeEmpty() throws Exception {
+ Mono<ResponseEntity<String>> responseEntityMono = testHelperTest.restClientV3().putForEntity("/configuration",
+ testHelperTest.configAsStringMeEmpty());
+ testHelperTest.testSuccessResponse(responseEntityMono, HttpStatus.OK, Objects::isNull);
+ //put Valid Configuration With New Ric should Update Repository. So, will wait until the ric size is 2
+ await().until(rics::size, equalTo(2));
+ //test Get Configuration
+ Mono<ResponseEntity<String>> responseGetConfigMono = testHelperTest.restClientV3().getForEntity("/configuration");
+ testHelperTest.testSuccessResponse(responseGetConfigMono, HttpStatus.OK, responseBody -> responseBody.contains("\"managedElementIds\":[]"));
+
+ refreshConfigTask.start();
+
+ Mono<ResponseEntity<String>> responseGetRicsMono = testHelperTest.restClientV3().getForEntity("/rics");
+ testHelperTest.testSuccessResponse(responseGetRicsMono, HttpStatus.OK, responseBody -> responseBody.contains("\"managedElementIds\":[]"));
+
+ Mono<ResponseEntity<String>> responseGetRicMono = testHelperTest.restClientV3().getForEntity("/rics/ric1");
+ testHelperTest.testSuccessResponse(responseGetRicMono, HttpStatus.OK, responseBody -> responseBody.contains("\"managedElementIds\":[]"));
+ }
+
@Test
void testHealthCheck() {
Mono<ResponseEntity<String>> responseHealthCheckMono = testHelperTest.restClientV3().getForEntity("/status");
new File(Objects.requireNonNull(getClass().getClassLoader().getResource("test_application_configuration.json")).getFile());
return FileUtils.readFileToString(configFile, "UTF-8");
}
+
+ public String configAsStringMeNull() throws Exception {
+ File configFile =
+ new File(Objects.requireNonNull(getClass().getClassLoader().getResource("test_application_configuration_me_null.json")).getFile());
+ return FileUtils.readFileToString(configFile, "UTF-8");
+ }
+
+ public String configAsStringMeEmpty() throws Exception {
+ File configFile =
+ new File(Objects.requireNonNull(getClass().getClassLoader().getResource("test_application_configuration_me_empty.json")).getFile());
+ return FileUtils.readFileToString(configFile, "UTF-8");
+ }
}
--- /dev/null
+{
+ "config": {
+ "description": "Test",
+ "controller": [
+ {
+ "name": "controller1",
+ "baseUrl": "http://localhost:8083/",
+ "userName": "user",
+ "password": "password"
+ }
+ ],
+ "ric": [
+ {
+ "name": "ric1",
+ "controller": "controller1",
+ "baseUrl": "http://localhost:8083/",
+ "customAdapterClass": "org.onap.ccsdk.oran.a1policymanagementservice.clients.StdA1ClientVersion2$Factory",
+ "managedElementIds": []
+ },
+ {
+ "name": "ric2",
+ "baseUrl": "http://localhost:8085/",
+ "managedElementIds": []
+ },
+ {
+ "name": "ric3_noBaseURL",
+ "baseUrl": "",
+ "managedElementIds": []
+ }
+ ]
+ }
+}
--- /dev/null
+{
+ "config": {
+ "description": "Test",
+ "controller": [
+ {
+ "name": "controller1",
+ "baseUrl": "http://localhost:8083/",
+ "userName": "user",
+ "password": "password"
+ }
+ ],
+ "ric": [
+ {
+ "name": "ric1",
+ "controller": "controller1",
+ "baseUrl": "http://localhost:8083/",
+ "customAdapterClass": "org.onap.ccsdk.oran.a1policymanagementservice.clients.StdA1ClientVersion2$Factory"
+ },
+ {
+ "name": "ric2",
+ "baseUrl": "http://localhost:8085/"
+ },
+ {
+ "name": "ric3_noBaseURL",
+ "baseUrl": ""
+ }
+ ]
+ }
+}