diff options
author | PatrikBuhr <patrik.buhr@est.tech> | 2022-05-11 13:10:40 +0200 |
---|---|---|
committer | PatrikBuhr <patrik.buhr@est.tech> | 2022-05-12 09:18:45 +0200 |
commit | 4faa502e6fb2a1d242618ba1513a47eb55d0a530 (patch) | |
tree | a0c3fe4c2cc9ee96163486229be76ba13ae9b410 /a1-policy-management/src/test/java | |
parent | f5f34a552b1559d79a74ae9e3e79686d6b93af70 (diff) |
NONRTRIC PMS added support for custom A1 adapters
Added support for added external A1-P adapter. This makes it possible to design and include
adapter to APIs for accessing of A1 policies (in a NearRT-RIC) without any changes in this
SW.
Issue-ID: CCSDK-3655
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Change-Id: Idc7bf97963a2455bde983b06a5f861df77d901ae
Diffstat (limited to 'a1-policy-management/src/test/java')
10 files changed, 52 insertions, 2 deletions
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 645f2353..499889a6 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 @@ -29,6 +29,7 @@ import static org.mockito.Mockito.when; import java.util.Vector; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -39,6 +40,7 @@ import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationCo import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ControllerConfig; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableControllerConfig; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableRicConfig; +import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig; import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric; @@ -68,21 +70,25 @@ class A1ClientFactoryTest { private Ric ric; private A1ClientFactory factoryUnderTest; - private static ImmutableRicConfig ricConfig(String controllerName) { + private static ImmutableRicConfig ricConfig(String controllerName, String customAdapter) { return ImmutableRicConfig.builder() // .ricId(RIC_NAME) // .baseUrl("baseUrl") // .managedElementIds(new Vector<>()) // .controllerName(controllerName) // + .customAdapterClass(customAdapter) // .build(); } + private static ImmutableRicConfig ricConfig(String controllerName) { + return ricConfig(controllerName, ""); + } + @BeforeEach void createFactoryUnderTest() { SecurityContext sec = new SecurityContext(""); factoryUnderTest = spy(new A1ClientFactory(applicationConfigMock, sec)); this.ric = new Ric(ricConfig("")); - } @Test @@ -109,6 +115,38 @@ class A1ClientFactoryTest { assertEquals(A1ProtocolType.STD_V1_1, ric.getProtocolVersion(), "Not correct protocol"); } + public static class CustomA1AdapterFactory implements A1Client.Factory { + @Override + public A1Client create(RicConfig ricConfig, AsyncRestClientFactory restClientFactory) { + return new StdA1ClientVersion2(ricConfig, restClientFactory); + } + } + + @Test + void testCustomAdapterCreation() { + + Ric ric = new Ric(ricConfig("", CustomA1AdapterFactory.class.getName())); + A1Client client = factoryUnderTest.createA1Client(ric).block(); + + assertEquals(client.getClass(), StdA1ClientVersion2.class); + + ric = new Ric(ricConfig("", "org.onap.ccsdk.oran.a1policymanagementservice.clients.StdA1ClientVersion2")); + client = factoryUnderTest.createA1Client(ric).block(); + + assertEquals(client.getClass(), StdA1ClientVersion2.class); + + ric = new Ric( + ricConfig("", "org.onap.ccsdk.oran.a1policymanagementservice.clients.StdA1ClientVersion2$Factory")); + client = factoryUnderTest.createA1Client(ric).block(); + + assertEquals(client.getClass(), StdA1ClientVersion2.class); + + Exception e = Assertions.assertThrows(Exception.class, () -> { + factoryUnderTest.createClient(new Ric(ricConfig("", "junk")), A1ProtocolType.CUSTOM_PROTOCOL); + }); + assertEquals("Could not find class: junk", e.getMessage()); + } + @Test void getProtocolVersion_error() throws ServiceException { whenGetProtocolVersionThrowException(clientMock1, clientMock2, clientMock3, clientMock4); 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 eb007138..3090f64a 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 @@ -49,6 +49,7 @@ public class A1ClientHelper { .baseUrl(url) // .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // .controllerName("") // + .customAdapterClass("") // .build(); return new Ric(cfg); } 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 6aacc914..13379633 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 @@ -71,6 +71,7 @@ class OscA1ClientTest { .baseUrl("RicBaseUrl") // .managedElementIds(new ArrayList<>()) // .controllerName("") // + .customAdapterClass("") // .build(); asyncRestClientMock = mock(AsyncRestClient.class); clientUnderTest = new OscA1Client(ricConfig, asyncRestClientMock); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientV2Test.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientV2Test.java index de55882b..4b6d17b0 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientV2Test.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientV2Test.java @@ -74,6 +74,7 @@ class StdA1ClientV2Test { .baseUrl(RIC_URL) // .managedElementIds(new ArrayList<>()) // .controllerName("") // + .customAdapterClass("") // .build(); asyncRestClientMock = mock(AsyncRestClient.class); clientUnderTest = new StdA1ClientVersion2(ricConfig, asyncRestClientMock); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java index 7a075428..fd77eb8f 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java @@ -42,6 +42,7 @@ class ApplicationConfigTest { .baseUrl("ric1_url") // .managedElementIds(new Vector<>()) // .controllerName("") // + .customAdapterClass("") // .build(); private static final ImmutableRicConfig RIC_CONFIG_2 = ImmutableRicConfig.builder() // @@ -49,6 +50,7 @@ class ApplicationConfigTest { .baseUrl("ric1_url") // .managedElementIds(new Vector<>()) // .controllerName("") // + .customAdapterClass("") // .build(); private static final ImmutableRicConfig RIC_CONFIG_3 = ImmutableRicConfig.builder() // @@ -56,6 +58,7 @@ class ApplicationConfigTest { .baseUrl("ric1_url") // .managedElementIds(new Vector<>()) // .controllerName("") // + .customAdapterClass("") // .build(); ConfigParserResult configParserResult(RicConfig... rics) { @@ -103,6 +106,7 @@ class ApplicationConfigTest { .baseUrl("changed_ric1_url") // .managedElementIds(new Vector<>()) // .controllerName("") // + .customAdapterClass("") // .build(); update = appConfigUnderTest.setConfiguration(configParserResult(changedRicConfig, RIC_CONFIG_2, RIC_CONFIG_3)) diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java index 569cb577..174add3b 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java @@ -1046,6 +1046,7 @@ class ApplicationTest { .baseUrl(ricId) // .managedElementIds(mes) // .controllerName("") // + .customAdapterClass("") // .build(); } diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java index f09bd05d..fc565305 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java @@ -82,6 +82,7 @@ class RefreshConfigTaskTest { .baseUrl("http://localhost:8080/") // .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // .controllerName("") // + .customAdapterClass("") // .build(); private RefreshConfigTask createTestObject(boolean configFileExists) { 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 b76131df..320d1fb0 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,6 +70,7 @@ class RicSupervisionTest { .baseUrl("baseUrl1") // .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) // .controllerName("controllerName") // + .customAdapterClass("") // .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 a5795ac9..e7e0a561 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 @@ -110,6 +110,7 @@ class RicSynchronizationTaskTest { .baseUrl("baseUrl1") // .managedElementIds(Collections.emptyList()) // .controllerName("controllerName") // + .customAdapterClass("") // .build()); policy1 = createPolicy("policyId1", false); policyTypes = new PolicyTypes(appConfig); diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java index 294b220c..8cdf2cc7 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java @@ -75,6 +75,7 @@ class ServiceSupervisionTest { .baseUrl("baseUrl") // .managedElementIds(Collections.emptyList()) // .controllerName("") // + .customAdapterClass("") // .build(); private Ric ric = new Ric(ricConfig); private PolicyType policyType = PolicyType.builder() // |