summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src
diff options
context:
space:
mode:
authorecaiyanlinux <martin.c.yan@est.tech>2020-10-27 20:40:57 +0100
committerecaiyanlinux <martin.c.yan@est.tech>2020-10-28 12:32:16 +0100
commit988f2af648a069ae86a4d9fc9499b80716ca8443 (patch)
treedc956a54fc74969362b3b76e8c411a55b91d932d /a1-policy-management/src
parentc655306c67fd9ed6b95d6b111f7bedab79c02f44 (diff)
Remove code for sdnc onap controller
sdnc onap controller is dismissed rename SdncOscA1Client to CcsdkA1AdapterClient rename SdncJsonHelper to A1AdapterJsonHelper update comments accordingly Signed-off-by: ecaiyanlinux <martin.c.yan@est.tech> Issue-ID: CCSDK-2502 Change-Id: If525dab599f9fd28203e85dcd57c010c67e20a8b
Diffstat (limited to 'a1-policy-management/src')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1AdapterJsonHelper.java (renamed from a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java)6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1Client.java7
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java11
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java (renamed from a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java)64
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java4
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java194
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java4
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java5
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java (renamed from a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java)80
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java271
11 files changed, 89 insertions, 559 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1AdapterJsonHelper.java
index ada35fd6..c72f196a 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1AdapterJsonHelper.java
@@ -40,17 +40,17 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
- * Common json functionality used by the SDNC clients
+ * Common json functionality used by the CCSDK A1 Adapter clients
*/
@SuppressWarnings("java:S1192") // Same text in several traces
-class SdncJsonHelper {
+class A1AdapterJsonHelper {
private static Gson gson = new GsonBuilder() //
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) //
.create();
private static final String OUTPUT = "output";
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private SdncJsonHelper() {}
+ private A1AdapterJsonHelper() {}
public static Flux<String> parseJsonArrayOfString(String inputString) {
try {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1Client.java
index 4321ed48..5e498e4b 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1Client.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1Client.java
@@ -38,10 +38,9 @@ public interface A1Client {
STD_V1_1, // STD A1 version 1.1
STD_V2_0_0, // STD A1 version 2.0.0
OSC_V1, // OSC 'A1'
- SDNC_OSC_STD_V1_1, // SDNC_OSC with STD A1 version 1.1 southbound
- SDNC_OSC_STD_V2_0_0, // SDNC_OSC with STD A1 version 2.0.0 southbound
- SDNC_OSC_OSC_V1, // SDNC_OSC with OSC 'A1' southbound
- SDNC_ONAP
+ CCSDK_A1_ADAPTER_STD_V1_1, // CCSDK_A1_ADAPTER with STD A1 version 1.1 southbound
+ CCSDK_A1_ADAPTER_STD_V2_0_0, // CCSDK_A1_ADAPTER with STD A1 version 2.0.0 southbound
+ CCSDK_A1_ADAPTER_OSC_V1 // CCSDK_A1_ADAPTER with OSC 'A1' southbound
}
public Mono<A1ProtocolType> getProtocolVersion();
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 66ba60c0..0ca3a45d 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
@@ -79,11 +79,9 @@ public class A1ClientFactory {
} else if (version == A1ProtocolType.OSC_V1) {
assertNoControllerConfig(ric, version);
return new OscA1Client(ric.getConfig(), this.restClientFactory);
- } else if (version == A1ProtocolType.SDNC_OSC_STD_V1_1 || version == A1ProtocolType.SDNC_OSC_OSC_V1
- || version == A1ProtocolType.SDNC_OSC_STD_V2_0_0) {
- return new SdncOscA1Client(version, ric.getConfig(), getControllerConfig(ric), this.restClientFactory);
- } else if (version == A1ProtocolType.SDNC_ONAP) {
- return new SdncOnapA1Client(ric.getConfig(), getControllerConfig(ric), this.restClientFactory);
+ } 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);
} else {
logger.error("Unhandled protocol: {}", version);
throw new ServiceException("Unhandled protocol");
@@ -125,8 +123,7 @@ public class A1ClientFactory {
return fetchVersion(ric, A1ProtocolType.STD_V2_0_0) //
.onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.STD_V1_1)) //
.onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.OSC_V1)) //
- .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_OSC_STD_V1_1)) //
- .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) //
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1)) //
.doOnNext(ric::setProtocolVersion)
.doOnNext(version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version,
ric.id())) //
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java
index 88859d37..3b581b63 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java
@@ -43,10 +43,10 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
- * Client for accessing the A1 adapter in the SDNC controller in OSC.
+ * Client for accessing the A1 adapter in the CCSDK in ONAP.
*/
@SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
-public class SdncOscA1Client implements A1Client {
+public class CcsdkA1AdapterClient implements A1Client {
static final int CONCURRENCY_RIC = 1; // How many paralell requests that is sent to one NearRT RIC
@@ -81,15 +81,15 @@ public class SdncOscA1Client implements A1Client {
* Constructor that creates the REST client to use.
*
* @param protocolType the southbound protocol of the controller. Supported
- * protocols are SDNC_OSC_STD_V1_1, SDNC_OSC_OSC_V1 and
- * SDNC_OSC_STD_V2_0_0 with
+ * protocols are CCSDK_A1_ADAPTER_STD_V1_1, CCSDK_A1_ADAPTER_OSC_V1 and
+ * CCSDK_A1_ADAPTER_STD_V2_0_0 with
* @param ricConfig the configuration of the Near-RT RIC to communicate
* with
- * @param controllerConfig the configuration of the SDNC controller to use
+ * @param controllerConfig the configuration of the CCSDK A1 Adapter to use
*
* @throws IllegalArgumentException when the protocolType is wrong.
*/
- public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
+ public CcsdkA1AdapterClient(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
AsyncRestClientFactory restClientFactory) {
this(protocolType, ricConfig, controllerConfig,
restClientFactory.createRestClient(controllerConfig.baseUrl() + "/restconf/operations"));
@@ -99,25 +99,25 @@ public class SdncOscA1Client implements A1Client {
* Constructor where the REST client to use is provided.
*
* @param protocolType the southbound protocol of the controller. Supported
- * protocols are SDNC_OSC_STD_V1_1, SDNC_OSC_OSC_V1 and
- * SDNC_OSC_STD_V2_0_0 with
+ * protocols are CCSDK_A1_ADAPTER_STD_V1_1, CCSDK_A1_ADAPTER_OSC_V1 and
+ * CCSDK_A1_ADAPTER_STD_V2_0_0 with
* @param ricConfig the configuration of the Near-RT RIC to communicate
* with
- * @param controllerConfig the configuration of the SDNC controller to use
+ * @param controllerConfig the configuration of the CCSDK A1 Adapter to use
* @param restClient the REST client to use
*
* @throws IllegalArgumentException when the protocolType is illegal.
*/
- public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
+ public CcsdkA1AdapterClient(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
AsyncRestClient restClient) {
- if (A1ProtocolType.SDNC_OSC_STD_V1_1.equals(protocolType) //
- || A1ProtocolType.SDNC_OSC_OSC_V1.equals(protocolType) //
- || A1ProtocolType.SDNC_OSC_STD_V2_0_0.equals(protocolType)) {
+ 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("SdncOscA1Client for ric: {}, a1Controller: {}", ricConfig.ricId(), controllerConfig);
+ logger.debug("CcsdkA1AdapterClient for ric: {}, a1Controller: {}", ricConfig.ricId(), controllerConfig);
} else {
throw new IllegalArgumentException("Not handeled protocolversion: " + protocolType);
}
@@ -126,11 +126,11 @@ public class SdncOscA1Client implements A1Client {
@Override
public Mono<List<String>> getPolicyTypeIdentities() {
- if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
+ if (this.protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1) {
return Mono.just(Arrays.asList(""));
} else {
return post(GET_POLICY_RPC, getUriBuilder().createPolicyTypesUri(), Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString) //
+ .flatMapMany(A1AdapterJsonHelper::parseJsonArrayOfString) //
.collectList();
}
@@ -144,7 +144,7 @@ public class SdncOscA1Client implements A1Client {
@Override
public Mono<String> getPolicyTypeSchema(String policyTypeId) {
- if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
+ if (this.protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1) {
return Mono.just("{}");
} else {
A1UriBuilder uri = this.getUriBuilder();
@@ -155,9 +155,9 @@ public class SdncOscA1Client implements A1Client {
}
private Mono<String> extractCreateSchema(String controllerResponse, String policyTypeId) {
- if (this.protocolType == A1ProtocolType.SDNC_OSC_OSC_V1) {
+ if (this.protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1) {
return OscA1Client.extractCreateSchema(controllerResponse, policyTypeId);
- } else if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V2_0_0) {
+ } else if (this.protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0) {
return StdA1ClientVersion2.extractPolicySchema(controllerResponse, policyTypeId);
} else {
throw new NullPointerException("Not supported");
@@ -178,7 +178,7 @@ public class SdncOscA1Client implements A1Client {
@Override
public Flux<String> deleteAllPolicies() {
- if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
+ if (this.protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1) {
return getPolicyIds() //
.flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); //
} else {
@@ -191,7 +191,7 @@ public class SdncOscA1Client implements A1Client {
private Flux<String> getInstancesForType(A1UriBuilder uriBuilder, String type) {
return post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(type), Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(A1AdapterJsonHelper::parseJsonArrayOfString);
}
private Flux<String> deleteAllInstancesForType(A1UriBuilder uriBuilder, String type) {
@@ -214,11 +214,11 @@ public class SdncOscA1Client implements A1Client {
}
private A1UriBuilder getUriBuilder() {
- if (protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
+ if (protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1) {
return new StdA1ClientVersion1.UriBuilder(ricConfig);
- } else if (protocolType == A1ProtocolType.SDNC_OSC_STD_V2_0_0) {
+ } else if (protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0) {
return new StdA1ClientVersion2.OranV2UriBuilder(ricConfig);
- } else if (protocolType == A1ProtocolType.SDNC_OSC_OSC_V1) {
+ } else if (protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1) {
return new OscA1Client.UriBuilder(ricConfig);
}
throw new NullPointerException();
@@ -227,33 +227,33 @@ public class SdncOscA1Client implements A1Client {
private Mono<A1ProtocolType> tryOscProtocolVersion() {
OscA1Client.UriBuilder oscApiuriBuilder = new OscA1Client.UriBuilder(ricConfig);
return post(GET_POLICY_RPC, oscApiuriBuilder.createHealtcheckUri(), Optional.empty()) //
- .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_OSC_V1));
+ .flatMap(x -> Mono.just(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1));
}
private Mono<A1ProtocolType> tryStdProtocolVersion1() {
StdA1ClientVersion1.UriBuilder uriBuilder = new StdA1ClientVersion1.UriBuilder(ricConfig);
return post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(""), Optional.empty()) //
- .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_STD_V1_1));
+ .flatMap(x -> Mono.just(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1));
}
private Mono<A1ProtocolType> tryStdProtocolVersion2() {
StdA1ClientVersion2.OranV2UriBuilder uriBuilder = new StdA1ClientVersion2.OranV2UriBuilder(ricConfig);
return post(GET_POLICY_RPC, uriBuilder.createPolicyTypesUri(), Optional.empty()) //
- .flatMap(x -> Mono.just(A1ProtocolType.SDNC_OSC_STD_V2_0_0));
+ .flatMap(x -> Mono.just(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0));
}
private Flux<String> getPolicyIds() {
- if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
+ if (this.protocolType == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1) {
StdA1ClientVersion1.UriBuilder uri = new StdA1ClientVersion1.UriBuilder(ricConfig);
final String ricUrl = uri.createGetPolicyIdsUri("");
return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(A1AdapterJsonHelper::parseJsonArrayOfString);
} else {
A1UriBuilder uri = this.getUriBuilder();
return getPolicyTypeIdentities() //
.flatMapMany(Flux::fromIterable)
.flatMap(type -> post(GET_POLICY_RPC, uri.createGetPolicyIdsUri(type), Optional.empty())) //
- .flatMap(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMap(A1AdapterJsonHelper::parseJsonArrayOfString);
}
}
@@ -267,7 +267,7 @@ public class SdncOscA1Client implements A1Client {
.nearRtRicUrl(ricUrl) //
.body(body) //
.build();
- final String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
+ final String inputJsonString = A1AdapterJsonHelper.createInputJsonString(inputParams);
logger.debug("POST inputJsonString = {}", inputJsonString);
return restClient
@@ -294,7 +294,7 @@ public class SdncOscA1Client implements A1Client {
}
private Mono<String> extractResponseBody(String responseStr) {
- return SdncJsonHelper.getOutput(responseStr) //
+ return A1AdapterJsonHelper.getOutput(responseStr) //
.flatMap(this::extractResponse);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
index f54dc2e0..402a73b4 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
@@ -195,12 +195,12 @@ public class OscA1Client implements A1Client {
private Flux<String> getPolicyTypeIds() {
return restClient.get(uri.createPolicyTypesUri()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(A1AdapterJsonHelper::parseJsonArrayOfString);
}
private Flux<String> getPolicyIdentitiesByType(String typeId) {
return restClient.get(uri.createGetPolicyIdsUri(typeId)) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(A1AdapterJsonHelper::parseJsonArrayOfString);
}
private Mono<String> deletePolicyById(String typeId, String policyId) {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java
deleted file mode 100644
index 68b0ab18..00000000
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- */
-
-package org.onap.ccsdk.oran.a1policymanagementservice.clients;
-
-import java.lang.invoke.MethodHandles;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-/**
- * Client for accessing the A1 adapter in the SDNC controller in ONAP
- */
-@SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
-public class SdncOnapA1Client implements A1Client {
- @Value.Immutable
- @Gson.TypeAdapters
- interface SdncOnapAdapterInput {
- public String nearRtRicId();
-
- public Optional<String> policyTypeId();
-
- public Optional<String> policyInstanceId();
-
- public Optional<String> policyInstance();
-
- public Optional<List<String>> properties();
- }
-
- private static final String URL_PREFIX = "/A1-ADAPTER-API:";
-
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- private final ControllerConfig controllerConfig;
- private final RicConfig ricConfig;
- private final AsyncRestClient restClient;
-
- public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig,
- AsyncRestClientFactory restClientFactory) {
- this(ricConfig, controllerConfig,
- restClientFactory.createRestClient(controllerConfig.baseUrl() + "/restconf/operations"));
- logger.debug("SdncOnapA1Client for ric: {}, a1ControllerBaseUrl: {}", ricConfig.ricId(),
- controllerConfig.baseUrl());
- }
-
- public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig, AsyncRestClient restClient) {
- this.ricConfig = ricConfig;
- this.controllerConfig = controllerConfig;
- this.restClient = restClient;
- }
-
- @Override
- public Mono<List<String>> getPolicyTypeIdentities() {
- return getPolicyTypeIds() //
- .collectList();
- }
-
- @Override
- public Mono<List<String>> getPolicyIdentities() {
- return getPolicyTypeIds() //
- .flatMap(this::getPolicyIdentitiesByType) //
- .collectList();
- }
-
- @Override
- public Mono<String> getPolicyTypeSchema(String policyTypeId) {
- SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policyTypeId) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
- logger.debug("POST getPolicyType inputJsonString = {}", inputJsonString);
-
- return restClient
- .postWithAuthHeader(URL_PREFIX + "getPolicyType", inputJsonString, controllerConfig.userName(),
- controllerConfig.password()) //
- .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type")) //
- .flatMap(SdncJsonHelper::extractPolicySchema);
- }
-
- @Override
- public Mono<String> putPolicy(Policy policy) {
- SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policy.type().id()) //
- .policyInstanceId(policy.id()) //
- .policyInstance(policy.json()) //
- .properties(new ArrayList<>()) //
- .build();
-
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
- logger.debug("POST putPolicy inputJsonString = {}", inputJsonString);
-
- return restClient.postWithAuthHeader(URL_PREFIX + "createPolicyInstance", inputJsonString,
- controllerConfig.userName(), controllerConfig.password());
- }
-
- @Override
- public Mono<String> deletePolicy(Policy policy) {
- return deletePolicyByTypeId(policy.type().id(), policy.id());
- }
-
- @Override
- public Flux<String> deleteAllPolicies() {
- return getPolicyTypeIds() //
- .flatMap(this::deletePoliciesForType); //
- }
-
- @Override
- public Mono<A1ProtocolType> getProtocolVersion() {
- return getPolicyTypeIdentities() //
- .flatMap(notUsed -> Mono.just(A1ProtocolType.SDNC_ONAP));
- }
-
- @Override
- public Mono<String> getPolicyStatus(Policy policy) {
- return Mono.error(new Exception("Status not implemented in the controller"));
- }
-
- private Flux<String> getPolicyTypeIds() {
- SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
- logger.debug("POST getPolicyTypeIdentities inputJsonString = {}", inputJsonString);
-
- return restClient
- .postWithAuthHeader(URL_PREFIX + "getPolicyTypes", inputJsonString, controllerConfig.userName(),
- controllerConfig.password()) //
- .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-type-id-list")) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
- }
-
- private Flux<String> getPolicyIdentitiesByType(String policyTypeId) {
- SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policyTypeId) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
- logger.debug("POST getPolicyIdentities inputJsonString = {}", inputJsonString);
-
- return restClient
- .postWithAuthHeader(URL_PREFIX + "getPolicyInstances", inputJsonString, controllerConfig.userName(),
- controllerConfig.password()) //
- .flatMap(response -> SdncJsonHelper.getValueFromResponse(response, "policy-instance-id-list")) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
- }
-
- private Flux<String> deletePoliciesForType(String typeId) {
- return getPolicyIdentitiesByType(typeId) //
- .flatMap(policyId -> deletePolicyByTypeId(typeId, policyId)); //
- }
-
- private Mono<String> deletePolicyByTypeId(String policyTypeId, String policyId) {
- SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policyTypeId) //
- .policyInstanceId(policyId) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
- logger.debug("POST deletePolicy inputJsonString = {}", inputJsonString);
-
- return restClient.postWithAuthHeader(URL_PREFIX + "deletePolicyInstance", inputJsonString,
- controllerConfig.userName(), controllerConfig.password());
- }
-}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
index a1c5ac7a..ba18afea 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
@@ -151,7 +151,7 @@ public class StdA1ClientVersion1 implements A1Client {
private Flux<String> getPolicyIds() {
return restClient.get(uri.createGetPolicyIdsUri("")) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(A1AdapterJsonHelper::parseJsonArrayOfString);
}
private Mono<String> deletePolicyById(String policyId) {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
index cdf35954..471b3c4d 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
@@ -200,12 +200,12 @@ public class StdA1ClientVersion2 implements A1Client {
private Flux<String> getPolicyTypeIds() {
return restClient.get(uriBuiler.createPolicyTypesUri()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(A1AdapterJsonHelper::parseJsonArrayOfString);
}
private Flux<String> getPolicyIdentitiesByType(String typeId) {
return restClient.get(uriBuiler.createGetPolicyIdsUri(typeId)) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(A1AdapterJsonHelper::parseJsonArrayOfString);
}
private Mono<String> deletePolicyById(String typeId, String policyId) {
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 89adf68a..3ca35430 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
@@ -135,13 +135,12 @@ class A1ClientFactoryTest {
void create_check_types_controllers() throws ServiceException {
this.ric = new Ric(ricConfig("anythingButEmpty"));
whenGetGetControllerConfigReturn();
- assertTrue(createClient(A1ProtocolType.SDNC_ONAP) instanceof SdncOnapA1Client);
whenGetGetControllerConfigReturn();
- assertTrue(createClient(A1ProtocolType.SDNC_OSC_STD_V1_1) instanceof SdncOscA1Client);
+ assertTrue(createClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1) instanceof CcsdkA1AdapterClient);
whenGetGetControllerConfigReturn();
- assertTrue(createClient(A1ProtocolType.SDNC_OSC_OSC_V1) instanceof SdncOscA1Client);
+ assertTrue(createClient(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1) instanceof CcsdkA1AdapterClient);
}
private void whenGetProtocolVersionThrowException(A1Client... clientMocks) {
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java
index 4eca44d4..87615f68 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClientTest.java
@@ -44,8 +44,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.OngoingStubbing;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client.A1ProtocolType;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.ImmutableAdapterOutput.Builder;
-import org.onap.ccsdk.oran.a1policymanagementservice.clients.SdncOscA1Client.AdapterOutput;
-import org.onap.ccsdk.oran.a1policymanagementservice.clients.SdncOscA1Client.AdapterRequest;
+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.ImmutableControllerConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy;
@@ -56,7 +56,7 @@ import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@ExtendWith(MockitoExtension.class)
-class SdncOscA1ClientTest {
+class CcsdkA1AdapterClientTest {
private static final String CONTROLLER_USERNAME = "username";
private static final String CONTROLLER_PASSWORD = "password";
private static final String RIC_1_URL = "RicUrl";
@@ -68,7 +68,7 @@ class SdncOscA1ClientTest {
private static final String POLICY_1_ID = "policy1";
private static final String POLICY_JSON_VALID = "{\"scope\":{\"ueId\":\"ue1\"}}";
- SdncOscA1Client clientUnderTest;
+ CcsdkA1AdapterClient clientUnderTest;
@Mock
AsyncRestClient asyncRestClientMock;
@@ -85,13 +85,13 @@ class SdncOscA1ClientTest {
@Test
void createClientWithWrongProtocol_thenErrorIsThrown() {
assertThrows(IllegalArgumentException.class, () -> {
- new SdncOscA1Client(A1ProtocolType.STD_V1_1, null, null, new AsyncRestClient("", null));
+ new CcsdkA1AdapterClient(A1ProtocolType.STD_V1_1, null, null, new AsyncRestClient("", null));
});
}
@Test
void getPolicyTypeIdentities_STD_V1() {
- clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, //
+ clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
List<String> policyTypeIds = clientUnderTest.getPolicyTypeIdentities().block();
@@ -100,7 +100,7 @@ class SdncOscA1ClientTest {
}
private void testGetPolicyTypeIdentities(A1ProtocolType protocolType, String expUrl) {
- clientUnderTest = new SdncOscA1Client(protocolType, //
+ clientUnderTest = new CcsdkA1AdapterClient(protocolType, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
@@ -115,25 +115,25 @@ class SdncOscA1ClientTest {
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
- String expInput = SdncJsonHelper.createInputJsonString(expectedParams);
+ String expInput = A1AdapterJsonHelper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
}
@Test
void getPolicyTypeIdentities_OSC() {
- testGetPolicyTypeIdentities(A1ProtocolType.SDNC_OSC_OSC_V1, RIC_1_URL + "/a1-p/policytypes");
+ testGetPolicyTypeIdentities(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, RIC_1_URL + "/a1-p/policytypes");
}
@Test
void getPolicyTypeIdentities_STD_V2() {
- testGetPolicyTypeIdentities(A1ProtocolType.SDNC_OSC_STD_V2_0_0, RIC_1_URL + "/A1-P/v2/policytypes");
+ testGetPolicyTypeIdentities(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, RIC_1_URL + "/A1-P/v2/policytypes");
}
@Test
void getTypeSchema_STD_V1() {
- clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, //
+ clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
@@ -144,7 +144,7 @@ class SdncOscA1ClientTest {
private void testGetTypeSchema(A1ProtocolType protocolType, String expUrl, String policyTypeId,
String getSchemaResponseFile) throws IOException {
- clientUnderTest = new SdncOscA1Client(protocolType, //
+ clientUnderTest = new CcsdkA1AdapterClient(protocolType, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
@@ -162,7 +162,7 @@ class SdncOscA1ClientTest {
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
- String expInput = SdncJsonHelper.createInputJsonString(expectedParams);
+ String expInput = A1AdapterJsonHelper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
@@ -171,13 +171,13 @@ class SdncOscA1ClientTest {
@Test
void getTypeSchema_OSC() throws IOException {
String expUrl = RIC_1_URL + "/a1-p/policytypes/policyTypeId";
- testGetTypeSchema(A1ProtocolType.SDNC_OSC_OSC_V1, expUrl, "policyTypeId", "test_osc_get_schema_response.json");
+ testGetTypeSchema(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrl, "policyTypeId", "test_osc_get_schema_response.json");
}
@Test
void getTypeSchema_STD_V2() throws IOException {
String expUrl = RIC_1_URL + "/A1-P/v2/policytypes/policyTypeId";
- testGetTypeSchema(A1ProtocolType.SDNC_OSC_STD_V2_0_0, expUrl, "policyTypeId",
+ testGetTypeSchema(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, expUrl, "policyTypeId",
"test_oran_get_schema_response.json");
}
@@ -186,14 +186,14 @@ class SdncOscA1ClientTest {
// One integer and one string
String inputString = "[1, \"1\" ]";
- List<String> result = SdncJsonHelper.parseJsonArrayOfString(inputString).collectList().block();
+ List<String> result = A1AdapterJsonHelper.parseJsonArrayOfString(inputString).collectList().block();
assertEquals(2, result.size());
assertEquals("1", result.get(0));
assertEquals("1", result.get(1));
}
private void getPolicyIdentities(A1ProtocolType protocolType, String... expUrls) {
- clientUnderTest = new SdncOscA1Client(protocolType, //
+ clientUnderTest = new CcsdkA1AdapterClient(protocolType, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
String resp = createOkResponseWithBody(Arrays.asList("xxx"));
@@ -206,7 +206,7 @@ class SdncOscA1ClientTest {
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
- String expInput = SdncJsonHelper.createInputJsonString(expectedParams);
+ String expInput = A1AdapterJsonHelper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
}
@@ -215,25 +215,25 @@ class SdncOscA1ClientTest {
@Test
void getPolicyIdentities_STD_V1() {
String expUrl = RIC_1_URL + "/A1-P/v1/policies";
- getPolicyIdentities(A1ProtocolType.SDNC_OSC_STD_V1_1, expUrl);
+ getPolicyIdentities(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, expUrl);
}
@Test
void getPolicyIdentities_STD_V2() {
String expUrlPolicies = RIC_1_URL + "/A1-P/v2/policytypes";
String expUrlInstances = RIC_1_URL + "/A1-P/v2/policytypes/xxx/policies";
- getPolicyIdentities(A1ProtocolType.SDNC_OSC_STD_V2_0_0, expUrlPolicies, expUrlInstances);
+ getPolicyIdentities(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, expUrlPolicies, expUrlInstances);
}
@Test
void getPolicyIdentities_OSC() {
String expUrlTypes = RIC_1_URL + "/a1-p/policytypes";
String expUrlInstances = RIC_1_URL + "/a1-p/policytypes/xxx/policies";
- getPolicyIdentities(A1ProtocolType.SDNC_OSC_OSC_V1, expUrlTypes, expUrlInstances);
+ getPolicyIdentities(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrlTypes, expUrlInstances);
}
private void putPolicy(A1ProtocolType protocolType, String expUrl) {
- clientUnderTest = new SdncOscA1Client(protocolType, //
+ clientUnderTest = new CcsdkA1AdapterClient(protocolType, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
@@ -248,7 +248,7 @@ class SdncOscA1ClientTest {
.nearRtRicUrl(expUrl) //
.body(POLICY_JSON_VALID) //
.build();
- String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams);
+ String expInput = A1AdapterJsonHelper.createInputJsonString(expectedInputParams);
verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expInput, CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
@@ -257,25 +257,25 @@ class SdncOscA1ClientTest {
@Test
void putPolicy_OSC() {
String expUrl = RIC_1_URL + "/a1-p/policytypes/type1/policies/policy1";
- putPolicy(A1ProtocolType.SDNC_OSC_OSC_V1, expUrl);
+ putPolicy(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrl);
}
@Test
void putPolicy_STD_V1() {
String expUrl = RIC_1_URL + "/A1-P/v1/policies/policy1";
- putPolicy(A1ProtocolType.SDNC_OSC_STD_V1_1, expUrl);
+ putPolicy(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, expUrl);
}
@Test
void putPolicy_STD_V2() {
String expUrl =
RIC_1_URL + "/A1-P/v2/policytypes/type1/policies/policy1?notificationDestination=https://test.com";
- putPolicy(A1ProtocolType.SDNC_OSC_STD_V2_0_0, expUrl);
+ putPolicy(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, expUrl);
}
@Test
void postRejected() {
- clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, //
+ clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
@@ -285,7 +285,7 @@ class SdncOscA1ClientTest {
.httpStatus(HttpStatus.BAD_REQUEST.value()) // ERROR
.build();
- String resp = SdncJsonHelper.createOutputJsonString(adapterOutput);
+ String resp = A1AdapterJsonHelper.createOutputJsonString(adapterOutput);
whenAsyncPostThenReturn(Mono.just(resp));
Mono<String> returnedMono = clientUnderTest
@@ -301,7 +301,7 @@ class SdncOscA1ClientTest {
}
private void deleteAllPolicies(A1ProtocolType protocolType, String expUrl) {
- clientUnderTest = new SdncOscA1Client(protocolType, //
+ clientUnderTest = new CcsdkA1AdapterClient(protocolType, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
String resp = createOkResponseWithBody(Arrays.asList("xxx"));
@@ -312,7 +312,7 @@ class SdncOscA1ClientTest {
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
- String expInput = SdncJsonHelper.createInputJsonString(expectedParams);
+ String expInput = A1AdapterJsonHelper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(DELETE_A1_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
}
@@ -320,24 +320,24 @@ class SdncOscA1ClientTest {
@Test
void deleteAllPolicies_STD_V2() {
String expUrl1 = RIC_1_URL + "/A1-P/v2/policytypes/xxx/policies/xxx";
- deleteAllPolicies(A1ProtocolType.SDNC_OSC_STD_V2_0_0, expUrl1);
+ deleteAllPolicies(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, expUrl1);
}
@Test
void deleteAllPolicies_STD_V1() {
String expUrl1 = RIC_1_URL + "/A1-P/v1/policies/xxx";
- deleteAllPolicies(A1ProtocolType.SDNC_OSC_STD_V1_1, expUrl1);
+ deleteAllPolicies(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, expUrl1);
}
@Test
void deleteAllPolicies_OSC() {
String expUrl1 = RIC_1_URL + "/a1-p/policytypes/xxx/policies/xxx";
- deleteAllPolicies(A1ProtocolType.SDNC_OSC_OSC_V1, expUrl1);
+ deleteAllPolicies(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrl1);
}
@Test
void getVersion_OSC() {
- clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, // Version irrelevant here
+ clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, // Version irrelevant here
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
@@ -345,12 +345,12 @@ class SdncOscA1ClientTest {
A1ProtocolType returnedVersion = clientUnderTest.getProtocolVersion().block();
- assertEquals(A1ProtocolType.SDNC_OSC_STD_V1_1, returnedVersion);
+ assertEquals(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, returnedVersion);
}
@Test
void testGetStatus() {
- clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V2_0_0, //
+ clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
controllerConfig(), asyncRestClientMock);
whenPostReturnOkResponse();
@@ -364,14 +364,14 @@ class SdncOscA1ClientTest {
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
- String expInput = SdncJsonHelper.createInputJsonString(expectedParams);
+ String expInput = A1AdapterJsonHelper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_STATUS_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
}
private Gson gson() {
- return SdncOscA1Client.gson;
+ return CcsdkA1AdapterClient.gson;
}
private String loadFile(String fileName) throws IOException {
@@ -394,7 +394,7 @@ class SdncOscA1ClientTest {
.body(gson().toJson(body)) //
.httpStatus(HttpStatus.OK.value()) //
.build();
- return SdncJsonHelper.createOutputJsonString(output);
+ return A1AdapterJsonHelper.createOutputJsonString(output);
}
private String createOkResponseString(boolean withBody) {
@@ -404,7 +404,7 @@ class SdncOscA1ClientTest {
} else {
responseBuilder.body(Optional.empty());
}
- return SdncJsonHelper.createOutputJsonString(responseBuilder.build());
+ return A1AdapterJsonHelper.createOutputJsonString(responseBuilder.build());
}
private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) {
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java
deleted file mode 100644
index c2118c12..00000000
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- */
-
-package org.onap.ccsdk.oran.a1policymanagementservice.clients;
-
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.json.JSONException;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.mockito.stubbing.OngoingStubbing;
-import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ControllerConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ImmutableControllerConfig;
-
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-@ExtendWith(MockitoExtension.class)
-class SdncOnapA1ClientTest {
- private static final String CONTROLLER_USERNAME = "username";
- private static final String CONTROLLER_PASSWORD = "password";
- private static final String RIC_1_URL = "RicUrl";
- private static final String POLICYTYPES_IDENTITIES_URL = "/A1-ADAPTER-API:getPolicyTypes";
- private static final String POLICIES_IDENTITIES_URL = "/A1-ADAPTER-API:getPolicyInstances";
- private static final String POLICYTYPES_URL = "/A1-ADAPTER-API:getPolicyType";
- private static final String PUT_POLICY_URL = "/A1-ADAPTER-API:createPolicyInstance";
- private static final String DELETE_POLICY_URL = "/A1-ADAPTER-API:deletePolicyInstance";
-
- private static final String POLICY_TYPE_1_ID = "type1";
- private static final String POLICY_TYPE_2_ID = "type2";
- private static final String POLICY_TYPE_SCHEMA_VALID = "{\"type\":\"type1\"}";
- private static final String POLICY_TYPE_SCHEMA_INVALID = "\"type\":\"type1\"}";
- private static final String POLICY_1_ID = "policy1";
- private static final String POLICY_2_ID = "policy2";
- private static final String POLICY_JSON_VALID = "{\"scope\":{\"ueId\":\"ue1\"}}";
-
- SdncOnapA1Client clientUnderTest;
-
- AsyncRestClient asyncRestClientMock;
-
- @BeforeEach
- void init() {
- asyncRestClientMock = mock(AsyncRestClient.class);
- ControllerConfig controllerCfg = ImmutableControllerConfig.builder() //
- .name("name") //
- .baseUrl("baseUrl") //
- .password(CONTROLLER_PASSWORD) //
- .userName(CONTROLLER_USERNAME) //
- .build();
-
- clientUnderTest = new SdncOnapA1Client(A1ClientHelper.createRic(RIC_1_URL).getConfig(), controllerCfg,
- asyncRestClientMock);
- }
-
- @Test
- void testGetPolicyTypeIdentities() {
- SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
-
- List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID);
- Mono<String> policyTypeIdsResp =
- A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString());
- whenAsyncPostThenReturn(policyTypeIdsResp);
-
- Mono<List<String>> returnedMono = clientUnderTest.getPolicyTypeIdentities();
- verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonString, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
- StepVerifier.create(returnedMono).expectNext(policyTypeIds).expectComplete().verify();
- }
-
- @Test
- void testGetPolicyIdentities() {
- SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .build();
- String inputJsonStringGetTypeIds = SdncJsonHelper.createInputJsonString(inputParams);
- inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .build();
- String inputJsonStringGetPolicyIdsType1 = SdncJsonHelper.createInputJsonString(inputParams);
- inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_2_ID) //
- .build();
- String inputJsonStringGetPolicyIdsType2 = SdncJsonHelper.createInputJsonString(inputParams);
-
- List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID);
- Mono<String> policyTypeIdsResp =
- A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString());
- List<String> policyIdsType1 = Arrays.asList(POLICY_1_ID);
- Mono<String> policyIdsType1Resp =
- A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString());
- List<String> policyIdsType2 = Arrays.asList(POLICY_2_ID);
- Mono<String> policyIdsType2Resp =
- A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString());
- whenAsyncPostThenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp).thenReturn(policyIdsType2Resp);
-
- Mono<List<String>> returnedMono = clientUnderTest.getPolicyIdentities();
- StepVerifier.create(returnedMono).expectNext(Arrays.asList(POLICY_1_ID, POLICY_2_ID)).expectComplete().verify();
- verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonStringGetTypeIds,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
- verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType1,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
- verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType2,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
- }
-
- @Test
- void testGetValidPolicyType() {
- SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
-
- String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_VALID + ", \"statusSchema\": {} }";
- Mono<String> policyTypeResp = A1ClientHelper.createOutputJsonResponse("policy-type", policyType);
- whenAsyncPostThenReturn(policyTypeResp);
-
- Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID);
- verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_URL, inputJsonString, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
- StepVerifier.create(returnedMono).expectNext(POLICY_TYPE_SCHEMA_VALID).expectComplete().verify();
- }
-
- @Test
- void testGetInvalidPolicyType() {
- SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
-
- String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_INVALID + ", \"statusSchema\": {} }";
- Mono<String> policyTypeResp = A1ClientHelper.createOutputJsonResponse("policy-type", policyType);
- whenAsyncPostThenReturn(policyTypeResp);
-
- Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID);
- verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_URL, inputJsonString, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
- StepVerifier.create(returnedMono).expectErrorMatches(throwable -> throwable instanceof JSONException).verify();
- }
-
- @Test
- void testPutPolicy() {
- SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .policyInstanceId(POLICY_1_ID) //
- .policyInstance(POLICY_JSON_VALID) //
- .properties(new ArrayList<String>()) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
-
- whenAsyncPostThenReturn(Mono.empty());
-
- Mono<String> returnedMono = clientUnderTest
- .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID));
- verify(asyncRestClientMock).postWithAuthHeader(PUT_POLICY_URL, inputJsonString, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
- StepVerifier.create(returnedMono).expectComplete().verify();
- }
-
- @Test
- void testDeletePolicy() {
- SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .policyInstanceId(POLICY_1_ID) //
- .build();
- String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
-
- whenAsyncPostThenReturn(Mono.empty());
-
- Mono<String> returnedMono = clientUnderTest
- .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID));
- verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonString, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
- StepVerifier.create(returnedMono).expectComplete().verify();
- }
-
- @Test
- void testDeleteAllPolicies() {
- SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .build();
- String inputJsonStringGetTypeIds = SdncJsonHelper.createInputJsonString(inputParams);
- inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .build();
- String inputJsonStringGetPolicyIdsType1 = SdncJsonHelper.createInputJsonString(inputParams);
- inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_2_ID) //
- .build();
- String inputJsonStringGetPolicyIdsType2 = SdncJsonHelper.createInputJsonString(inputParams);
- inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .policyInstanceId(POLICY_1_ID) //
- .build();
- String inputJsonStringDeletePolicy1 = SdncJsonHelper.createInputJsonString(inputParams);
- inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_2_ID) //
- .policyInstanceId(POLICY_2_ID) //
- .build();
- String inputJsonStringDeletePolicy2 = SdncJsonHelper.createInputJsonString(inputParams);
-
- List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID);
- Mono<String> policyTypeIdsResp =
- A1ClientHelper.createOutputJsonResponse("policy-type-id-list", policyTypeIds.toString());
- List<String> policyIdsType1 = Arrays.asList(POLICY_1_ID);
- Mono<String> policyIdsType1Resp =
- A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType1.toString());
- List<String> policyIdsType2 = Arrays.asList(POLICY_2_ID);
- Mono<String> policyIdsType2Resp =
- A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString());
- whenAsyncPostThenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp).thenReturn(Mono.empty())
- .thenReturn(policyIdsType2Resp).thenReturn(Mono.empty());
-
- Flux<String> returnedFlux = clientUnderTest.deleteAllPolicies();
- StepVerifier.create(returnedFlux).expectComplete().verify();
- verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_IDENTITIES_URL, inputJsonStringGetTypeIds,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
- verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType1,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
- verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonStringDeletePolicy1,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
- verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType2,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
- verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonStringDeletePolicy2,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
- }
-
- private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) {
- return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString()))
- .thenReturn(response);
- }
-}