From 5e7e5f2c0cdd4e5554f4d8629403b7c554b3a0aa Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Fri, 31 Mar 2023 13:20:42 +0200 Subject: Changes needed to make custom adapters that accesses CCSDK To access the CCSDK a custom adapter needs the controller configuration. Issue-ID: CCSDK-3883 Signed-off-by: PatrikBuhr Change-Id: I6fb3eb3bb953f3fc209229282b66c9e1aa10cdee --- .../clients/A1ClientFactory.java | 15 ++---- .../clients/CcsdkA1AdapterClient.java | 20 ++++---- .../configuration/ApplicationConfig.java | 11 ----- .../configuration/ApplicationConfigParser.java | 19 +++++--- .../configuration/RicConfig.java | 2 +- .../controllers/v2/PolicyController.java | 1 - .../clients/A1ClientFactoryTest.java | 19 ++------ .../clients/A1ClientHelper.java | 23 ++------- .../clients/CcsdkA1AdapterClientTest.java | 54 +++++++++++++--------- .../clients/OscA1ClientTest.java | 12 ++++- .../configuration/MetersTest.java | 3 +- .../tasks/RicSupervisionTest.java | 1 - .../tasks/RicSynchronizationTaskTest.java | 1 - 13 files changed, 79 insertions(+), 102 deletions(-) (limited to 'a1-policy-management') diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java index 14738a91..54dfab88 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java @@ -84,7 +84,7 @@ public class A1ClientFactory { } else if (version == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1 || version == A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1 || version == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0) { - return new CcsdkA1AdapterClient(version, ric.getConfig(), getControllerConfig(ric), this.restClientFactory); + return new CcsdkA1AdapterClient(version, ric.getConfig(), this.restClientFactory); } else if (version == A1ProtocolType.CUSTOM_PROTOCOL) { return createCustomAdapter(ric); } else { @@ -94,17 +94,12 @@ public class A1ClientFactory { } private ControllerConfig getControllerConfig(Ric ric) throws ServiceException { - String controllerName = ric.getConfig().getControllerName(); - if (controllerName.isEmpty()) { + ControllerConfig controllerConfig = ric.getConfig().getControllerConfig(); + if (controllerConfig == null) { ric.setProtocolVersion(A1ProtocolType.UNKNOWN); throw new ServiceException("No controller configured for Near-RT RIC: " + ric.id()); } - try { - return this.appConfig.getControllerConfig(controllerName); - } catch (ServiceException e) { - ric.setProtocolVersion(A1ProtocolType.UNKNOWN); - throw e; - } + return controllerConfig; } private A1Client createCustomAdapter(Ric ric) throws ServiceException { @@ -127,7 +122,7 @@ public class A1ClientFactory { } private void assertNoControllerConfig(Ric ric, A1ProtocolType version) throws ServiceException { - if (!ric.getConfig().getControllerName().isEmpty()) { + if (ric.getConfig().getControllerConfig() != null) { ric.setProtocolVersion(A1ProtocolType.UNKNOWN); throw new ServiceException( "Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version); diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java index 225d2f71..3b0d12a4 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java @@ -85,7 +85,6 @@ public class CcsdkA1AdapterClient implements A1Client { private static final String GET_POLICY_RPC = "getA1Policy"; private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final ControllerConfig controllerConfig; private final AsyncRestClient restClient; private final RicConfig ricConfig; private final A1ProtocolType protocolType; @@ -103,10 +102,10 @@ public class CcsdkA1AdapterClient implements A1Client { * * @throws IllegalArgumentException when the protocolType is wrong. */ - public CcsdkA1AdapterClient(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig, + public CcsdkA1AdapterClient(A1ProtocolType protocolType, RicConfig ricConfig, AsyncRestClientFactory restClientFactory) { - this(protocolType, ricConfig, controllerConfig, - restClientFactory.createRestClientNoHttpProxy(controllerConfig.getBaseUrl() + "/rests/operations")); + this(protocolType, ricConfig, restClientFactory + .createRestClientNoHttpProxy(ricConfig.getControllerConfig().getBaseUrl() + "/rests/operations")); } /** @@ -123,16 +122,15 @@ public class CcsdkA1AdapterClient implements A1Client { * * @throws IllegalArgumentException when the protocolType is illegal. */ - CcsdkA1AdapterClient(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig, - AsyncRestClient restClient) { + CcsdkA1AdapterClient(A1ProtocolType protocolType, RicConfig ricConfig, AsyncRestClient restClient) { if (A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1.equals(protocolType) // || A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1.equals(protocolType) // || A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0.equals(protocolType)) { this.restClient = restClient; this.ricConfig = ricConfig; this.protocolType = protocolType; - this.controllerConfig = controllerConfig; - logger.debug("CcsdkA1AdapterClient for ric: {}, a1Controller: {}", ricConfig.getRicId(), controllerConfig); + logger.debug("CcsdkA1AdapterClient for ric: {}, a1Controller: {}", ricConfig.getRicId(), + ricConfig.getControllerConfig()); } else { logger.error("Not supported protocoltype: {}", protocolType); throw new IllegalArgumentException("Not handeled protocolversion: " + protocolType); @@ -284,10 +282,10 @@ public class CcsdkA1AdapterClient implements A1Client { final String inputJsonString = A1AdapterJsonHelper.createInputJsonString(inputParams); logger.debug("POST inputJsonString = {}", inputJsonString); - + ControllerConfig controllerConfig = this.ricConfig.getControllerConfig(); return restClient - .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.getUserName(), - this.controllerConfig.getPassword()) // + .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, controllerConfig.getUserName(), + controllerConfig.getPassword()) // .flatMap(resp -> extractResponseBody(resp, ricUrl)); } diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java index 358680a0..eea96927 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java @@ -100,8 +100,6 @@ public class ApplicationConfig { private Map ricConfigs = new HashMap<>(); - private Map controllerConfigs = new HashMap<>(); - private WebClientConfig webClientConfig = null; public synchronized Collection getRicConfigs() { @@ -130,14 +128,6 @@ public class ApplicationConfig { return this.webClientConfig; } - public synchronized ControllerConfig getControllerConfig(String name) throws ServiceException { - ControllerConfig controllerConfig = this.controllerConfigs.get(name); - if (controllerConfig == null) { - throw new ServiceException("Could not find controller config: " + name); - } - return controllerConfig; - } - public synchronized RicConfig getRic(String ricId) throws ServiceException { RicConfig ricConfig = this.ricConfigs.get(ricId); if (ricConfig == null) { @@ -166,7 +156,6 @@ public class ApplicationConfig { ApplicationConfigParser.ConfigParserResult parserResult) { Collection modifications = new ArrayList<>(); - this.controllerConfigs = parserResult.getControllerConfigs(); Map newRicConfigs = new HashMap<>(); for (RicConfig newConfig : parserResult.getRicConfigs()) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java index 9df901fa..45305f84 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java @@ -81,8 +81,9 @@ public class ApplicationConfigParser { throw new ServiceException("Missing root configuration \"" + CONFIG + "\" in JSON: " + root); } - List ricConfigs = parseRics(pmsConfigJson); Map controllerConfigs = parseControllerConfigs(pmsConfigJson); + List ricConfigs = parseRics(pmsConfigJson, controllerConfigs); + checkConfigurationConsistency(ricConfigs, controllerConfigs); return ConfigParserResult.builder() // @@ -133,22 +134,26 @@ public class ApplicationConfigParser { if (!ricNames.add(ric.getRicId())) { throw new ServiceException("Configuration error, more than one RIC with name: " + ric.getRicId()); } - if (!ric.getControllerName().isEmpty() && controllerConfigs.get(ric.getControllerName()) == null) { - throw new ServiceException( - "Configuration error, controller configuration not found: " + ric.getControllerName()); - } } } - private List parseRics(JsonObject config) throws ServiceException { + private List parseRics(JsonObject config, Map controllerConfigs) + throws ServiceException { List result = new ArrayList<>(); for (JsonElement ricElem : getAsJsonArray(config, "ric")) { JsonObject ricJsonObj = ricElem.getAsJsonObject(); + String controllerName = getString(ricJsonObj, CONTROLLER, ""); + ControllerConfig controllerConfig = controllerConfigs.get(controllerName); + if (!controllerName.isEmpty() && controllerConfig == null) { + throw new ServiceException( + "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())) // - .controllerName(getString(ricJsonObj, CONTROLLER, "")) + .controllerConfig(controllerConfig) .customAdapterClass(getString(ricJsonObj, "customAdapterClass", "")) // .build(); if (!ricConfig.getBaseUrl().isEmpty()) { diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java index ffe853f5..05ba6672 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java @@ -36,7 +36,7 @@ public class RicConfig { private String ricId; @Builder.Default - private String controllerName = ""; + private ControllerConfig controllerConfig = null; private String baseUrl; diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java index f5950c9b..500ddd2a 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java @@ -57,7 +57,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java index ef4ad1c8..f50d5537 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java @@ -68,10 +68,14 @@ class A1ClientFactoryTest { private A1ClientFactory factoryUnderTest; private static RicConfig ricConfig(String controllerName, String customAdapter) { + ControllerConfig controllerConfig = null; + if (!controllerName.isEmpty()) { + controllerConfig = ControllerConfig.builder().baseUrl("baseUrl").name(controllerName).build(); + } return RicConfig.builder() // .ricId(RIC_NAME) // .baseUrl("baseUrl") // - .controllerName(controllerName) // + .controllerConfig(controllerConfig) // .customAdapterClass(customAdapter) // .build(); } @@ -175,12 +179,9 @@ class A1ClientFactoryTest { @DisplayName("test create check types controllers") void create_check_types_controllers() throws ServiceException { this.ric = new Ric(ricConfig("anythingButEmpty")); - whenGetGetControllerConfigReturn(); - whenGetGetControllerConfigReturn(); assertTrue(createClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1) instanceof CcsdkA1AdapterClient); - whenGetGetControllerConfigReturn(); assertTrue(createClient(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1) instanceof CcsdkA1AdapterClient); } @@ -194,14 +195,4 @@ class A1ClientFactoryTest { when(clientMock.getProtocolVersion()).thenReturn(Mono.just(protocol)); } - private void whenGetGetControllerConfigReturn() throws ServiceException { - ControllerConfig controllerCfg = ControllerConfig.builder() // - .name("name") // - .baseUrl("baseUrl") // - .password("pass") // - .userName("user") // - .build(); - when(applicationConfigMock.getControllerConfig(any())).thenReturn(controllerCfg); - } - } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java index b42edb8f..36b591a7 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java @@ -24,26 +24,16 @@ import java.time.Instant; import java.util.Arrays; import java.util.Vector; -import org.json.JSONObject; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy; import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyType; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric; -import reactor.core.publisher.Mono; public class A1ClientHelper { private A1ClientHelper() {} - protected static Mono createOutputJsonResponse(String key, String value) { - JSONObject paramsJson = new JSONObject(); - paramsJson.put(key, value); - JSONObject responseJson = new JSONObject(); - responseJson.put("output", paramsJson); - return Mono.just(responseJson.toString()); - } - - protected static Ric createRic(String url) { + private static Ric createRic(String url) { RicConfig cfg = RicConfig.builder().ricId("ric") // .baseUrl(url) // .managedElementIds(new Vector(Arrays.asList("kista_1", "kista_2"))) // @@ -51,7 +41,7 @@ public class A1ClientHelper { return new Ric(cfg); } - protected static Policy createPolicy(String nearRtRicUrl, String policyId, String json, String type) { + public static Policy createPolicy(String nearRtRicUrl, String policyId, String json, String type) { String callbackUrl = "https://test.com"; return Policy.builder() // .id(policyId) // @@ -65,14 +55,7 @@ public class A1ClientHelper { .build(); } - protected static PolicyType createPolicyType(String name) { + public static PolicyType createPolicyType(String name) { return PolicyType.builder().id(name).schema("schema").build(); } - - protected static String getCreateSchema(String policyType, String policyTypeId) { - JSONObject obj = new JSONObject(policyType); - JSONObject schemaObj = obj.getJSONObject("create_schema"); - schemaObj.put("title", policyTypeId); - return schemaObj.toString(); - } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java index 9bd10f3a..e6c8dfe8 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java @@ -35,6 +35,7 @@ import java.net.URL; import java.nio.file.Files; import java.util.Arrays; import java.util.List; +import java.util.Vector; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -46,7 +47,9 @@ import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client.A1Protocol import org.onap.ccsdk.oran.a1policymanagementservice.clients.CcsdkA1AdapterClient.AdapterOutput; import org.onap.ccsdk.oran.a1policymanagementservice.clients.CcsdkA1AdapterClient.AdapterRequest; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ControllerConfig; +import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy; +import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric; import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.WebClientResponseException; @@ -85,7 +88,7 @@ class CcsdkA1AdapterClientTest { void createClientWithWrongProtocol_thenErrorIsThrown() { AsyncRestClient asyncRestClient = new AsyncRestClient("", null, null, new SecurityContext("")); assertThrows(IllegalArgumentException.class, () -> { - new CcsdkA1AdapterClient(A1ProtocolType.STD_V1_1, null, null, asyncRestClient); + new CcsdkA1AdapterClient(A1ProtocolType.STD_V1_1, null, asyncRestClient); }); } @@ -93,17 +96,26 @@ class CcsdkA1AdapterClientTest { @DisplayName("test get Policy Type Identities STD V1") void getPolicyTypeIdentities_STD_V1() { clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); List policyTypeIds = clientUnderTest.getPolicyTypeIdentities().block(); assertEquals(1, policyTypeIds.size(), "should hardcoded to one"); assertEquals("", policyTypeIds.get(0), "should hardcoded to empty"); } + private Ric createRic(String url) { + RicConfig cfg = RicConfig.builder().ricId("ric") // + .baseUrl(url) // + .managedElementIds(new Vector(Arrays.asList("kista_1", "kista_2"))) // + .controllerConfig(controllerConfig()) // + .build(); + return new Ric(cfg); + } + private void testGetPolicyTypeIdentities(A1ProtocolType protocolType, String expUrl) { clientUnderTest = new CcsdkA1AdapterClient(protocolType, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); String response = createOkResponseWithBody(Arrays.asList(POLICY_TYPE_1_ID)); whenAsyncPostThenReturn(Mono.just(response)); @@ -137,8 +149,8 @@ class CcsdkA1AdapterClientTest { void getTypeSchema_STD_V1() { clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); String policyType = clientUnderTest.getPolicyTypeSchema("").block(); @@ -148,8 +160,8 @@ class CcsdkA1AdapterClientTest { private void testGetTypeSchema(A1ProtocolType protocolType, String expUrl, String policyTypeId, String getSchemaResponseFile) throws IOException { clientUnderTest = new CcsdkA1AdapterClient(protocolType, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); String ricResponse = loadFile(getSchemaResponseFile); JsonElement elem = gson().fromJson(ricResponse, JsonElement.class); @@ -200,8 +212,8 @@ class CcsdkA1AdapterClientTest { private void getPolicyIdentities(A1ProtocolType protocolType, String... expUrls) { clientUnderTest = new CcsdkA1AdapterClient(protocolType, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); String resp = createOkResponseWithBody(Arrays.asList("xxx")); whenAsyncPostThenReturn(Mono.just(resp)); @@ -242,8 +254,8 @@ class CcsdkA1AdapterClientTest { private void putPolicy(A1ProtocolType protocolType, String expUrl) { clientUnderTest = new CcsdkA1AdapterClient(protocolType, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); whenPostReturnOkResponse(); @@ -285,8 +297,8 @@ class CcsdkA1AdapterClientTest { @DisplayName("test post Rejected") void postRejected() { clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); final String policyJson = "{}"; AdapterOutput adapterOutput = new AdapterOutput(HttpStatus.BAD_REQUEST.value(), "NOK"); @@ -308,8 +320,8 @@ class CcsdkA1AdapterClientTest { private void deleteAllPolicies(A1ProtocolType protocolType, String expUrl) { clientUnderTest = new CcsdkA1AdapterClient(protocolType, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); String resp = createOkResponseWithBody(Arrays.asList("xxx")); whenAsyncPostThenReturn(Mono.just(resp)); @@ -347,8 +359,8 @@ class CcsdkA1AdapterClientTest { @DisplayName("test get Version OSC") void getVersion_OSC() { clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, // Version irrelevant here - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); whenAsyncPostThenReturn(Mono.error(new Exception("Error"))).thenReturn(Mono.just(createOkResponseString(true))); @@ -361,8 +373,8 @@ class CcsdkA1AdapterClientTest { @DisplayName("test Get Status") void testGetStatus() { clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, // - A1ClientHelper.createRic(RIC_1_URL).getConfig(), // - controllerConfig(), asyncRestClientMock); + createRic(RIC_1_URL).getConfig(), // + asyncRestClientMock); whenPostReturnOkResponse(); Policy policy = A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java index c376d90f..2f2cce02 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java @@ -30,6 +30,7 @@ import java.util.Arrays; import java.util.List; import org.json.JSONException; +import org.json.JSONObject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -112,8 +113,8 @@ class OscA1ClientTest { Mono returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID); verify(asyncRestClientMock).get(POLICYTYPES_URL + POLICY_TYPE_1_ID); - StepVerifier.create(returnedMono).expectNext(A1ClientHelper.getCreateSchema(policyType, POLICY_TYPE_1_ID)) - .expectComplete().verify(); + StepVerifier.create(returnedMono).expectNext(getCreateSchema(policyType, POLICY_TYPE_1_ID)).expectComplete() + .verify(); } @Test @@ -182,4 +183,11 @@ class OscA1ClientTest { verify(asyncRestClientMock).get(POLICYTYPES_URL + POLICY_TYPE_2_ID + POLICIES); verify(asyncRestClientMock).delete(POLICYTYPES_URL + POLICY_TYPE_2_ID + POLICIES + "/" + POLICY_2_ID); } + + private String getCreateSchema(String policyType, String policyTypeId) { + JSONObject obj = new JSONObject(policyType); + JSONObject schemaObj = obj.getJSONObject("create_schema"); + schemaObj.put("title", policyTypeId); + return schemaObj.toString(); + } } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java index 9696aabc..922d139d 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java @@ -48,8 +48,7 @@ class MetersTest { private static final PolicyType POLICY_TYPE_1 = PolicyType.builder().id(POLICY_TYPE_1_NAME).schema("").build(); private static final Ric RIC_1 = new Ric(RicConfig.builder().ricId("ric_1").baseUrl("baseUrl1") - .managedElementIds(new Vector(Arrays.asList("kista_1", "kista_2"))).controllerName("controllerName") - .build()); + .managedElementIds(new Vector(Arrays.asList("kista_1", "kista_2"))).build()); private static final String POLICY_1_ID = "policyId1"; private static final Policy POLICY_1 = Policy.builder().id(POLICY_1_ID).json("").ownerServiceId("service") diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java index 1b41ce08..77464300 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java @@ -70,7 +70,6 @@ class RicSupervisionTest { .ricId("ric_1") // .baseUrl("baseUrl1") // .managedElementIds(new Vector(Arrays.asList("kista_1", "kista_2"))) // - .controllerName("controllerName") // .build()); private static final String POLICY_1_ID = "policyId1"; diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java index c2f419fb..1a6f1904 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java @@ -112,7 +112,6 @@ class RicSynchronizationTaskTest { ric1 = new Ric(RicConfig.builder() // .ricId(RIC_1_NAME) // .baseUrl("baseUrl1") // - .controllerName("controllerName") // .build()); policy1 = createPolicy("policyId1", false); policyTypes = new PolicyTypes(appConfig); -- cgit 1.2.3-korg