summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src
diff options
context:
space:
mode:
Diffstat (limited to 'a1-policy-management/src')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java50
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java26
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java152
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java18
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncJsonHelper.java21
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1Client.java80
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java86
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java8
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java18
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java38
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java191
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java22
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java32
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java12
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java257
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java8
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java44
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java54
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java26
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java31
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java31
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java51
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java30
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java81
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java42
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java21
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactoryTest.java26
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientHelper.java27
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java26
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1ClientTest.java23
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOnapA1ClientTest.java148
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1ClientTest.java106
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java2
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java32
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigTest.java44
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java91
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java101
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java18
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java32
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java92
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java10
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java59
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java134
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervisionTest.java54
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java60
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervisionTest.java42
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java4
60 files changed, 1259 insertions, 1352 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
index a5636592..89058a1c 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
@@ -54,14 +54,14 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
static final String API_TITLE = "A1 Policy management service";
static final String DESCRIPTION = //
- "The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices. \n" //
- + "It provides support for:" //
- + "<ul>" //
- + "<li>A1 Policy creation and modification.</li>" //
- + "<li>Maintaining a view of supported Near-RT RIC policy types </li>" //
- + "<li>Supervision of using services (R-APPs). When a service is unavailble, its policies are removed. </li> " //
- + "<li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs </li>" //
- + "</ul>"//
+ "The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices. \n" //
+ + "It provides support for:" //
+ + "<ul>" //
+ + "<li>A1 Policy creation and modification.</li>" //
+ + "<li>Maintaining a view of supported Near-RT RIC policy types </li>" //
+ + "<li>Supervision of using services (R-APPs). When a service is unavailble, its policies are removed. </li> " //
+ + "<li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs </li>" //
+ + "</ul>"//
;
static final String VERSION = "1.1.0";
@SuppressWarnings("squid:S1075") // Refactor your code to get this URI from a customizable parameter.
@@ -78,25 +78,25 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2) //
- .apiInfo(apiInfo()) //
- .select() //
- .apis(RequestHandlerSelectors.any()) //
- .paths(PathSelectors.any()) //
- .paths(Predicates.not(PathSelectors.regex("/error"))) //
- // this endpoint is not implemented, but was visible for Swagger
- .paths(Predicates.not(PathSelectors.regex("/actuator.*"))) //
- // this endpoint is implemented by spring framework, exclude for now
- .build();
+ .apiInfo(apiInfo()) //
+ .select() //
+ .apis(RequestHandlerSelectors.any()) //
+ .paths(PathSelectors.any()) //
+ .paths(Predicates.not(PathSelectors.regex("/error"))) //
+ // this endpoint is not implemented, but was visible for Swagger
+ .paths(Predicates.not(PathSelectors.regex("/actuator.*"))) //
+ // this endpoint is implemented by spring framework, exclude for now
+ .build();
}
private static ApiInfo apiInfo() {
return new ApiInfoBuilder() //
- .title(API_TITLE) //
- .description(DESCRIPTION) //
- .version(VERSION) //
- .contact(contact()) //
- .extensions(vendorExtentions()) //
- .build();
+ .title(API_TITLE) //
+ .description(DESCRIPTION) //
+ .version(VERSION) //
+ .contact(contact()) //
+ .extensions(vendorExtentions()) //
+ .build();
}
@SuppressWarnings("rawtypes") // VendorExtension is a raw type. References to generic type VendorExtension<T>
@@ -116,10 +116,10 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler(SWAGGER_UI) //
- .addResourceLocations(RESOURCES_PATH);
+ .addResourceLocations(RESOURCES_PATH);
registry.addResourceHandler(WEBJARS) //
- .addResourceLocations(WEBJARS_PATH);
+ .addResourceLocations(WEBJARS_PATH);
}
}
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 31a706b4..cfb01d0b 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
@@ -66,7 +66,7 @@ public class A1ClientFactory {
*/
public Mono<A1Client> createA1Client(Ric ric) {
return getProtocolVersion(ric) //
- .flatMap(version -> createA1ClientMono(ric, version));
+ .flatMap(version -> createA1ClientMono(ric, version));
}
A1Client createClient(Ric ric, A1ProtocolType version) throws ServiceException {
@@ -78,7 +78,7 @@ public class A1ClientFactory {
return new OscA1Client(ric.getConfig(), this.appConfig.getWebClientConfig());
} else if (version == A1ProtocolType.SDNC_OSC_STD_V1_1 || version == A1ProtocolType.SDNC_OSC_OSC_V1) {
return new SdncOscA1Client(version, ric.getConfig(), getControllerConfig(ric),
- this.appConfig.getWebClientConfig());
+ this.appConfig.getWebClientConfig());
} else if (version == A1ProtocolType.SDNC_ONAP) {
return new SdncOnapA1Client(ric.getConfig(), getControllerConfig(ric), this.appConfig.getWebClientConfig());
} else {
@@ -105,7 +105,7 @@ public class A1ClientFactory {
if (!ric.getConfig().controllerName().isEmpty()) {
ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
throw new ServiceException(
- "Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version);
+ "Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version);
}
}
@@ -120,15 +120,15 @@ public class A1ClientFactory {
private Mono<A1Client.A1ProtocolType> getProtocolVersion(Ric ric) {
if (ric.getProtocolVersion() == A1ProtocolType.UNKNOWN) {
return 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)) //
- .doOnNext(ric::setProtocolVersion)
- .doOnNext(
- version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version, ric.id())) //
- .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id())) //
- .onErrorResume(
- notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id())));
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.OSC_V1)) //
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_OSC_STD_V1_1)) //
+ .onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) //
+ .doOnNext(ric::setProtocolVersion)
+ .doOnNext(version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version,
+ ric.id())) //
+ .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id())) //
+ .onErrorResume(
+ notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id())));
} else {
return Mono.just(ric.getProtocolVersion());
}
@@ -136,6 +136,6 @@ public class A1ClientFactory {
private Mono<A1ProtocolType> fetchVersion(Ric ric, A1ProtocolType protocolType) {
return createA1ClientMono(ric, protocolType) //
- .flatMap(A1Client::getProtocolVersion);
+ .flatMap(A1Client::getProtocolVersion);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
index c3de6b2c..c1cea8b5 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
@@ -90,18 +90,18 @@ public class AsyncRestClient {
logger.trace("{} POST body: {}", traceTag, body);
Mono<String> bodyProducer = body != null ? Mono.just(body) : Mono.empty();
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.post() //
- .uri(uri) //
- .contentType(MediaType.APPLICATION_JSON) //
- .body(bodyProducer, String.class);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.post() //
+ .uri(uri) //
+ .contentType(MediaType.APPLICATION_JSON) //
+ .body(bodyProducer, String.class);
+ return retrieve(traceTag, request);
+ });
}
public Mono<String> post(String uri, @Nullable String body) {
return postForEntity(uri, body) //
- .flatMap(this::toBody);
+ .flatMap(this::toBody);
}
public Mono<String> postWithAuthHeader(String uri, String body, String username, String password) {
@@ -109,15 +109,15 @@ public class AsyncRestClient {
logger.debug("{} POST (auth) uri = '{}{}''", traceTag, baseUrl, uri);
logger.trace("{} POST body: {}", traceTag, body);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.post() //
- .uri(uri) //
- .headers(headers -> headers.setBasicAuth(username, password)) //
- .contentType(MediaType.APPLICATION_JSON) //
- .bodyValue(body);
- return retrieve(traceTag, request) //
- .flatMap(this::toBody);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.post() //
+ .uri(uri) //
+ .headers(headers -> headers.setBasicAuth(username, password)) //
+ .contentType(MediaType.APPLICATION_JSON) //
+ .bodyValue(body);
+ return retrieve(traceTag, request) //
+ .flatMap(this::toBody);
+ });
}
public Mono<ResponseEntity<String>> putForEntity(String uri, String body) {
@@ -125,13 +125,13 @@ public class AsyncRestClient {
logger.debug("{} PUT uri = '{}{}''", traceTag, baseUrl, uri);
logger.trace("{} PUT body: {}", traceTag, body);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.put() //
- .uri(uri) //
- .contentType(MediaType.APPLICATION_JSON) //
- .bodyValue(body);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.put() //
+ .uri(uri) //
+ .contentType(MediaType.APPLICATION_JSON) //
+ .bodyValue(body);
+ return retrieve(traceTag, request);
+ });
}
public Mono<ResponseEntity<String>> putForEntity(String uri) {
@@ -139,54 +139,54 @@ public class AsyncRestClient {
logger.debug("{} PUT uri = '{}{}''", traceTag, baseUrl, uri);
logger.trace("{} PUT body: <empty>", traceTag);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.put() //
- .uri(uri);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.put() //
+ .uri(uri);
+ return retrieve(traceTag, request);
+ });
}
public Mono<String> put(String uri, String body) {
return putForEntity(uri, body) //
- .flatMap(this::toBody);
+ .flatMap(this::toBody);
}
public Mono<ResponseEntity<String>> getForEntity(String uri) {
Object traceTag = createTraceTag();
logger.debug("{} GET uri = '{}{}''", traceTag, baseUrl, uri);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.get().uri(uri);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.get().uri(uri);
+ return retrieve(traceTag, request);
+ });
}
public Mono<String> get(String uri) {
return getForEntity(uri) //
- .flatMap(this::toBody);
+ .flatMap(this::toBody);
}
public Mono<ResponseEntity<String>> deleteForEntity(String uri) {
Object traceTag = createTraceTag();
logger.debug("{} DELETE uri = '{}{}''", traceTag, baseUrl, uri);
return getWebClient() //
- .flatMap(client -> {
- RequestHeadersSpec<?> request = client.delete().uri(uri);
- return retrieve(traceTag, request);
- });
+ .flatMap(client -> {
+ RequestHeadersSpec<?> request = client.delete().uri(uri);
+ return retrieve(traceTag, request);
+ });
}
public Mono<String> delete(String uri) {
return deleteForEntity(uri) //
- .flatMap(this::toBody);
+ .flatMap(this::toBody);
}
private Mono<ResponseEntity<String>> retrieve(Object traceTag, RequestHeadersSpec<?> request) {
final Class<String> clazz = String.class;
return request.retrieve() //
- .toEntity(clazz) //
- .doOnNext(entity -> logReceivedData(traceTag, entity)) //
- .doOnError(throwable -> onHttpError(traceTag, throwable));
+ .toEntity(clazz) //
+ .doOnNext(entity -> logReceivedData(traceTag, entity)) //
+ .doOnError(throwable -> onHttpError(traceTag, throwable));
}
private void logReceivedData(Object traceTag, ResponseEntity<String> entity) {
@@ -201,7 +201,7 @@ public class AsyncRestClient {
if (t instanceof WebClientResponseException) {
WebClientResponseException exception = (WebClientResponseException) t;
logger.debug("{} HTTP error status = '{}', body '{}'", traceTag, exception.getStatusCode(),
- exception.getResponseBodyAsString());
+ exception.getResponseBodyAsString());
} else {
logger.debug("{} HTTP error", traceTag, t);
}
@@ -234,7 +234,7 @@ public class AsyncRestClient {
}
private static synchronized KeyStore getTrustStore(String trustStorePath, String trustStorePass)
- throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
+ throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
if (clientTrustStore == null) {
KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType());
store.load(new FileInputStream(ResourceUtils.getFile(trustStorePath)), trustStorePass.toCharArray());
@@ -244,66 +244,66 @@ public class AsyncRestClient {
}
private SslContext createSslContextRejectingUntrustedPeers(String trustStorePath, String trustStorePass,
- KeyManagerFactory keyManager)
- throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
+ KeyManagerFactory keyManager)
+ throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
final KeyStore trustStore = getTrustStore(trustStorePath, trustStorePass);
List<Certificate> certificateList = Collections.list(trustStore.aliases()).stream() //
- .filter(alias -> isCertificateEntry(trustStore, alias)) //
- .map(alias -> getCertificate(trustStore, alias)) //
- .collect(Collectors.toList());
+ .filter(alias -> isCertificateEntry(trustStore, alias)) //
+ .map(alias -> getCertificate(trustStore, alias)) //
+ .collect(Collectors.toList());
final X509Certificate[] certificates = certificateList.toArray(new X509Certificate[certificateList.size()]);
return SslContextBuilder.forClient() //
- .keyManager(keyManager) //
- .trustManager(certificates) //
- .build();
+ .keyManager(keyManager) //
+ .trustManager(certificates) //
+ .build();
}
private SslContext createSslContext(KeyManagerFactory keyManager)
- throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {
+ throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {
if (this.clientConfig.isTrustStoreUsed()) {
return createSslContextRejectingUntrustedPeers(this.clientConfig.trustStore(),
- this.clientConfig.trustStorePassword(), keyManager);
+ this.clientConfig.trustStorePassword(), keyManager);
} else {
// Trust anyone
return SslContextBuilder.forClient() //
- .keyManager(keyManager) //
- .trustManager(InsecureTrustManagerFactory.INSTANCE) //
- .build();
+ .keyManager(keyManager) //
+ .trustManager(InsecureTrustManagerFactory.INSTANCE) //
+ .build();
}
}
private TcpClient createTcpClientSecure(SslContext sslContext) {
return TcpClient.create(ConnectionProvider.newConnection()) //
- .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
- .secure(c -> c.sslContext(sslContext)) //
- .doOnConnected(connection -> {
- connection.addHandlerLast(new ReadTimeoutHandler(30));
- connection.addHandlerLast(new WriteTimeoutHandler(30));
- });
+ .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
+ .secure(c -> c.sslContext(sslContext)) //
+ .doOnConnected(connection -> {
+ connection.addHandlerLast(new ReadTimeoutHandler(30));
+ connection.addHandlerLast(new WriteTimeoutHandler(30));
+ });
}
private TcpClient createTcpClientInsecure() {
return TcpClient.create(ConnectionProvider.newConnection()) //
- .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
- .doOnConnected(connection -> {
- connection.addHandlerLast(new ReadTimeoutHandler(30));
- connection.addHandlerLast(new WriteTimeoutHandler(30));
- });
+ .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
+ .doOnConnected(connection -> {
+ connection.addHandlerLast(new ReadTimeoutHandler(30));
+ connection.addHandlerLast(new WriteTimeoutHandler(30));
+ });
}
private WebClient createWebClient(String baseUrl, TcpClient tcpClient) {
HttpClient httpClient = HttpClient.from(tcpClient);
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() //
- .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) //
- .build();
+ .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) //
+ .build();
return WebClient.builder() //
- .clientConnector(connector) //
- .baseUrl(baseUrl) //
- .exchangeStrategies(exchangeStrategies) //
- .build();
+ .clientConnector(connector) //
+ .baseUrl(baseUrl) //
+ .exchangeStrategies(exchangeStrategies) //
+ .build();
}
private Mono<WebClient> getWebClient() {
@@ -311,7 +311,7 @@ public class AsyncRestClient {
try {
if (this.sslEnabled) {
final KeyManagerFactory keyManager =
- KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.keyStoreType());
final String keyStoreFile = this.clientConfig.keyStore();
final String keyStorePassword = this.clientConfig.keyStorePassword();
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 bdbb916b..fed218e8 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
@@ -144,21 +144,21 @@ public class OscA1Client implements A1Client {
@Override
public Mono<List<String>> getPolicyTypeIdentities() {
return getPolicyTypeIds() //
- .collectList();
+ .collectList();
}
@Override
public Mono<List<String>> getPolicyIdentities() {
return getPolicyTypeIds() //
- .flatMap(this::getPolicyIdentitiesByType) //
- .collectList();
+ .flatMap(this::getPolicyIdentitiesByType) //
+ .collectList();
}
@Override
public Mono<String> getPolicyTypeSchema(String policyTypeId) {
String schemaUri = uri.createGetSchemaUri(policyTypeId);
return restClient.get(schemaUri) //
- .flatMap(response -> extractCreateSchema(response, policyTypeId));
+ .flatMap(response -> extractCreateSchema(response, policyTypeId));
}
@Override
@@ -175,13 +175,13 @@ public class OscA1Client implements A1Client {
@Override
public Mono<A1ProtocolType> getProtocolVersion() {
return restClient.get(uri.createHealtcheckUri()) //
- .flatMap(notUsed -> Mono.just(A1ProtocolType.OSC_V1));
+ .flatMap(notUsed -> Mono.just(A1ProtocolType.OSC_V1));
}
@Override
public Flux<String> deleteAllPolicies() {
return getPolicyTypeIds() //
- .flatMap(this::deletePoliciesForType, CONCURRENCY_RIC);
+ .flatMap(this::deletePoliciesForType, CONCURRENCY_RIC);
}
@Override
@@ -193,12 +193,12 @@ public class OscA1Client implements A1Client {
private Flux<String> getPolicyTypeIds() {
return restClient.get(uri.createPolicyTypesUri()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Flux<String> getPolicyIdentitiesByType(String typeId) {
return restClient.get(uri.createGetPolicyIdsUri(typeId)) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Mono<String> deletePolicyById(String typeId, String policyId) {
@@ -208,6 +208,6 @@ public class OscA1Client implements A1Client {
private Flux<String> deletePoliciesForType(String typeId) {
return getPolicyIdentitiesByType(typeId) //
- .flatMap(policyId -> deletePolicyById(typeId, policyId), CONCURRENCY_RIC);
+ .flatMap(policyId -> deletePolicyById(typeId, policyId), CONCURRENCY_RIC);
}
}
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/SdncJsonHelper.java
index fdbbd533..ada35fd6 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/SdncJsonHelper.java
@@ -45,13 +45,12 @@ import reactor.core.publisher.Mono;
@SuppressWarnings("java:S1192") // Same text in several traces
class SdncJsonHelper {
private static Gson gson = new GsonBuilder() //
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) //
- .create();
+ .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 SdncJsonHelper() {}
public static Flux<String> parseJsonArrayOfString(String inputString) {
try {
@@ -97,13 +96,13 @@ class SdncJsonHelper {
public static Mono<String> getValueFromResponse(String response, String key) {
return getOutput(response) //
- .flatMap(responseParams -> {
- if (!responseParams.has(key)) {
- return Mono.just("");
- }
- String value = responseParams.get(key).toString();
- return Mono.just(value);
- });
+ .flatMap(responseParams -> {
+ if (!responseParams.has(key)) {
+ return Mono.just("");
+ }
+ String value = responseParams.get(key).toString();
+ return Mono.just(value);
+ });
}
public static Mono<String> extractPolicySchema(String inputString) {
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
index 0591e668..2c564c3f 100644
--- 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
@@ -66,9 +66,9 @@ public class SdncOnapA1Client implements A1Client {
public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig, WebClientConfig clientConfig) {
this(ricConfig, controllerConfig,
- new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
+ new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
logger.debug("SdncOnapA1Client for ric: {}, a1ControllerBaseUrl: {}", ricConfig.ricId(),
- controllerConfig.baseUrl());
+ controllerConfig.baseUrl());
}
public SdncOnapA1Client(RicConfig ricConfig, ControllerConfig controllerConfig, AsyncRestClient restClient) {
@@ -80,47 +80,47 @@ public class SdncOnapA1Client implements A1Client {
@Override
public Mono<List<String>> getPolicyTypeIdentities() {
return getPolicyTypeIds() //
- .collectList();
+ .collectList();
}
@Override
public Mono<List<String>> getPolicyIdentities() {
return getPolicyTypeIds() //
- .flatMap(this::getPolicyIdentitiesByType) //
- .collectList();
+ .flatMap(this::getPolicyIdentitiesByType) //
+ .collectList();
}
@Override
public Mono<String> getPolicyTypeSchema(String policyTypeId) {
SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .policyTypeId(policyTypeId) //
- .build();
+ .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);
+ .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();
+ .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());
+ controllerConfig.userName(), controllerConfig.password());
}
@Override
@@ -131,13 +131,13 @@ public class SdncOnapA1Client implements A1Client {
@Override
public Flux<String> deleteAllPolicies() {
return getPolicyTypeIds() //
- .flatMap(this::deletePoliciesForType); //
+ .flatMap(this::deletePoliciesForType); //
}
@Override
public Mono<A1ProtocolType> getProtocolVersion() {
return getPolicyTypeIdentities() //
- .flatMap(notUsed -> Mono.just(A1ProtocolType.SDNC_ONAP));
+ .flatMap(notUsed -> Mono.just(A1ProtocolType.SDNC_ONAP));
}
@Override
@@ -147,48 +147,48 @@ public class SdncOnapA1Client implements A1Client {
private Flux<String> getPolicyTypeIds() {
SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(ricConfig.baseUrl()) //
- .build();
+ .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);
+ .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();
+ .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);
+ .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)); //
+ .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();
+ .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());
+ controllerConfig.userName(), controllerConfig.password());
}
}
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/SdncOscA1Client.java
index 4ad08ce2..3647f225 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/SdncOscA1Client.java
@@ -68,8 +68,8 @@ public class SdncOscA1Client implements A1Client {
}
static com.google.gson.Gson gson = new GsonBuilder() //
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) //
- .create(); //
+ .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES) //
+ .create(); //
private static final String GET_POLICY_RPC = "getA1Policy";
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -90,9 +90,9 @@ public class SdncOscA1Client implements A1Client {
* @throws IllegalArgumentException when the protocolType is wrong.
*/
public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
- WebClientConfig clientConfig) {
+ WebClientConfig clientConfig) {
this(protocolType, ricConfig, controllerConfig,
- new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
+ new AsyncRestClient(controllerConfig.baseUrl() + "/restconf/operations", clientConfig));
logger.debug("SdncOscA1Client for ric: {}, a1Controller: {}", ricConfig.ricId(), controllerConfig);
}
@@ -109,11 +109,11 @@ public class SdncOscA1Client implements A1Client {
* @throws IllegalArgumentException when the protocolType is wrong.
*/
public SdncOscA1Client(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
- AsyncRestClient restClient) {
+ AsyncRestClient restClient) {
if (!(A1ProtocolType.SDNC_OSC_STD_V1_1.equals(protocolType)
- || A1ProtocolType.SDNC_OSC_OSC_V1.equals(protocolType))) {
+ || A1ProtocolType.SDNC_OSC_OSC_V1.equals(protocolType))) {
throw new IllegalArgumentException("Protocol type must be " + A1ProtocolType.SDNC_OSC_STD_V1_1 + " or "
- + A1ProtocolType.SDNC_OSC_OSC_V1 + ", was: " + protocolType);
+ + A1ProtocolType.SDNC_OSC_OSC_V1 + ", was: " + protocolType);
}
this.restClient = restClient;
this.ricConfig = ricConfig;
@@ -129,8 +129,8 @@ public class SdncOscA1Client implements A1Client {
OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
final String ricUrl = uri.createPolicyTypesUri();
return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString) //
- .collectList();
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString) //
+ .collectList();
}
}
@@ -138,7 +138,7 @@ public class SdncOscA1Client implements A1Client {
@Override
public Mono<List<String>> getPolicyIdentities() {
return getPolicyIds() //
- .collectList();
+ .collectList();
}
@Override
@@ -149,17 +149,17 @@ public class SdncOscA1Client implements A1Client {
OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
final String ricUrl = uri.createGetSchemaUri(policyTypeId);
return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
- .flatMap(response -> OscA1Client.extractCreateSchema(response, policyTypeId));
+ .flatMap(response -> OscA1Client.extractCreateSchema(response, policyTypeId));
}
}
@Override
public Mono<String> putPolicy(Policy policy) {
return getUriBuilder() //
- .flatMap(builder -> {
- String ricUrl = builder.createPutPolicyUri(policy.type().id(), policy.id());
- return post("putA1Policy", ricUrl, Optional.of(policy.json()));
- });
+ .flatMap(builder -> {
+ String ricUrl = builder.createPutPolicyUri(policy.type().id(), policy.id());
+ return post("putA1Policy", ricUrl, Optional.of(policy.json()));
+ });
}
@Override
@@ -171,38 +171,38 @@ public class SdncOscA1Client implements A1Client {
public Flux<String> deleteAllPolicies() {
if (this.protocolType == A1ProtocolType.SDNC_OSC_STD_V1_1) {
return getPolicyIds() //
- .flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); //
+ .flatMap(policyId -> deletePolicyById("", policyId), CONCURRENCY_RIC); //
} else {
OscA1Client.UriBuilder uriBuilder = new OscA1Client.UriBuilder(ricConfig);
return getPolicyTypeIdentities() //
- .flatMapMany(Flux::fromIterable) //
- .flatMap(type -> oscDeleteInstancesForType(uriBuilder, type), CONCURRENCY_RIC);
+ .flatMapMany(Flux::fromIterable) //
+ .flatMap(type -> oscDeleteInstancesForType(uriBuilder, type), CONCURRENCY_RIC);
}
}
private Flux<String> oscGetInstancesForType(OscA1Client.UriBuilder uriBuilder, String type) {
return post(GET_POLICY_RPC, uriBuilder.createGetPolicyIdsUri(type), Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Flux<String> oscDeleteInstancesForType(OscA1Client.UriBuilder uriBuilder, String type) {
return oscGetInstancesForType(uriBuilder, type) //
- .flatMap(instance -> deletePolicyById(type, instance), CONCURRENCY_RIC);
+ .flatMap(instance -> deletePolicyById(type, instance), CONCURRENCY_RIC);
}
@Override
public Mono<A1ProtocolType> getProtocolVersion() {
return tryStdProtocolVersion() //
- .onErrorResume(t -> tryOscProtocolVersion());
+ .onErrorResume(t -> tryOscProtocolVersion());
}
@Override
public Mono<String> getPolicyStatus(Policy policy) {
return getUriBuilder() //
- .flatMap(builder -> {
- String ricUrl = builder.createGetPolicyStatusUri(policy.type().id(), policy.id());
- return post("getA1PolicyStatus", ricUrl, Optional.empty());
- });
+ .flatMap(builder -> {
+ String ricUrl = builder.createGetPolicyStatusUri(policy.type().id(), policy.id());
+ return post("getA1PolicyStatus", ricUrl, Optional.empty());
+ });
}
private Mono<A1UriBuilder> getUriBuilder() {
@@ -216,13 +216,13 @@ 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.SDNC_OSC_OSC_V1));
}
private Mono<A1ProtocolType> tryStdProtocolVersion() {
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.SDNC_OSC_STD_V1_1));
}
private Flux<String> getPolicyIds() {
@@ -230,36 +230,36 @@ public class SdncOscA1Client implements A1Client {
StdA1ClientVersion1.UriBuilder uri = new StdA1ClientVersion1.UriBuilder(ricConfig);
final String ricUrl = uri.createGetPolicyIdsUri();
return post(GET_POLICY_RPC, ricUrl, Optional.empty()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
} else {
OscA1Client.UriBuilder uri = new OscA1Client.UriBuilder(ricConfig);
return getPolicyTypeIdentities() //
- .flatMapMany(Flux::fromIterable)
- .flatMap(type -> post(GET_POLICY_RPC, uri.createGetPolicyIdsUri(type), Optional.empty())) //
- .flatMap(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(Flux::fromIterable)
+ .flatMap(type -> post(GET_POLICY_RPC, uri.createGetPolicyIdsUri(type), Optional.empty())) //
+ .flatMap(SdncJsonHelper::parseJsonArrayOfString);
}
}
private Mono<String> deletePolicyById(String type, String policyId) {
return getUriBuilder() //
- .flatMap(builder -> {
- String ricUrl = builder.createDeleteUri(type, policyId);
- return post("deleteA1Policy", ricUrl, Optional.empty());
- });
+ .flatMap(builder -> {
+ String ricUrl = builder.createDeleteUri(type, policyId);
+ return post("deleteA1Policy", ricUrl, Optional.empty());
+ });
}
private Mono<String> post(String rpcName, String ricUrl, Optional<String> body) {
AdapterRequest inputParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(ricUrl) //
- .body(body) //
- .build();
+ .nearRtRicUrl(ricUrl) //
+ .body(body) //
+ .build();
final String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
logger.debug("POST inputJsonString = {}", inputJsonString);
return restClient
- .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.userName(),
- this.controllerConfig.password()) //
- .flatMap(this::extractResponseBody);
+ .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.userName(),
+ this.controllerConfig.password()) //
+ .flatMap(this::extractResponseBody);
}
private Mono<String> extractResponse(JSONObject responseOutput) {
@@ -272,7 +272,7 @@ public class SdncOscA1Client implements A1Client {
logger.debug("Error response: {} {}", output.httpStatus(), body);
byte[] responseBodyBytes = body.getBytes(StandardCharsets.UTF_8);
WebClientResponseException responseException = new WebClientResponseException(output.httpStatus(),
- "statusText", null, responseBodyBytes, StandardCharsets.UTF_8, null);
+ "statusText", null, responseBodyBytes, StandardCharsets.UTF_8, null);
return Mono.error(responseException);
}
@@ -280,7 +280,7 @@ public class SdncOscA1Client implements A1Client {
private Mono<String> extractResponseBody(String responseStr) {
return SdncJsonHelper.getOutput(responseStr) //
- .flatMap(this::extractResponse);
+ .flatMap(this::extractResponse);
}
private String controllerUrl(String rpcName) {
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 51beea71..0da9a267 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
@@ -97,7 +97,7 @@ public class StdA1ClientVersion1 implements A1Client {
@Override
public Mono<List<String>> getPolicyIdentities() {
return getPolicyIds() //
- .collectList();
+ .collectList();
}
@Override
@@ -123,13 +123,13 @@ public class StdA1ClientVersion1 implements A1Client {
@Override
public Flux<String> deleteAllPolicies() {
return getPolicyIds() //
- .flatMap(this::deletePolicyById); //
+ .flatMap(this::deletePolicyById); //
}
@Override
public Mono<A1ProtocolType> getProtocolVersion() {
return getPolicyIdentities() //
- .flatMap(x -> Mono.just(A1ProtocolType.STD_V1_1));
+ .flatMap(x -> Mono.just(A1ProtocolType.STD_V1_1));
}
@Override
@@ -139,7 +139,7 @@ public class StdA1ClientVersion1 implements A1Client {
private Flux<String> getPolicyIds() {
return restClient.get(uri.createGetPolicyIdsUri()) //
- .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
+ .flatMapMany(SdncJsonHelper::parseJsonArrayOfString);
}
private Mono<String> deletePolicyById(String policyId) {
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 4f8e87fd..65c6daa3 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
@@ -80,14 +80,14 @@ public class ApplicationConfig {
public WebClientConfig getWebClientConfig() {
return ImmutableWebClientConfig.builder() //
- .keyStoreType(this.sslKeyStoreType) //
- .keyStorePassword(this.sslKeyStorePassword) //
- .keyStore(this.sslKeyStore) //
- .keyPassword(this.sslKeyPassword) //
- .isTrustStoreUsed(this.sslTrustStoreUsed) //
- .trustStore(this.sslTrustStore) //
- .trustStorePassword(this.sslTrustStorePassword) //
- .build();
+ .keyStoreType(this.sslKeyStoreType) //
+ .keyStorePassword(this.sslKeyStorePassword) //
+ .keyStore(this.sslKeyStore) //
+ .keyPassword(this.sslKeyPassword) //
+ .isTrustStoreUsed(this.sslTrustStoreUsed) //
+ .trustStore(this.sslTrustStore) //
+ .trustStorePassword(this.sslTrustStorePassword) //
+ .build();
}
public synchronized ControllerConfig getControllerConfig(String name) throws ServiceException {
@@ -123,7 +123,7 @@ public class ApplicationConfig {
}
public synchronized Flux<RicConfigUpdate> setConfiguration(
- ApplicationConfigParser.ConfigParserResult parserResult) {
+ ApplicationConfigParser.ConfigParserResult parserResult) {
Collection<RicConfigUpdate> modifications = new ArrayList<>();
this.controllerConfigs = parserResult.controllerConfigs();
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 07c04e1a..bc1f62a4 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
@@ -87,15 +87,15 @@ public class ApplicationConfigParser {
checkConfigurationConsistency(ricConfigs, controllerConfigs);
return ImmutableConfigParserResult.builder() //
- .dmaapConsumerTopicUrl(dmaapConsumerTopicUrl) //
- .dmaapProducerTopicUrl(dmaapProducerTopicUrl) //
- .ricConfigs(ricConfigs) //
- .controllerConfigs(controllerConfigs) //
- .build();
+ .dmaapConsumerTopicUrl(dmaapConsumerTopicUrl) //
+ .dmaapProducerTopicUrl(dmaapProducerTopicUrl) //
+ .ricConfigs(ricConfigs) //
+ .controllerConfigs(controllerConfigs) //
+ .build();
}
private void checkConfigurationConsistency(List<RicConfig> ricConfigs,
- Map<String, ControllerConfig> controllerConfigs) throws ServiceException {
+ Map<String, ControllerConfig> controllerConfigs) throws ServiceException {
Set<String> ricUrls = new HashSet<>();
Set<String> ricNames = new HashSet<>();
for (RicConfig ric : ricConfigs) {
@@ -107,7 +107,7 @@ public class ApplicationConfigParser {
}
if (!ric.controllerName().isEmpty() && controllerConfigs.get(ric.controllerName()) == null) {
throw new ServiceException(
- "Configuration error, controller configuration not found: " + ric.controllerName());
+ "Configuration error, controller configuration not found: " + ric.controllerName());
}
}
@@ -119,11 +119,11 @@ public class ApplicationConfigParser {
JsonObject ricAsJson = ricElem.getAsJsonObject();
JsonElement controllerNameElement = ricAsJson.get(CONTROLLER);
RicConfig ricConfig = ImmutableRicConfig.builder() //
- .ricId(get(ricAsJson, "name", "id", "ricId").getAsString()) //
- .baseUrl(get(ricAsJson, "baseUrl").getAsString()) //
- .managedElementIds(parseManagedElementIds(get(ricAsJson, "managedElementIds").getAsJsonArray())) //
- .controllerName(controllerNameElement != null ? controllerNameElement.getAsString() : "") //
- .build();
+ .ricId(get(ricAsJson, "name", "id", "ricId").getAsString()) //
+ .baseUrl(get(ricAsJson, "baseUrl").getAsString()) //
+ .managedElementIds(parseManagedElementIds(get(ricAsJson, "managedElementIds").getAsJsonArray())) //
+ .controllerName(controllerNameElement != null ? controllerNameElement.getAsString() : "") //
+ .build();
result.add(ricConfig);
}
return result;
@@ -137,15 +137,15 @@ public class ApplicationConfigParser {
for (JsonElement element : getAsJsonArray(config, CONTROLLER)) {
JsonObject controllerAsJson = element.getAsJsonObject();
ImmutableControllerConfig controllerConfig = ImmutableControllerConfig.builder() //
- .name(get(controllerAsJson, "name").getAsString()) //
- .baseUrl(get(controllerAsJson, "baseUrl").getAsString()) //
- .password(get(controllerAsJson, "password").getAsString()) //
- .userName(get(controllerAsJson, "userName").getAsString()) // )
- .build();
+ .name(get(controllerAsJson, "name").getAsString()) //
+ .baseUrl(get(controllerAsJson, "baseUrl").getAsString()) //
+ .password(get(controllerAsJson, "password").getAsString()) //
+ .userName(get(controllerAsJson, "userName").getAsString()) // )
+ .build();
if (result.put(controllerConfig.name(), controllerConfig) != null) {
throw new ServiceException(
- "Configuration error, more than one controller with name: " + controllerConfig.name());
+ "Configuration error, more than one controller with name: " + controllerConfig.name());
}
}
return result;
@@ -179,7 +179,7 @@ public class ApplicationConfigParser {
Set<Entry<String, JsonElement>> streamConfigEntries = streamCfg.entrySet();
if (streamConfigEntries.size() != 1) {
throw new ServiceException(
- "Invalid configuration. Number of streams must be one, config: " + streamConfigEntries);
+ "Invalid configuration. Number of streams must be one, config: " + streamConfigEntries);
}
JsonObject streamConfigEntry = streamConfigEntries.iterator().next().getValue().getAsJsonObject();
JsonObject dmaapInfo = get(streamConfigEntry, "dmaap_info").getAsJsonObject();
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java
index 6ee656cc..a2b9af4b 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java
@@ -27,6 +27,5 @@ import org.immutables.gson.Gson;
@Gson.TypeAdapters
@ApiModel(value = "void", description = "Void/empty")
public class VoidResponse {
- private VoidResponse() {
- }
+ private VoidResponse() {}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java
index cef31c30..c54394e0 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/Consts.java
@@ -24,6 +24,5 @@ public class Consts {
public static final String V1_API_NAME = "A1 Policy Management Version 1.0";
- private Consts() {
- }
+ private Consts() {}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
index 90666e7a..d5024581 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java
@@ -92,18 +92,17 @@ public class PolicyController {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
@GetMapping("/policy_schemas")
@ApiOperation(value = "Returns policy type schema definitions")
- @ApiResponses(
- value = {
+ @ApiResponses(value = {
@ApiResponse(code = 200, message = "Policy schemas", response = Object.class, responseContainer = "List"), //
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class)})
public ResponseEntity<String> getPolicySchemas( //
- @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get the definitions for.") //
- @RequestParam(name = "ric", required = false) String ricName) {
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get the definitions for.") //
+ @RequestParam(name = "ric", required = false) String ricName) {
if (ricName == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
@@ -119,13 +118,13 @@ public class PolicyController {
@GetMapping("/policy_schema")
@ApiOperation(value = "Returns one policy type schema definition")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy schema", response = Object.class),
@ApiResponse(code = 404, message = "The policy type is not found", response = String.class)})
public ResponseEntity<String> getPolicySchema( //
- @ApiParam(name = "id", required = true, value = "The identity of the policy type to get the definition for.") //
- @RequestParam(name = "id", required = true) String id) {
+ @ApiParam(name = "id", required = true,
+ value = "The identity of the policy type to get the definition for.") //
+ @RequestParam(name = "id", required = true) String id) {
try {
PolicyType type = policyTypes.getType(id);
return new ResponseEntity<>(type.schema(), HttpStatus.OK);
@@ -136,17 +135,13 @@ public class PolicyController {
@GetMapping("/policy_types")
@ApiOperation(value = "Query policy type names")
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "Policy type names",
- response = String.class,
- responseContainer = "List"),
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Policy type names", response = String.class,
+ responseContainer = "List"),
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class)})
public ResponseEntity<String> getPolicyTypes( //
- @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get types for.") //
- @RequestParam(name = "ric", required = false) String ricName) {
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get types for.") //
+ @RequestParam(name = "ric", required = false) String ricName) {
if (ricName == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
return new ResponseEntity<>(toPolicyTypeIdsJson(types), HttpStatus.OK);
@@ -162,14 +157,13 @@ public class PolicyController {
@GetMapping("/policy")
@ApiOperation(value = "Returns a policy configuration") //
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy found", response = Object.class), //
@ApiResponse(code = 404, message = "Policy is not found")} //
)
public ResponseEntity<String> getPolicy( //
- @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = "id", required = true) String id) {
+ @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = "id", required = true) String id) {
try {
Policy p = policies.getPolicy(id);
return new ResponseEntity<>(p.json(), HttpStatus.OK);
@@ -180,28 +174,27 @@ public class PolicyController {
@DeleteMapping("/policy")
@ApiOperation(value = "Delete a policy", response = Object.class)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 204, message = "Policy deleted", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Policy is not found", response = String.class),
@ApiResponse(code = 423, message = "Near-RT RIC is not operational", response = String.class)})
public Mono<ResponseEntity<Object>> deletePolicy( //
- @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = "id", required = true) String id) {
+ @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = "id", required = true) String id) {
try {
Policy policy = policies.getPolicy(id);
keepServiceAlive(policy.ownerServiceId());
Ric ric = policy.ric();
return ric.getLock().lock(LockType.SHARED) //
- .flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
- .doOnNext(notUsed -> policies.remove(policy)) //
- .flatMap(client -> client.deletePolicy(policy)) //
- .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
- .doOnError(notUsed -> ric.getLock().unlockBlocking()) //
- .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
- .onErrorResume(this::handleException);
+ .flatMap(notUsed -> assertRicStateIdle(ric)) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
+ .doOnNext(notUsed -> policies.remove(policy)) //
+ .flatMap(client -> client.deletePolicy(policy)) //
+ .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
+ .doOnError(notUsed -> ric.getLock().unlockBlocking()) //
+ .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
+ .onErrorResume(this::handleException);
} catch (ServiceException e) {
return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
@@ -209,28 +202,27 @@ public class PolicyController {
@PutMapping(path = "/policy")
@ApiOperation(value = "Put a policy", response = VoidResponse.class)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 201, message = "Policy created", response = VoidResponse.class), //
@ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), //
@ApiResponse(code = 423, message = "Near-RT RIC is not operational", response = String.class), //
@ApiResponse(code = 404, message = "Near-RT RIC or policy type is not found", response = String.class) //
- })
+ })
public Mono<ResponseEntity<Object>> putPolicy( //
- @ApiParam(name = "type", required = false, value = "The name of the policy type.") //
- @RequestParam(name = "type", required = false, defaultValue = "") String typeName, //
- @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = "id", required = true) String instanceId, //
- @ApiParam(name = "ric", required = true, value = "The name of the Near-RT RIC where the policy will be " + //
- "created.") //
- @RequestParam(name = "ric", required = true) String ricName, //
- @ApiParam(name = "service", required = true, value = "The name of the service creating the policy.") //
- @RequestParam(name = "service", required = true) String service, //
- @ApiParam(name = "transient", required = false, value = "If the policy is transient or not (boolean " + //
- "defaulted to false). A policy is transient if it will be forgotten when the service needs to " + //
- "reconnect to the Near-RT RIC.") //
- @RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, //
- @RequestBody Object jsonBody) {
+ @ApiParam(name = "type", required = false, value = "The name of the policy type.") //
+ @RequestParam(name = "type", required = false, defaultValue = "") String typeName, //
+ @ApiParam(name = "id", required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = "id", required = true) String instanceId, //
+ @ApiParam(name = "ric", required = true, value = "The name of the Near-RT RIC where the policy will be " + //
+ "created.") //
+ @RequestParam(name = "ric", required = true) String ricName, //
+ @ApiParam(name = "service", required = true, value = "The name of the service creating the policy.") //
+ @RequestParam(name = "service", required = true) String service, //
+ @ApiParam(name = "transient", required = false, value = "If the policy is transient or not (boolean " + //
+ "defaulted to false). A policy is transient if it will be forgotten when the service needs to " + //
+ "reconnect to the Near-RT RIC.") //
+ @RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, //
+ @RequestBody Object jsonBody) {
String jsonString = gson.toJson(jsonBody);
Ric ric = rics.get(ricName);
@@ -240,28 +232,28 @@ public class PolicyController {
return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
Policy policy = ImmutablePolicy.builder() //
- .id(instanceId) //
- .json(jsonString) //
- .type(type) //
- .ric(ric) //
- .ownerServiceId(service) //
- .lastModified(Instant.now()) //
- .isTransient(isTransient) //
- .build();
+ .id(instanceId) //
+ .json(jsonString) //
+ .type(type) //
+ .ric(ric) //
+ .ownerServiceId(service) //
+ .lastModified(Instant.now()) //
+ .isTransient(isTransient) //
+ .build();
final boolean isCreate = this.policies.get(policy.id()) == null;
return ric.getLock().lock(LockType.SHARED) //
- .flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> checkSupportedType(ric, type)) //
- .flatMap(notUsed -> validateModifiedPolicy(policy)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) //
- .flatMap(client -> client.putPolicy(policy)) //
- .doOnNext(notUsed -> policies.put(policy)) //
- .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
- .doOnError(trowable -> ric.getLock().unlockBlocking()) //
- .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) //
- .onErrorResume(this::handleException);
+ .flatMap(notUsed -> assertRicStateIdle(ric)) //
+ .flatMap(notUsed -> checkSupportedType(ric, type)) //
+ .flatMap(notUsed -> validateModifiedPolicy(policy)) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) //
+ .flatMap(client -> client.putPolicy(policy)) //
+ .doOnNext(notUsed -> policies.put(policy)) //
+ .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
+ .doOnError(trowable -> ric.getLock().unlockBlocking()) //
+ .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) //
+ .onErrorResume(this::handleException);
}
@SuppressWarnings({"unchecked"})
@@ -287,8 +279,8 @@ public class PolicyController {
Policy current = this.policies.get(policy.id());
if (current != null && !current.ric().id().equals(policy.ric().id())) {
RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + //
- ", RIC name: " + current.ric().id() + //
- ", new name: " + policy.ric().id(), HttpStatus.CONFLICT);
+ ", RIC name: " + current.ric().id() + //
+ ", new name: " + policy.ric().id(), HttpStatus.CONFLICT);
logger.debug("Request rejected, {}", e.getMessage());
return Mono.error(e);
}
@@ -299,7 +291,7 @@ public class PolicyController {
if (!ric.isSupportingType(type.id())) {
logger.debug("Request rejected, type not supported, RIC: {}", ric);
RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(),
- HttpStatus.NOT_FOUND);
+ HttpStatus.NOT_FOUND);
return Mono.error(e);
}
return Mono.just("OK");
@@ -311,24 +303,23 @@ public class PolicyController {
} else {
logger.debug("Request rejected RIC not IDLE, ric: {}", ric);
RejectionException e = new RejectionException(
- "Ric is not operational, RIC name: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED);
+ "Ric is not operational, RIC name: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED);
return Mono.error(e);
}
}
@GetMapping("/policies")
@ApiOperation(value = "Query policies")
- @ApiResponses(
- value = {
+ @ApiResponses(value = {
@ApiResponse(code = 200, message = "Policies", response = PolicyInfo.class, responseContainer = "List"),
@ApiResponse(code = 404, message = "Near-RT RIC or type not found", response = String.class)})
public ResponseEntity<String> getPolicies( //
- @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
- @RequestParam(name = "type", required = false) String type, //
- @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
- @RequestParam(name = "ric", required = false) String ric, //
- @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
- @RequestParam(name = "service", required = false) String service) //
+ @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
+ @RequestParam(name = "type", required = false) String type, //
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
+ @RequestParam(name = "ric", required = false) String ric, //
+ @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
+ @RequestParam(name = "service", required = false) String service) //
{
if ((type != null && this.policyTypes.get(type) == null)) {
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
@@ -343,21 +334,17 @@ public class PolicyController {
@GetMapping("/policy_ids")
@ApiOperation(value = "Query policies, only policy identities returned")
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "Policy identitiess",
- response = String.class,
- responseContainer = "List"),
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Policy identitiess", response = String.class,
+ responseContainer = "List"),
@ApiResponse(code = 404, message = "Near-RT RIC or type not found", response = String.class)})
public ResponseEntity<String> getPolicyIds( //
- @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
- @RequestParam(name = "type", required = false) String type, //
- @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
- @RequestParam(name = "ric", required = false) String ric, //
- @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
- @RequestParam(name = "service", required = false) String service) //
+ @ApiParam(name = "type", required = false, value = "The name of the policy type to get policies for.") //
+ @RequestParam(name = "type", required = false) String type, //
+ @ApiParam(name = "ric", required = false, value = "The name of the Near-RT RIC to get policies for.") //
+ @RequestParam(name = "ric", required = false) String ric, //
+ @ApiParam(name = "service", required = false, value = "The name of the service to get policies for.") //
+ @RequestParam(name = "service", required = false) String service) //
{
if ((type != null && this.policyTypes.get(type) == null)) {
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
@@ -372,22 +359,20 @@ public class PolicyController {
@GetMapping("/policy_status")
@ApiOperation(value = "Returns a policy status") //
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy status", response = Object.class), //
@ApiResponse(code = 404, message = "Policy is not found", response = String.class)} //
)
public Mono<ResponseEntity<String>> getPolicyStatus( //
- @ApiParam(name = "id", required = true, value = "The identity of the policy.") @RequestParam(
- name = "id", //
- required = true) String id) {
+ @ApiParam(name = "id", required = true, value = "The identity of the policy.") @RequestParam(name = "id", //
+ required = true) String id) {
try {
Policy policy = policies.getPolicy(id);
return a1ClientFactory.createA1Client(policy.ric()) //
- .flatMap(client -> client.getPolicyStatus(policy)) //
- .flatMap(status -> Mono.just(new ResponseEntity<>(status, HttpStatus.OK)))
- .onErrorResume(this::handleException);
+ .flatMap(client -> client.getPolicyStatus(policy)) //
+ .flatMap(status -> Mono.just(new ResponseEntity<>(status, HttpStatus.OK)))
+ .onErrorResume(this::handleException);
} catch (ServiceException e) {
return Mono.just(new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND));
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java
index c4862016..21e5b96c 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java
@@ -47,8 +47,7 @@ public class PolicyInfo {
@ApiModelProperty(value = "timestamp, last modification time")
public String lastModified;
- PolicyInfo() {
- }
+ PolicyInfo() {}
public boolean validate() {
return id != null && type != null && ric != null && json != null && service != null && lastModified != null;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java
index cd56abda..31c4f3bf 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java
@@ -54,22 +54,21 @@ public class RicRepositoryController {
PolicyTypes types;
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
/**
* Example: http://localhost:8081/rics?managedElementId=kista_1
*/
@GetMapping("/ric")
@ApiOperation(value = "Returns the name of a RIC managing one Mananged Element")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Near-RT RIC is found", response = String.class), //
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = String.class) //
- })
+ })
public ResponseEntity<String> getRic( //
- @ApiParam(name = "managedElementId", required = true, value = "The identity of the Managed Element") //
- @RequestParam(name = "managedElementId", required = true) String managedElementId) {
+ @ApiParam(name = "managedElementId", required = true, value = "The identity of the Managed Element") //
+ @RequestParam(name = "managedElementId", required = true) String managedElementId) {
Optional<Ric> ric = this.rics.lookupRicForManagedElement(managedElementId);
if (ric.isPresent()) {
@@ -84,13 +83,12 @@ public class RicRepositoryController {
*/
@GetMapping("/rics")
@ApiOperation(value = "Query Near-RT RIC information")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "OK", response = RicInfo.class, responseContainer = "List"), //
@ApiResponse(code = 404, message = "Policy type is not found", response = String.class)})
public ResponseEntity<String> getRics( //
- @ApiParam(name = "policyType", required = false, value = "The name of the policy type") //
- @RequestParam(name = "policyType", required = false) String supportingPolicyType) {
+ @ApiParam(name = "policyType", required = false, value = "The name of the policy type") //
+ @RequestParam(name = "policyType", required = false) String supportingPolicyType) {
if ((supportingPolicyType != null) && (this.types.get(supportingPolicyType) == null)) {
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
}
@@ -99,7 +97,7 @@ public class RicRepositoryController {
for (Ric ric : rics.getRics()) {
if (supportingPolicyType == null || ric.isSupportingType(supportingPolicyType)) {
result.add(new RicInfo(ric.id(), ric.getManagedElementIds(), ric.getSupportedPolicyTypeNames(),
- ric.getState().toString()));
+ ric.getState().toString()));
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
index bb85ad14..8f51c686 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceController.java
@@ -59,7 +59,7 @@ public class ServiceController {
private final Policies policies;
private static Gson gson = new GsonBuilder() //
- .create(); //
+ .create(); //
@Autowired
ServiceController(Services services, Policies policies) {
@@ -69,13 +69,12 @@ public class ServiceController {
@GetMapping("/services")
@ApiOperation(value = "Returns service information")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "OK", response = ServiceStatus.class, responseContainer = "List"), //
@ApiResponse(code = 404, message = "Service is not found", response = String.class)})
public ResponseEntity<String> getServices(//
- @ApiParam(name = "name", required = false, value = "The name of the service") //
- @RequestParam(name = "name", required = false) String name) {
+ @ApiParam(name = "name", required = false, value = "The name of the service") //
+ @RequestParam(name = "name", required = false) String name) {
if (name != null && this.services.get(name) == null) {
return new ResponseEntity<>("Service not found", HttpStatus.NOT_FOUND);
}
@@ -93,11 +92,11 @@ public class ServiceController {
private ServiceStatus toServiceStatus(Service s) {
return new ServiceStatus(s.getName(), s.getKeepAliveInterval().toSeconds(), s.timeSinceLastPing().toSeconds(),
- s.getCallbackUrl());
+ s.getCallbackUrl());
}
private void validateRegistrationInfo(ServiceRegistrationInfo registrationInfo)
- throws ServiceException, MalformedURLException {
+ throws ServiceException, MalformedURLException {
if (registrationInfo.serviceName.isEmpty()) {
throw new ServiceException("Missing mandatory parameter 'serviceName'");
}
@@ -110,14 +109,13 @@ public class ServiceController {
}
@ApiOperation(value = "Register a service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service updated", response = String.class),
@ApiResponse(code = 201, message = "Service created", response = String.class), //
@ApiResponse(code = 400, message = "The ServiceRegistrationInfo is not accepted", response = String.class)})
@PutMapping("/service")
public ResponseEntity<String> putService(//
- @RequestBody ServiceRegistrationInfo registrationInfo) {
+ @RequestBody ServiceRegistrationInfo registrationInfo) {
try {
validateRegistrationInfo(registrationInfo);
final boolean isCreate = this.services.get(registrationInfo.serviceName) == null;
@@ -129,15 +127,14 @@ public class ServiceController {
}
@ApiOperation(value = "Delete a service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 204, message = "Service deleted"),
@ApiResponse(code = 204, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Service not found", response = String.class)})
@DeleteMapping("/services")
public ResponseEntity<String> deleteService(//
- @ApiParam(name = "name", required = true, value = "The name of the service") //
- @RequestParam(name = "name", required = true) String serviceName) {
+ @ApiParam(name = "name", required = true, value = "The name of the service") //
+ @RequestParam(name = "name", required = true) String serviceName) {
try {
Service service = removeService(serviceName);
// Remove the policies from the repo and let the consistency monitoring
@@ -150,14 +147,13 @@ public class ServiceController {
}
@ApiOperation(value = "Heartbeat from a serice")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service supervision timer refreshed, OK"),
@ApiResponse(code = 404, message = "The service is not found, needs re-registration")})
@PutMapping("/services/keepalive")
public ResponseEntity<String> keepAliveService(//
- @ApiParam(name = "name", required = true, value = "The name of the service") //
- @RequestParam(name = "name", required = true) String serviceName) {
+ @ApiParam(name = "name", required = true, value = "The name of the service") //
+ @RequestParam(name = "name", required = true) String serviceName) {
try {
services.getService(serviceName).keepAlive();
return new ResponseEntity<>("OK", HttpStatus.OK);
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java
index 89016919..38e9b3b4 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ServiceRegistrationInfo.java
@@ -34,8 +34,7 @@ public class ServiceRegistrationInfo {
@SerializedName("serviceName")
public String serviceName = "";
- @ApiModelProperty(
- value = "keep alive interval for the service. This is a heartbeat supervision of the service, "
+ @ApiModelProperty(value = "keep alive interval for the service. This is a heartbeat supervision of the service, "
+ "which in regular intevals must invoke a 'keepAlive' REST call. "
+ "When a service does not invoke this call within the given time, it is considered unavailble. "
+ "An unavailable service will be automatically deregistered and its policies will be deleted. "
@@ -47,8 +46,7 @@ public class ServiceRegistrationInfo {
@SerializedName("callbackUrl")
public String callbackUrl = "";
- public ServiceRegistrationInfo() {
- }
+ public ServiceRegistrationInfo() {}
public ServiceRegistrationInfo(String name, long keepAliveIntervalSeconds, String callbackUrl) {
this.serviceName = name;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java
index e520a282..492b1ea8 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/StatusController.java
@@ -37,10 +37,9 @@ public class StatusController {
@GetMapping("/status")
@ApiOperation(value = "Returns status and statistics of this service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service is living", response = String.class) //
- })
+ })
public Mono<ResponseEntity<String>> getStatus() {
return Mono.just(new ResponseEntity<>("hunky dory", HttpStatus.OK));
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java
index 68c1d717..478b8c27 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/Consts.java
@@ -31,6 +31,5 @@ public class Consts {
public static final String V2_API_ROOT = "/v2";
public static final String V2_API_NAME = "A1 Policy Management Version 2.0 (in progress)";
- private Consts() {
- }
+ private Consts() {}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java
index 2ba63abc..988fbc2a 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ErrorResponse.java
@@ -35,7 +35,7 @@ import reactor.core.publisher.Mono;
class ErrorResponse {
private static Gson gson = new GsonBuilder() //
- .create(); //
+ .create(); //
// Returned as body for all failed REST calls
@ApiModel(value = "error_information", description = "Problem as defined in https://tools.ietf.org/html/rfc7807")
@@ -60,16 +60,14 @@ class ErrorResponse {
this.status = status;
}
- @ApiModelProperty(
- example = "503",
- value = "The HTTP status code generated by the origin server for this occurrence of the problem. ")
+ @ApiModelProperty(example = "503",
+ value = "The HTTP status code generated by the origin server for this occurrence of the problem. ")
public Integer getStatus() {
return status;
}
- @ApiModelProperty(
- example = "Policy type not found",
- value = " A human-readable explanation specific to this occurrence of the problem.")
+ @ApiModelProperty(example = "Policy type not found",
+ value = " A human-readable explanation specific to this occurrence of the problem.")
public String getDetail() {
return this.detail;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java
index 22227656..fea1d097 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java
@@ -25,8 +25,7 @@ import io.swagger.annotations.ApiModel;
import org.immutables.gson.Gson;
@Gson.TypeAdapters
-@ApiModel(
- value = "json_object",
- description = "A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.")
+@ApiModel(value = "json_object",
+ description = "A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.")
class JsonObject {
}
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 d42d51e9..8d3ecf6c 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
@@ -94,26 +94,21 @@ public class PolicyController {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
@GetMapping(path = Consts.V2_API_ROOT + "/policy-schemas", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns policy type schema definitions")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy schemas", response = PolicySchemaList.class), //
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicySchemas( //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of the Near-RT RIC to get the definitions for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId,
- @ApiParam(
- name = Consts.POLICY_TYPE_ID_PARAM,
- required = true,
- value = "The identity of the policy type to get the definition for. When this parameter is given, max one schema will be returned") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId) {
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of the Near-RT RIC to get the definitions for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId,
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = true,
+ value = "The identity of the policy type to get the definition for. When this parameter is given, max one schema will be returned") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId) {
try {
Ric ric = ricId == null ? null : rics.getRic(ricId);
if (ric == null && policyTypeId == null) {
@@ -146,15 +141,12 @@ public class PolicyController {
@GetMapping(path = Consts.V2_API_ROOT + "/policy-types", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Query policy type identities", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiResponses(
- value = {@ApiResponse(code = 200, message = "Policy type IDs", response = PolicyTypeIdList.class),
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "Policy type IDs", response = PolicyTypeIdList.class),
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicyTypes( //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of the Near-RT RIC to get types for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of the Near-RT RIC to get types for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
if (ricId == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
return new ResponseEntity<>(toPolicyTypeIdsJson(types), HttpStatus.OK);
@@ -170,14 +162,13 @@ public class PolicyController {
@GetMapping(path = Consts.V2_API_ROOT + "/policy", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns a policy configuration") //
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy found", response = JsonObject.class), //
@ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class)} //
)
public ResponseEntity<Object> getPolicy( //
- @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) {
+ @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) {
try {
Policy p = policies.getPolicy(id);
return new ResponseEntity<>(p.json(), HttpStatus.OK);
@@ -188,31 +179,28 @@ public class PolicyController {
@DeleteMapping(Consts.V2_API_ROOT + "/policy")
@ApiOperation(value = "Delete a policy")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 204, message = "Policy deleted", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class),
- @ApiResponse(
- code = 423,
- message = "Near-RT RIC is not operational",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 423, message = "Near-RT RIC is not operational",
+ response = ErrorResponse.ErrorInfo.class)})
public Mono<ResponseEntity<Object>> deletePolicy( //
- @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) {
+ @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String id) {
try {
Policy policy = policies.getPolicy(id);
keepServiceAlive(policy.ownerServiceId());
Ric ric = policy.ric();
return ric.getLock().lock(LockType.SHARED) //
- .flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
- .doOnNext(notUsed -> policies.remove(policy)) //
- .flatMap(client -> client.deletePolicy(policy)) //
- .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
- .doOnError(notUsed -> ric.getLock().unlockBlocking()) //
- .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
- .onErrorResume(this::handleException);
+ .flatMap(notUsed -> assertRicStateIdle(ric)) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) //
+ .doOnNext(notUsed -> policies.remove(policy)) //
+ .flatMap(client -> client.deletePolicy(policy)) //
+ .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
+ .doOnError(notUsed -> ric.getLock().unlockBlocking()) //
+ .flatMap(notUsed -> Mono.just(new ResponseEntity<>(HttpStatus.NO_CONTENT)))
+ .onErrorResume(this::handleException);
} catch (ServiceException e) {
return ErrorResponse.createMono(e, HttpStatus.NOT_FOUND);
}
@@ -220,43 +208,33 @@ public class PolicyController {
@PutMapping(path = Consts.V2_API_ROOT + "/policy", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Create or update a policy")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 201, message = "Policy created", response = VoidResponse.class), //
@ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), //
- @ApiResponse(
- code = 423,
- message = "Near-RT RIC is not operational",
- response = ErrorResponse.ErrorInfo.class), //
- @ApiResponse(
- code = 404,
- message = "Near-RT RIC or policy type is not found",
- response = ErrorResponse.ErrorInfo.class) //
- })
+ @ApiResponse(code = 423, message = "Near-RT RIC is not operational",
+ response = ErrorResponse.ErrorInfo.class), //
+ @ApiResponse(code = 404, message = "Near-RT RIC or policy type is not found",
+ response = ErrorResponse.ErrorInfo.class) //
+ })
public Mono<ResponseEntity<Object>> putPolicy( //
- @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, value = "The identity of the policy type.") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, defaultValue = "") String policyTypeId, //
- @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
- @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String instanceId, //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = true,
- value = "The identity of the Near-RT RIC where the policy will be " + //
- "created.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = true) String ricId, //
- @ApiParam(
- name = Consts.SERVICE_ID_PARAM,
- required = true,
- value = "The identity of the service creating the policy.") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceId, //
- @ApiParam(
- name = Consts.TRANSIENT_PARAM,
- required = false,
- value = "If the policy is transient or not (boolean " + //
- "defaulted to false). A policy is transient if it will not be recreated in the Near-RT RIC " + //
- "when it has been lost (for instance due to a restart)") //
- @RequestParam(name = Consts.TRANSIENT_PARAM, required = false, defaultValue = "false") boolean isTransient, //
- @RequestBody Object jsonBody) {
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, value = "The identity of the policy type.") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, defaultValue = "") String policyTypeId, //
+ @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy instance.") //
+ @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String instanceId, //
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = true,
+ value = "The identity of the Near-RT RIC where the policy will be " + //
+ "created.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = true) String ricId, //
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true,
+ value = "The identity of the service creating the policy.") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceId, //
+ @ApiParam(name = Consts.TRANSIENT_PARAM, required = false,
+ value = "If the policy is transient or not (boolean " + //
+ "defaulted to false). A policy is transient if it will not be recreated in the Near-RT RIC "
+ + //
+ "when it has been lost (for instance due to a restart)") //
+ @RequestParam(name = Consts.TRANSIENT_PARAM, required = false, defaultValue = "false") boolean isTransient, //
+ @RequestBody Object jsonBody) {
String jsonString = gson.toJson(jsonBody);
Ric ric = rics.get(ricId);
@@ -266,28 +244,28 @@ public class PolicyController {
return ErrorResponse.createMono("Near-RT RIC or policy type not found", HttpStatus.NOT_FOUND);
}
Policy policy = ImmutablePolicy.builder() //
- .id(instanceId) //
- .json(jsonString) //
- .type(type) //
- .ric(ric) //
- .ownerServiceId(serviceId) //
- .lastModified(Instant.now()) //
- .isTransient(isTransient) //
- .build();
+ .id(instanceId) //
+ .json(jsonString) //
+ .type(type) //
+ .ric(ric) //
+ .ownerServiceId(serviceId) //
+ .lastModified(Instant.now()) //
+ .isTransient(isTransient) //
+ .build();
final boolean isCreate = this.policies.get(policy.id()) == null;
return ric.getLock().lock(LockType.SHARED) //
- .flatMap(notUsed -> assertRicStateIdle(ric)) //
- .flatMap(notUsed -> checkSupportedType(ric, type)) //
- .flatMap(notUsed -> validateModifiedPolicy(policy)) //
- .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) //
- .flatMap(client -> client.putPolicy(policy)) //
- .doOnNext(notUsed -> policies.put(policy)) //
- .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
- .doOnError(trowable -> ric.getLock().unlockBlocking()) //
- .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) //
- .onErrorResume(this::handleException);
+ .flatMap(notUsed -> assertRicStateIdle(ric)) //
+ .flatMap(notUsed -> checkSupportedType(ric, type)) //
+ .flatMap(notUsed -> validateModifiedPolicy(policy)) //
+ .flatMap(notUsed -> a1ClientFactory.createA1Client(ric)) //
+ .flatMap(client -> client.putPolicy(policy)) //
+ .doOnNext(notUsed -> policies.put(policy)) //
+ .doOnNext(notUsed -> ric.getLock().unlockBlocking()) //
+ .doOnError(trowable -> ric.getLock().unlockBlocking()) //
+ .flatMap(notUsed -> Mono.just(new ResponseEntity<>(isCreate ? HttpStatus.CREATED : HttpStatus.OK))) //
+ .onErrorResume(this::handleException);
}
private Mono<ResponseEntity<Object>> handleException(Throwable throwable) {
@@ -307,8 +285,8 @@ public class PolicyController {
Policy current = this.policies.get(policy.id());
if (current != null && !current.ric().id().equals(policy.ric().id())) {
RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + //
- ", RIC ID: " + current.ric().id() + //
- ", new ID: " + policy.ric().id(), HttpStatus.CONFLICT);
+ ", RIC ID: " + current.ric().id() + //
+ ", new ID: " + policy.ric().id(), HttpStatus.CONFLICT);
logger.debug("Request rejected, {}", e.getMessage());
return Mono.error(e);
}
@@ -319,7 +297,7 @@ public class PolicyController {
if (!ric.isSupportingType(type.id())) {
logger.debug("Request rejected, type not supported, RIC: {}", ric);
RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(),
- HttpStatus.NOT_FOUND);
+ HttpStatus.NOT_FOUND);
return Mono.error(e);
}
return Mono.just("{}");
@@ -337,40 +315,32 @@ public class PolicyController {
} else {
logger.debug("Request rejected Near-RT RIC not IDLE, ric: {}", ric);
RejectionException e = new RejectionException(
- "Near-RT RIC: is not operational, id: " + ric.id() + ", state: " + ric.getState(), HttpStatus.LOCKED);
+ "Near-RT RIC: is not operational, id: " + ric.id() + ", state: " + ric.getState(),
+ HttpStatus.LOCKED);
return Mono.error(e);
}
}
static final String GET_POLICIES_QUERY_DETAILS =
- "Returns a list of A1 policies matching given search criteria. <br>" //
- + "If several query parameters are defined, the policies matching all conditions are returned.";
+ "Returns a list of A1 policies matching given search criteria. <br>" //
+ + "If several query parameters are defined, the policies matching all conditions are returned.";
@GetMapping(path = Consts.V2_API_ROOT + "/policies", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Query for existing A1 policies", notes = GET_POLICIES_QUERY_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policies", response = PolicyInfoList.class),
- @ApiResponse(
- code = 404,
- message = "Near-RT RIC, policy type or service not found",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 404, message = "Near-RT RIC, policy type or service not found",
+ response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicies( //
- @ApiParam(
- name = Consts.POLICY_TYPE_ID_PARAM,
- required = false,
- value = "The identity of the policy type to get policies for.") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String type, //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of the Near-RT RIC to get policies for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ric, //
- @ApiParam(
- name = Consts.SERVICE_ID_PARAM,
- required = false,
- value = "The identity of the service to get policies for.") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String service) //
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false,
+ value = "The identity of the policy type to get policies for.") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String type, //
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of the Near-RT RIC to get policies for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ric, //
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false,
+ value = "The identity of the service to get policies for.") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String service) //
{
if ((type != null && this.policyTypes.get(type) == null)) {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
@@ -385,29 +355,19 @@ public class PolicyController {
@GetMapping(path = Consts.V2_API_ROOT + "/policy-ids", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Query policies, only policy identities are returned", notes = GET_POLICIES_QUERY_DETAILS)
- @ApiResponses(
- value = { //
- @ApiResponse(code = 200, message = "Policy identities", response = PolicyIdList.class),
- @ApiResponse(
- code = 404,
- message = "Near-RT RIC or type not found",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponses(value = { //
+ @ApiResponse(code = 200, message = "Policy identities", response = PolicyIdList.class), @ApiResponse(
+ code = 404, message = "Near-RT RIC or type not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicyIds( //
- @ApiParam(
- name = Consts.POLICY_TYPE_ID_PARAM,
- required = false,
- value = "The identity of the policy type to get policies for.") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId, //
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of the Near-RT RIC to get policies for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, //
- @ApiParam(
- name = Consts.SERVICE_ID_PARAM,
- required = false,
- value = "The identity of the service to get policies for.") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String serviceId) //
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false,
+ value = "The identity of the policy type to get policies for.") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String policyTypeId, //
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of the Near-RT RIC to get policies for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId, //
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false,
+ value = "The identity of the service to get policies for.") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String serviceId) //
{
if ((policyTypeId != null && this.policyTypes.get(policyTypeId) == null)) {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
@@ -422,21 +382,20 @@ public class PolicyController {
@GetMapping(path = Consts.V2_API_ROOT + "/policy-status", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns a policy status") //
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Policy status", response = JsonObject.class), //
@ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class)} //
)
public Mono<ResponseEntity<Object>> getPolicyStatus( //
- @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy.") //
- @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String policyId) {
+ @ApiParam(name = Consts.POLICY_ID_PARAM, required = true, value = "The identity of the policy.") //
+ @RequestParam(name = Consts.POLICY_ID_PARAM, required = true) String policyId) {
try {
Policy policy = policies.getPolicy(policyId);
return a1ClientFactory.createA1Client(policy.ric()) //
- .flatMap(client -> client.getPolicyStatus(policy)) //
- .flatMap(status -> Mono.just(new ResponseEntity<>((Object) status, HttpStatus.OK)))
- .onErrorResume(this::handleException);
+ .flatMap(client -> client.getPolicyStatus(policy)) //
+ .flatMap(status -> Mono.just(new ResponseEntity<>((Object) status, HttpStatus.OK)))
+ .onErrorResume(this::handleException);
} catch (ServiceException e) {
return ErrorResponse.createMono(e, HttpStatus.NOT_FOUND);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
index 673c9455..ab812790 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
@@ -62,12 +62,11 @@ public class PolicyInfo {
@JsonProperty("last_modified")
public String lastModified;
- PolicyInfo() {
- }
+ PolicyInfo() {}
public boolean validate() {
return policyId != null && policyTypeId != null && ricId != null && policyData != null && serviceId != null
- && lastModified != null;
+ && lastModified != null;
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java
index 6768b76a..d550db4e 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java
@@ -38,7 +38,7 @@ import org.immutables.gson.Gson;
public class PolicySchemaList {
@ApiModelProperty(
- value = "Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema")
+ value = "Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema")
@SerializedName("policy_schemas")
@JsonProperty("policy_schemas")
public final Collection<Object> schemas;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java
index 750f0dfb..938d5106 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java
@@ -41,10 +41,10 @@ public class RicInfo {
}
private static final String STATE_DESCRIPTION = "State for the Near-RT RIC, values: \n"
- + "UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent \n"
- + "AVAILABLE: The normal state. Policies can be configured. +\n"
- + "SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured. \n"
- + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured.";
+ + "UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent \n"
+ + "AVAILABLE: The normal state. Policies can be configured. +\n"
+ + "SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured. \n"
+ + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured.";
@ApiModelProperty(value = "identity of the Near-RT RIC")
@SerializedName("ric_id")
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
index cc8a8e92..a7505016 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java
@@ -56,35 +56,30 @@ public class RicRepositoryController {
PolicyTypes types;
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
private static final String GET_RIC_BRIEF = "Returns info for a Near-RT RIC";
private static final String GET_RIC_DETAILS =
- "Either a Near-RT RIC identity or a Mananged Element identity can be specified.<br>" //
- + "The intention with Mananged Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).";
+ "Either a Near-RT RIC identity or a Mananged Element identity can be specified.<br>" //
+ + "The intention with Mananged Element identity is the ID used in O1 for accessing the traffical element (such as the ID of CU).";
/**
* Example: http://localhost:8081/v2/ric?managed_element_id=kista_1
*/
@GetMapping(path = Consts.V2_API_ROOT + "/ric", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = GET_RIC_BRIEF, notes = GET_RIC_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Near-RT RIC is found", response = RicInfo.class), //
@ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class) //
- })
+ })
public ResponseEntity<Object> getRic( //
- @ApiParam(
- name = Consts.MANAGED_ELEMENT_ID_PARAM,
- required = false,
- value = "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.") //
- @RequestParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false) String managedElementId,
- @ApiParam(
- name = Consts.RIC_ID_PARAM,
- required = false,
- value = "The identity of a Near-RT RIC to get information for.") //
- @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
+ @ApiParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false,
+ value = "The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.") //
+ @RequestParam(name = Consts.MANAGED_ELEMENT_ID_PARAM, required = false) String managedElementId,
+ @ApiParam(name = Consts.RIC_ID_PARAM, required = false,
+ value = "The identity of a Near-RT RIC to get information for.") //
+ @RequestParam(name = Consts.RIC_ID_PARAM, required = false) String ricId) {
try {
if (managedElementId != null && ricId != null) {
return ErrorResponse.create("Give one query parameter", HttpStatus.BAD_REQUEST);
@@ -107,23 +102,20 @@ public class RicRepositoryController {
}
static final String QUERY_RIC_INFO_DETAILS =
- "The call returns all Near-RT RICs that supports a given policy type identity";
+ "The call returns all Near-RT RICs that supports a given policy type identity";
/**
* @return a Json array of all RIC data Example: http://localhost:8081/v2/ric
*/
@GetMapping(path = Consts.V2_API_ROOT + "/rics", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Query Near-RT RIC information", notes = QUERY_RIC_INFO_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "OK", response = RicInfoList.class), //
@ApiResponse(code = 404, message = "Policy type is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getRics( //
- @ApiParam(
- name = Consts.POLICY_TYPE_ID_PARAM,
- required = false,
- value = "The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned") //
- @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String supportingPolicyType) {
+ @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false,
+ value = "The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned") //
+ @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String supportingPolicyType) {
if ((supportingPolicyType != null) && (this.types.get(supportingPolicyType) == null)) {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
}
@@ -155,6 +147,6 @@ public class RicRepositoryController {
private RicInfo toRicInfo(Ric ric) {
return new RicInfo(ric.id(), ric.getManagedElementIds(), ric.getSupportedPolicyTypeNames(),
- toRicState(ric.getState()));
+ toRicState(ric.getState()));
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
index 383e4f7f..73e421be 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
@@ -60,7 +60,7 @@ public class ServiceController {
private final Policies policies;
private static Gson gson = new GsonBuilder() //
- .create(); //
+ .create(); //
@Autowired
ServiceController(Services services, Policies policies) {
@@ -69,17 +69,16 @@ public class ServiceController {
}
private static final String GET_SERVICE_DETAILS =
- "Either information about a registered service with given identity or all registered services are returned.";
+ "Either information about a registered service with given identity or all registered services are returned.";
@GetMapping(path = Consts.V2_API_ROOT + "/services", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns service information", notes = GET_SERVICE_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "OK", response = ServiceStatusList.class), //
@ApiResponse(code = 404, message = "Service is not found", response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getServices(//
- @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, value = "The identity of the service") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String name) {
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = false, value = "The identity of the service") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = false) String name) {
if (name != null && this.services.get(name) == null) {
return ErrorResponse.create("Service not found", HttpStatus.NOT_FOUND);
}
@@ -97,11 +96,11 @@ public class ServiceController {
private ServiceStatus toServiceStatus(Service s) {
return new ServiceStatus(s.getName(), s.getKeepAliveInterval().toSeconds(), s.timeSinceLastPing().toSeconds(),
- s.getCallbackUrl());
+ s.getCallbackUrl());
}
private void validateRegistrationInfo(ServiceRegistrationInfo registrationInfo)
- throws ServiceException, MalformedURLException {
+ throws ServiceException, MalformedURLException {
if (registrationInfo.serviceId.isEmpty()) {
throw new ServiceException("Missing mandatory parameter 'serviceName'");
}
@@ -114,24 +113,21 @@ public class ServiceController {
}
private static final String REGISTER_SERVICE_DETAILS = "Registering a service is needed to:" //
- + "<ul>" //
- + "<li>Get callbacks.</li>" //
- + "<li>Activate supervision of the service. If a service is inactive, its policies will be deleted.</li>"//
- + "</ul>" //
+ + "<ul>" //
+ + "<li>Get callbacks.</li>" //
+ + "<li>Activate supervision of the service. If a service is inactive, its policies will be deleted.</li>"//
+ + "</ul>" //
;
@ApiOperation(value = "Register a service", notes = REGISTER_SERVICE_DETAILS)
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service updated"),
@ApiResponse(code = 201, message = "Service created"), //
- @ApiResponse(
- code = 400,
- message = "The ServiceRegistrationInfo is not accepted",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 400, message = "The ServiceRegistrationInfo is not accepted",
+ response = ErrorResponse.ErrorInfo.class)})
@PutMapping(Consts.V2_API_ROOT + "/services")
public ResponseEntity<Object> putService(//
- @RequestBody ServiceRegistrationInfo registrationInfo) {
+ @RequestBody ServiceRegistrationInfo registrationInfo) {
try {
validateRegistrationInfo(registrationInfo);
final boolean isCreate = this.services.get(registrationInfo.serviceId) == null;
@@ -143,15 +139,14 @@ public class ServiceController {
}
@ApiOperation(value = "Unregister a service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 204, message = "Service unregistered"),
@ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
@ApiResponse(code = 404, message = "Service not found", response = ErrorResponse.ErrorInfo.class)})
@DeleteMapping(Consts.V2_API_ROOT + "/services")
public ResponseEntity<Object> deleteService(//
- @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The idenitity of the service") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The idenitity of the service") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
try {
Service service = removeService(serviceName);
// Remove the policies from the repo and let the consistency monitoring
@@ -164,18 +159,15 @@ public class ServiceController {
}
@ApiOperation(value = "Heartbeat indicates that the service is running")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service supervision timer refreshed, OK"), //
- @ApiResponse(
- code = 404,
- message = "The service is not found, needs re-registration",
- response = ErrorResponse.ErrorInfo.class)})
+ @ApiResponse(code = 404, message = "The service is not found, needs re-registration",
+ response = ErrorResponse.ErrorInfo.class)})
@PutMapping(Consts.V2_API_ROOT + "/services/keepalive")
public ResponseEntity<Object> keepAliveService(//
- @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The identity of the service") //
- @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
+ @ApiParam(name = Consts.SERVICE_ID_PARAM, required = true, value = "The identity of the service") //
+ @RequestParam(name = Consts.SERVICE_ID_PARAM, required = true) String serviceName) {
try {
services.getService(serviceName).keepAlive();
return new ResponseEntity<>(HttpStatus.OK);
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
index 30fcb7d6..68afc384 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
@@ -37,8 +37,7 @@ public class ServiceRegistrationInfo {
@JsonProperty("service_id")
public String serviceId = "";
- @ApiModelProperty(
- value = "keep alive interval for the service. This is a heartbeat supervision of the service, "
+ @ApiModelProperty(value = "keep alive interval for the service. This is a heartbeat supervision of the service, "
+ "which in regular intevals must invoke a 'keepAlive' REST call. "
+ "When a service does not invoke this call within the given time, it is considered unavailble. "
+ "An unavailable service will be automatically deregistered and its policies will be deleted. "
@@ -52,8 +51,7 @@ public class ServiceRegistrationInfo {
@JsonProperty("callback_url")
public String callbackUrl = "";
- public ServiceRegistrationInfo() {
- }
+ public ServiceRegistrationInfo() {}
public ServiceRegistrationInfo(String id, long keepAliveIntervalSeconds, String callbackUrl) {
this.serviceId = id;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
index f47cdd5c..1c5a473b 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
@@ -52,10 +52,9 @@ public class StatusController {
@GetMapping(path = Consts.V2_API_ROOT + "/status", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Returns status and statistics of this service")
- @ApiResponses(
- value = { //
+ @ApiResponses(value = { //
@ApiResponse(code = 200, message = "Service is living", response = StatusInfo.class) //
- })
+ })
public Mono<ResponseEntity<Object>> getStatus() {
StatusInfo info = new StatusInfo("hunky dory");
return Mono.just(new ResponseEntity<>(info, HttpStatus.OK));
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java
index a4da4bdd..bafa8453 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumer.java
@@ -123,7 +123,7 @@ public class DmaapMessageConsumer {
String producerTopicUrl = applicationConfig.getDmaapProducerTopicUrl();
String consumerTopicUrl = applicationConfig.getDmaapConsumerTopicUrl();
return (producerTopicUrl != null && consumerTopicUrl != null && !producerTopicUrl.isEmpty()
- && !consumerTopicUrl.isEmpty());
+ && !consumerTopicUrl.isEmpty());
}
private <T> List<T> parseList(String jsonString, Class<T> clazz) {
@@ -144,16 +144,16 @@ public class DmaapMessageConsumer {
private void sendErrorResponse(String response) {
DmaapRequestMessage fakeRequest = ImmutableDmaapRequestMessage.builder() //
- .apiVersion("") //
- .correlationId("") //
- .operation(DmaapRequestMessage.Operation.PUT) //
- .originatorId("") //
- .payload(Optional.empty()) //
- .requestId("") //
- .target("") //
- .timestamp("") //
- .url("URL") //
- .build();
+ .apiVersion("") //
+ .correlationId("") //
+ .operation(DmaapRequestMessage.Operation.PUT) //
+ .originatorId("") //
+ .payload(Optional.empty()) //
+ .requestId("") //
+ .target("") //
+ .timestamp("") //
+ .url("URL") //
+ .build();
getDmaapMessageHandler().sendDmaapResponse(response, fakeRequest, HttpStatus.BAD_REQUEST).block();
}
@@ -175,7 +175,7 @@ public class DmaapMessageConsumer {
return parseMessages(response.getBody());
} else {
throw new ServiceException("Cannot fetch because of Error respons: " + response.getStatusCode().toString()
- + " " + response.getBody());
+ + " " + response.getBody());
}
}
@@ -189,7 +189,7 @@ public class DmaapMessageConsumer {
String pmsBaseUrl = "http://localhost:" + this.localServerHttpPort;
AsyncRestClient pmsClient = new AsyncRestClient(pmsBaseUrl, this.applicationConfig.getWebClientConfig());
AsyncRestClient producer = new AsyncRestClient(this.applicationConfig.getDmaapProducerTopicUrl(),
- this.applicationConfig.getWebClientConfig());
+ this.applicationConfig.getWebClientConfig());
this.dmaapMessageHandler = new DmaapMessageHandler(producer, pmsClient);
}
return this.dmaapMessageHandler;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java
index 2d7b5063..967cab1d 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandler.java
@@ -65,12 +65,13 @@ public class DmaapMessageHandler {
Mono<String> createTask(DmaapRequestMessage dmaapRequestMessage) {
return this.invokePolicyManagementService(dmaapRequestMessage) //
- .onErrorResume(t -> handlePolicyManagementServiceCallError(t, dmaapRequestMessage)) //
- .flatMap(response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage, response.getStatusCode()));
+ .onErrorResume(t -> handlePolicyManagementServiceCallError(t, dmaapRequestMessage)) //
+ .flatMap(response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage,
+ response.getStatusCode()));
}
private Mono<ResponseEntity<String>> handlePolicyManagementServiceCallError(Throwable error,
- DmaapRequestMessage dmaapRequestMessage) {
+ DmaapRequestMessage dmaapRequestMessage) {
logger.debug("Policy Management Service call failed: {}", error.getMessage());
HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
String errorMessage = error.getMessage();
@@ -85,13 +86,13 @@ public class DmaapMessageHandler {
logger.warn("Unexpected exception ", error);
}
return sendDmaapResponse(errorMessage, dmaapRequestMessage, status) //
- .flatMap(notUsed -> Mono.empty());
+ .flatMap(notUsed -> Mono.empty());
}
public Mono<String> sendDmaapResponse(String response, DmaapRequestMessage dmaapRequestMessage, HttpStatus status) {
return createDmaapResponseMessage(dmaapRequestMessage, response, status) //
- .flatMap(this::sendToDmaap) //
- .onErrorResume(this::handleResponseCallError);
+ .flatMap(this::sendToDmaap) //
+ .onErrorResume(this::handleResponseCallError);
}
private Mono<ResponseEntity<String>> invokePolicyManagementService(DmaapRequestMessage dmaapRequestMessage) {
@@ -132,16 +133,16 @@ public class DmaapMessageHandler {
}
private Mono<String> createDmaapResponseMessage(DmaapRequestMessage dmaapRequestMessage, String response,
- HttpStatus status) {
+ HttpStatus status) {
DmaapResponseMessage dmaapResponseMessage = ImmutableDmaapResponseMessage.builder() //
- .status(status.toString()) //
- .message(response == null ? "" : response) //
- .type("response") //
- .correlationId(dmaapRequestMessage.correlationId() == null ? "" : dmaapRequestMessage.correlationId()) //
- .originatorId(dmaapRequestMessage.originatorId() == null ? "" : dmaapRequestMessage.originatorId()) //
- .requestId(dmaapRequestMessage.requestId() == null ? "" : dmaapRequestMessage.requestId()) //
- .timestamp(dmaapRequestMessage.timestamp() == null ? "" : dmaapRequestMessage.timestamp()) //
- .build();
+ .status(status.toString()) //
+ .message(response == null ? "" : response) //
+ .type("response") //
+ .correlationId(dmaapRequestMessage.correlationId() == null ? "" : dmaapRequestMessage.correlationId()) //
+ .originatorId(dmaapRequestMessage.originatorId() == null ? "" : dmaapRequestMessage.originatorId()) //
+ .requestId(dmaapRequestMessage.requestId() == null ? "" : dmaapRequestMessage.requestId()) //
+ .timestamp(dmaapRequestMessage.timestamp() == null ? "" : dmaapRequestMessage.timestamp()) //
+ .build();
String str = gson.toJson(dmaapResponseMessage);
return Mono.just(str);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java
index 0cde2e12..6892a503 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Lock.java
@@ -87,7 +87,7 @@ public class Lock {
@Override
public synchronized String toString() {
return "Lock cnt: " + this.lockCounter + " exclusive: " + this.isExclusive + " queued: "
- + this.lockRequestQueue.size();
+ + this.lockRequestQueue.size();
}
/** returns the current number of granted locks */
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
index 05ba41da..c7f471eb 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
@@ -134,7 +134,7 @@ public class Ric {
@Override
public synchronized String toString() {
return Ric.class.getSimpleName() + ": " + "name: " + id() + ", state: " + state + ", baseUrl: "
- + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds();
+ + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds();
}
/**
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java
index 840de817..ba81d222 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessor.java
@@ -39,19 +39,18 @@ class EnvironmentProcessor {
private static final int DEFAULT_CONSUL_PORT = 8500;
private static final Logger logger = LoggerFactory.getLogger(EnvironmentProcessor.class);
- private EnvironmentProcessor() {
- }
+ private EnvironmentProcessor() {}
static Mono<EnvProperties> readEnvironmentVariables(Properties systemEnvironment) {
EnvProperties envProperties;
try {
envProperties = ImmutableEnvProperties.builder() //
- .consulHost(getConsulHost(systemEnvironment)) //
- .consulPort(getConsultPort(systemEnvironment)) //
- .cbsName(getConfigBindingService(systemEnvironment)) //
- .appName(getService(systemEnvironment)) //
- .build();
+ .consulHost(getConsulHost(systemEnvironment)) //
+ .consulPort(getConsultPort(systemEnvironment)) //
+ .cbsName(getConfigBindingService(systemEnvironment)) //
+ .appName(getService(systemEnvironment)) //
+ .build();
} catch (EnvironmentLoaderException e) {
return Mono.error(e);
}
@@ -61,27 +60,27 @@ class EnvironmentProcessor {
private static String getConsulHost(Properties systemEnvironments) throws EnvironmentLoaderException {
return Optional.ofNullable(systemEnvironments.getProperty("CONSUL_HOST"))
- .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined"));
+ .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined"));
}
private static Integer getConsultPort(Properties systemEnvironments) {
return Optional.ofNullable(systemEnvironments.getProperty("CONSUL_PORT")) //
- .map(Integer::valueOf) //
- .orElseGet(EnvironmentProcessor::getDefaultPortOfConsul);
+ .map(Integer::valueOf) //
+ .orElseGet(EnvironmentProcessor::getDefaultPortOfConsul);
}
private static String getConfigBindingService(Properties systemEnvironments) throws EnvironmentLoaderException {
return Optional.ofNullable(systemEnvironments.getProperty("CONFIG_BINDING_SERVICE")) //
- .orElseThrow(
- () -> new EnvironmentLoaderException("$CONFIG_BINDING_SERVICE environment has not been defined"));
+ .orElseThrow(() -> new EnvironmentLoaderException(
+ "$CONFIG_BINDING_SERVICE environment has not been defined"));
}
private static String getService(Properties systemEnvironments) throws EnvironmentLoaderException {
return Optional
- .ofNullable(Optional.ofNullable(systemEnvironments.getProperty("HOSTNAME"))
- .orElse(systemEnvironments.getProperty("SERVICE_NAME")))
- .orElseThrow(() -> new EnvironmentLoaderException(
- "Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment"));
+ .ofNullable(Optional.ofNullable(systemEnvironments.getProperty("HOSTNAME"))
+ .orElse(systemEnvironments.getProperty("SERVICE_NAME")))
+ .orElseThrow(() -> new EnvironmentLoaderException(
+ "Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment"));
}
private static Integer getDefaultPortOfConsul() {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
index 248ba32d..5da066f3 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
@@ -94,7 +94,7 @@ public class RefreshConfigTask {
@Autowired
public RefreshConfigTask(ApplicationConfig appConfig, Rics rics, Policies policies, Services services,
- PolicyTypes policyTypes, A1ClientFactory a1ClientFactory) {
+ PolicyTypes policyTypes, A1ClientFactory a1ClientFactory) {
this.appConfig = appConfig;
this.rics = rics;
this.policies = policies;
@@ -107,9 +107,10 @@ public class RefreshConfigTask {
logger.debug("Starting refreshConfigTask");
stop();
refreshTask = createRefreshTask() //
- .subscribe(notUsed -> logger.debug("Refreshed configuration data"),
- throwable -> logger.error("Configuration refresh terminated due to exception {}", throwable.toString()),
- () -> logger.error("Configuration refresh terminated"));
+ .subscribe(
+ notUsed -> logger.debug("Refreshed configuration data"), throwable -> logger
+ .error("Configuration refresh terminated due to exception {}", throwable.toString()),
+ () -> logger.error("Configuration refresh terminated"));
}
public void stop() {
@@ -120,44 +121,44 @@ public class RefreshConfigTask {
Flux<RicConfigUpdate.Type> createRefreshTask() {
Flux<JsonObject> loadFromFile = Flux.interval(Duration.ZERO, CONFIG_REFRESH_INTERVAL) //
- .filter(notUsed -> !this.isConsulUsed) //
- .flatMap(notUsed -> loadConfigurationFromFile()) //
- .onErrorResume(this::ignoreErrorFlux) //
- .doOnNext(json -> logger.debug("loadFromFile succeeded")) //
- .doOnTerminate(() -> logger.error("loadFromFile Terminate"));
+ .filter(notUsed -> !this.isConsulUsed) //
+ .flatMap(notUsed -> loadConfigurationFromFile()) //
+ .onErrorResume(this::ignoreErrorFlux) //
+ .doOnNext(json -> logger.debug("loadFromFile succeeded")) //
+ .doOnTerminate(() -> logger.error("loadFromFile Terminate"));
Flux<JsonObject> loadFromConsul = Flux.interval(Duration.ZERO, CONFIG_REFRESH_INTERVAL) //
- .flatMap(i -> getEnvironment(systemEnvironment)) //
- .flatMap(this::createCbsClient) //
- .flatMap(this::getFromCbs) //
- .onErrorResume(this::ignoreErrorMono) //
- .doOnNext(json -> logger.debug("loadFromConsul succeeded")) //
- .doOnNext(json -> this.isConsulUsed = true) //
- .doOnTerminate(() -> logger.error("loadFromConsul Terminated"));
+ .flatMap(i -> getEnvironment(systemEnvironment)) //
+ .flatMap(this::createCbsClient) //
+ .flatMap(this::getFromCbs) //
+ .onErrorResume(this::ignoreErrorMono) //
+ .doOnNext(json -> logger.debug("loadFromConsul succeeded")) //
+ .doOnNext(json -> this.isConsulUsed = true) //
+ .doOnTerminate(() -> logger.error("loadFromConsul Terminated"));
return Flux.merge(loadFromFile, loadFromConsul) //
- .flatMap(this::parseConfiguration) //
- .flatMap(this::updateConfig) //
- .doOnNext(this::handleUpdatedRicConfig) //
- .flatMap(configUpdate -> Flux.just(configUpdate.getType())) //
- .doOnTerminate(() -> logger.error("Configuration refresh task is terminated"));
+ .flatMap(this::parseConfiguration) //
+ .flatMap(this::updateConfig) //
+ .doOnNext(this::handleUpdatedRicConfig) //
+ .flatMap(configUpdate -> Flux.just(configUpdate.getType())) //
+ .doOnTerminate(() -> logger.error("Configuration refresh task is terminated"));
}
Mono<EnvProperties> getEnvironment(Properties systemEnvironment) {
return EnvironmentProcessor.readEnvironmentVariables(systemEnvironment) //
- .onErrorResume(t -> Mono.empty());
+ .onErrorResume(t -> Mono.empty());
}
Mono<CbsClient> createCbsClient(EnvProperties env) {
return CbsClientFactory.createCbsClient(env) //
- .onErrorResume(this::ignoreErrorMono);
+ .onErrorResume(this::ignoreErrorMono);
}
private Mono<JsonObject> getFromCbs(CbsClient cbsClient) {
try {
final CbsRequest getConfigRequest = CbsRequests.getAll(RequestDiagnosticContext.create());
return cbsClient.get(getConfigRequest) //
- .onErrorResume(this::ignoreErrorMono);
+ .onErrorResume(this::ignoreErrorMono);
} catch (Exception e) {
return ignoreErrorMono(e);
}
@@ -223,7 +224,7 @@ public class RefreshConfigTask {
void runRicSynchronization(Ric ric) {
RicSynchronizationTask synchronizationTask =
- new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services);
+ new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services);
synchronizationTask.run(ric);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
index 332af8bc..46059fd9 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
@@ -83,7 +83,7 @@ public class RicSupervision {
@Autowired
public RicSupervision(Rics rics, Policies policies, A1ClientFactory a1ClientFactory, PolicyTypes policyTypes,
- Services services) {
+ Services services) {
this.rics = rics;
this.policies = policies;
this.a1ClientFactory = a1ClientFactory;
@@ -102,19 +102,19 @@ public class RicSupervision {
private Flux<RicData> createTask() {
return Flux.fromIterable(rics.getRics()) //
- .flatMap(this::createRicData) //
- .flatMap(this::checkOneRic);
+ .flatMap(this::createRicData) //
+ .flatMap(this::checkOneRic);
}
private Mono<RicData> checkOneRic(RicData ricData) {
return checkRicState(ricData) //
- .flatMap(x -> ricData.ric.getLock().lock(LockType.EXCLUSIVE)) //
- .flatMap(notUsed -> setRicState(ricData)) //
- .flatMap(x -> checkRicPolicies(ricData)) //
- .flatMap(x -> checkRicPolicyTypes(ricData)) //
- .doOnNext(x -> onRicCheckedOk(ricData)) //
- .doOnError(t -> onRicCheckedError(t, ricData)) //
- .onErrorResume(throwable -> Mono.empty());
+ .flatMap(x -> ricData.ric.getLock().lock(LockType.EXCLUSIVE)) //
+ .flatMap(notUsed -> setRicState(ricData)) //
+ .flatMap(x -> checkRicPolicies(ricData)) //
+ .flatMap(x -> checkRicPolicyTypes(ricData)) //
+ .doOnNext(x -> onRicCheckedOk(ricData)) //
+ .doOnError(t -> onRicCheckedError(t, ricData)) //
+ .onErrorResume(throwable -> Mono.empty());
}
private void onRicCheckedError(Throwable t, RicData ricData) {
@@ -148,14 +148,14 @@ public class RicSupervision {
private Mono<RicData> createRicData(Ric ric) {
return Mono.just(ric) //
- .flatMap(aRic -> this.a1ClientFactory.createA1Client(ric)) //
- .flatMap(a1Client -> Mono.just(new RicData(ric, a1Client)));
+ .flatMap(aRic -> this.a1ClientFactory.createA1Client(ric)) //
+ .flatMap(a1Client -> Mono.just(new RicData(ric, a1Client)));
}
private Mono<RicData> checkRicState(RicData ric) {
if (ric.ric.getState() == RicState.UNAVAILABLE) {
return startSynchronization(ric) //
- .onErrorResume(t -> Mono.empty());
+ .onErrorResume(t -> Mono.empty());
} else if (ric.ric.getState() == RicState.SYNCHRONIZING || ric.ric.getState() == RicState.CONSISTENCY_CHECK) {
return Mono.empty();
} else {
@@ -165,7 +165,7 @@ public class RicSupervision {
private Mono<RicData> checkRicPolicies(RicData ric) {
return ric.getClient().getPolicyIdentities() //
- .flatMap(ricP -> validateInstances(ricP, ric));
+ .flatMap(ricP -> validateInstances(ricP, ric));
}
private Mono<RicData> validateInstances(Collection<String> ricPolicies, RicData ric) {
@@ -185,7 +185,7 @@ public class RicSupervision {
private Mono<RicData> checkRicPolicyTypes(RicData ric) {
return ric.getClient().getPolicyTypeIdentities() //
- .flatMap(ricTypes -> validateTypes(ricTypes, ric));
+ .flatMap(ricTypes -> validateTypes(ricTypes, ric));
}
private Mono<RicData> validateTypes(Collection<String> ricTypes, RicData ric) {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
index f810c659..ccc57852 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
@@ -66,7 +66,7 @@ public class RicSynchronizationTask {
private final Services services;
public RicSynchronizationTask(A1ClientFactory a1ClientFactory, PolicyTypes policyTypes, Policies policies,
- Services services) {
+ Services services) {
this.a1ClientFactory = a1ClientFactory;
this.policyTypes = policyTypes;
this.policies = policies;
@@ -82,27 +82,28 @@ public class RicSynchronizationTask {
}
ric.getLock().lock(LockType.EXCLUSIVE) //
- .flatMap(notUsed -> setRicState(ric)) //
- .flatMap(lock -> this.a1ClientFactory.createA1Client(ric)) //
- .flatMapMany(client -> runSynchronization(ric, client)) //
- .onErrorResume(throwable -> deleteAllPolicyInstances(ric, throwable))
- .subscribe(new BaseSubscriber<Object>() {
- @Override
- protected void hookOnError(Throwable throwable) {
- logger.warn("Synchronization failure for ric: {}, reason: {}", ric.id(), throwable.getMessage());
- ric.setState(RicState.UNAVAILABLE);
- }
-
- @Override
- protected void hookOnComplete() {
- onSynchronizationComplete(ric);
- }
-
- @Override
- protected void hookFinally(SignalType type) {
- ric.getLock().unlockBlocking();
- }
- });
+ .flatMap(notUsed -> setRicState(ric)) //
+ .flatMap(lock -> this.a1ClientFactory.createA1Client(ric)) //
+ .flatMapMany(client -> runSynchronization(ric, client)) //
+ .onErrorResume(throwable -> deleteAllPolicyInstances(ric, throwable))
+ .subscribe(new BaseSubscriber<Object>() {
+ @Override
+ protected void hookOnError(Throwable throwable) {
+ logger.warn("Synchronization failure for ric: {}, reason: {}", ric.id(),
+ throwable.getMessage());
+ ric.setState(RicState.UNAVAILABLE);
+ }
+
+ @Override
+ protected void hookOnComplete() {
+ onSynchronizationComplete(ric);
+ }
+
+ @Override
+ protected void hookFinally(SignalType type) {
+ ric.getLock().unlockBlocking();
+ }
+ });
}
@SuppressWarnings("squid:S2445") // Blocks should be synchronized on "private final" fields
@@ -136,12 +137,12 @@ public class RicSynchronizationTask {
String url = service.getCallbackUrl();
if (url.length() > 0) {
createNotificationClient(url) //
- .put("", body) //
- .subscribe( //
- notUsed -> logger.debug("Service {} notified", service.getName()),
- throwable -> logger.warn("Service notification failed for service: {}. Cause: {}",
- service.getName(), throwable.getMessage()),
- () -> logger.debug("All services notified"));
+ .put("", body) //
+ .subscribe( //
+ notUsed -> logger.debug("Service {} notified", service.getName()),
+ throwable -> logger.warn("Service notification failed for service: {}. Cause: {}",
+ service.getName(), throwable.getMessage()),
+ () -> logger.debug("All services notified"));
}
}
}
@@ -151,10 +152,10 @@ public class RicSynchronizationTask {
deleteAllPoliciesInRepository(ric);
Flux<PolicyType> synchronizedTypes = this.a1ClientFactory.createA1Client(ric) //
- .flatMapMany(a1Client -> synchronizePolicyTypes(ric, a1Client));
+ .flatMapMany(a1Client -> synchronizePolicyTypes(ric, a1Client));
Flux<?> deletePoliciesInRic = this.a1ClientFactory.createA1Client(ric) //
- .flatMapMany(A1Client::deleteAllPolicies) //
- .doOnComplete(() -> deleteAllPoliciesInRepository(ric));
+ .flatMapMany(A1Client::deleteAllPolicies) //
+ .doOnComplete(() -> deleteAllPoliciesInRepository(ric));
return Flux.concat(synchronizedTypes, deletePoliciesInRic);
}
@@ -165,11 +166,11 @@ public class RicSynchronizationTask {
private Flux<PolicyType> synchronizePolicyTypes(Ric ric, A1Client a1Client) {
return a1Client.getPolicyTypeIdentities() //
- .doOnNext(x -> ric.clearSupportedPolicyTypes()) //
- .flatMapMany(Flux::fromIterable) //
- .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().ricId(), typeId)) //
- .flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client), CONCURRENCY_RIC) //
- .doOnNext(ric::addSupportedPolicyType); //
+ .doOnNext(x -> ric.clearSupportedPolicyTypes()) //
+ .flatMapMany(Flux::fromIterable) //
+ .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().ricId(), typeId)) //
+ .flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client), CONCURRENCY_RIC) //
+ .doOnNext(ric::addSupportedPolicyType); //
}
private Mono<PolicyType> getPolicyType(String policyTypeId, A1Client a1Client) {
@@ -177,7 +178,7 @@ public class RicSynchronizationTask {
return Mono.just(policyTypes.get(policyTypeId));
}
return a1Client.getPolicyTypeSchema(policyTypeId) //
- .flatMap(schema -> createPolicyType(policyTypeId, schema));
+ .flatMap(schema -> createPolicyType(policyTypeId, schema));
}
private Mono<PolicyType> createPolicyType(String policyTypeId, String schema) {
@@ -195,7 +196,7 @@ public class RicSynchronizationTask {
private Flux<Policy> putPolicy(Policy policy, Ric ric, A1Client a1Client) {
logger.debug("Recreating policy: {}, for ric: {}", policy.id(), ric.getConfig().ricId());
return a1Client.putPolicy(policy) //
- .flatMapMany(notUsed -> Flux.just(policy));
+ .flatMapMany(notUsed -> Flux.just(policy));
}
private boolean checkTransient(Policy policy) {
@@ -207,8 +208,8 @@ public class RicSynchronizationTask {
private Flux<Policy> recreateAllPoliciesInRic(Ric ric, A1Client a1Client) {
return Flux.fromIterable(policies.getForRic(ric.id())) //
- .filter(policy -> !checkTransient(policy)) //
- .flatMap(policy -> putPolicy(policy, ric, a1Client), CONCURRENCY_RIC);
+ .filter(policy -> !checkTransient(policy)) //
+ .flatMap(policy -> putPolicy(policy, ric, a1Client), CONCURRENCY_RIC);
}
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
index a46ff1f9..4c063e2d 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/ServiceSupervision.java
@@ -62,7 +62,7 @@ public class ServiceSupervision {
}
public ServiceSupervision(Services services, Policies policies, A1ClientFactory a1ClientFactory,
- Duration checkInterval) {
+ Duration checkInterval) {
this.services = services;
this.policies = policies;
this.a1ClientFactory = a1ClientFactory;
@@ -77,32 +77,32 @@ public class ServiceSupervision {
private Flux<?> createTask() {
return Flux.interval(this.checkInterval) //
- .flatMap(notUsed -> checkAllServices());
+ .flatMap(notUsed -> checkAllServices());
}
Flux<Policy> checkAllServices() {
return Flux.fromIterable(services.getAll()) //
- .filter(Service::isExpired) //
- .doOnNext(service -> logger.info("Service is expired: {}", service.getName())) //
- .doOnNext(service -> services.remove(service.getName())) //
- .flatMap(this::getAllPoliciesForService) //
- .flatMap(this::deletePolicy, CONCURRENCY_RIC);
+ .filter(Service::isExpired) //
+ .doOnNext(service -> logger.info("Service is expired: {}", service.getName())) //
+ .doOnNext(service -> services.remove(service.getName())) //
+ .flatMap(this::getAllPoliciesForService) //
+ .flatMap(this::deletePolicy, CONCURRENCY_RIC);
}
@SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally
private Flux<Policy> deletePolicy(Policy policy) {
Lock lock = policy.ric().getLock();
return lock.lock(LockType.SHARED) //
- .doOnNext(notUsed -> policies.remove(policy)) //
- .flatMap(notUsed -> deletePolicyInRic(policy))
- .doOnNext(notUsed -> logger.debug("Policy deleted due to service inactivity: {}, service: {}", policy.id(),
- policy.ownerServiceId())) //
- .doOnNext(notUsed -> lock.unlockBlocking()) //
- .doOnError(throwable -> lock.unlockBlocking()) //
- .doOnError(throwable -> logger.debug("Failed to delete inactive policy: {}, reason: {}", policy.id(),
- throwable.getMessage())) //
- .flatMapMany(notUsed -> Flux.just(policy)) //
- .onErrorResume(throwable -> Flux.empty());
+ .doOnNext(notUsed -> policies.remove(policy)) //
+ .flatMap(notUsed -> deletePolicyInRic(policy))
+ .doOnNext(notUsed -> logger.debug("Policy deleted due to service inactivity: {}, service: {}",
+ policy.id(), policy.ownerServiceId())) //
+ .doOnNext(notUsed -> lock.unlockBlocking()) //
+ .doOnError(throwable -> lock.unlockBlocking()) //
+ .doOnError(throwable -> logger.debug("Failed to delete inactive policy: {}, reason: {}", policy.id(),
+ throwable.getMessage())) //
+ .flatMapMany(notUsed -> Flux.just(policy)) //
+ .onErrorResume(throwable -> Flux.empty());
}
private Flux<Policy> getAllPoliciesForService(Service service) {
@@ -111,14 +111,14 @@ public class ServiceSupervision {
private Mono<Policy> deletePolicyInRic(Policy policy) {
return a1ClientFactory.createA1Client(policy.ric()) //
- .flatMap(client -> client.deletePolicy(policy) //
- .onErrorResume(exception -> handleDeleteFromRicFailure(policy, exception)) //
- .map(nothing -> policy));
+ .flatMap(client -> client.deletePolicy(policy) //
+ .onErrorResume(exception -> handleDeleteFromRicFailure(policy, exception)) //
+ .map(nothing -> policy));
}
private Mono<String> handleDeleteFromRicFailure(Policy policy, Throwable e) {
logger.warn("Could not delete policy: {} from ric: {}. Cause: {}", policy.id(), policy.ric().id(),
- e.getMessage());
+ e.getMessage());
return Mono.empty();
}
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java
index 6ccf162c..ab318615 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/MockPolicyManagementService.java
@@ -57,8 +57,7 @@ import org.springframework.util.StringUtils;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
-@TestPropertySource(
- properties = { //
+@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
"app.webclient.trust-store=./config/truststore.jks"})
class MockPolicyManagementService {
@@ -170,7 +169,7 @@ class MockPolicyManagementService {
await().until(() -> rics.size() == noOfRicsInConfigFile);
} catch (Exception e) {
logger.info("Loaded rics: {}, and no of rics in config file: {} never matched!", rics.size(),
- StringUtils.countOccurrencesOf(json, "baseUrl"));
+ StringUtils.countOccurrencesOf(json, "baseUrl"));
}
}
@@ -186,14 +185,14 @@ class MockPolicyManagementService {
String json = getConfigJsonFromFile();
Policy policy = ImmutablePolicy.builder() //
- .id("typelessPolicy") //
- .json(json) //
- .ownerServiceId("MockPolicyManagementService") //
- .ric(ric) //
- .type(unnamedPolicyType) //
- .lastModified(Instant.now()) //
- .isTransient(false) //
- .build();
+ .id("typelessPolicy") //
+ .json(json) //
+ .ownerServiceId("MockPolicyManagementService") //
+ .ric(ric) //
+ .type(unnamedPolicyType) //
+ .lastModified(Instant.now()) //
+ .isTransient(false) //
+ .build();
this.policies.put(policy);
}
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 685c5611..89adf68a 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
@@ -70,11 +70,11 @@ class A1ClientFactoryTest {
private static ImmutableRicConfig ricConfig(String controllerName) {
return ImmutableRicConfig.builder() //
- .ricId(RIC_NAME) //
- .baseUrl("baseUrl") //
- .managedElementIds(new Vector<>()) //
- .controllerName(controllerName) //
- .build();
+ .ricId(RIC_NAME) //
+ .baseUrl("baseUrl") //
+ .managedElementIds(new Vector<>()) //
+ .controllerName(controllerName) //
+ .build();
}
@BeforeEach
@@ -114,9 +114,9 @@ class A1ClientFactoryTest {
doReturn(clientMock1, clientMock2, clientMock3, clientMock4).when(factoryUnderTest).createClient(any(), any());
StepVerifier.create(factoryUnderTest.createA1Client(ric)) //
- .expectSubscription() //
- .expectError() //
- .verify();
+ .expectSubscription() //
+ .expectError() //
+ .verify();
assertEquals(A1ProtocolType.UNKNOWN, ric.getProtocolVersion(), "Protocol negotiation failed for " + ric.id());
}
@@ -156,11 +156,11 @@ class A1ClientFactoryTest {
private void whenGetGetControllerConfigReturn() throws ServiceException {
ControllerConfig controllerCfg = ImmutableControllerConfig.builder() //
- .name("name") //
- .baseUrl("baseUrl") //
- .password("pass") //
- .userName("user") //
- .build();
+ .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 855a917f..cec5c2c6 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
@@ -36,8 +36,7 @@ import reactor.core.publisher.Mono;
public class A1ClientHelper {
- private A1ClientHelper() {
- }
+ private A1ClientHelper() {}
protected static Mono<String> createOutputJsonResponse(String key, String value) {
JSONObject paramsJson = new JSONObject();
@@ -49,23 +48,23 @@ public class A1ClientHelper {
protected static Ric createRic(String url) {
RicConfig cfg = ImmutableRicConfig.builder().ricId("ric") //
- .baseUrl(url) //
- .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) //
- .controllerName("") //
- .build();
+ .baseUrl(url) //
+ .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) //
+ .controllerName("") //
+ .build();
return new Ric(cfg);
}
protected static Policy createPolicy(String nearRtRicUrl, String policyId, String json, String type) {
return ImmutablePolicy.builder() //
- .id(policyId) //
- .json(json) //
- .ownerServiceId("service") //
- .ric(createRic(nearRtRicUrl)) //
- .type(createPolicyType(type)) //
- .lastModified(Instant.now()) //
- .isTransient(false) //
- .build();
+ .id(policyId) //
+ .json(json) //
+ .ownerServiceId("service") //
+ .ric(createRic(nearRtRicUrl)) //
+ .type(createPolicyType(type)) //
+ .lastModified(Instant.now()) //
+ .isTransient(false) //
+ .build();
}
protected static PolicyType createPolicyType(String name) {
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java
index 28343322..36bbda57 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java
@@ -69,8 +69,8 @@ class AsyncRestClientTest {
@Test
void testGetNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
- .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
- .setBody(TEST_JSON));
+ .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
+ .setBody(TEST_JSON));
Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL);
StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify();
@@ -82,14 +82,14 @@ class AsyncRestClientTest {
Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL);
StepVerifier.create(returnedMono)
- .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
+ .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
}
@Test
void testPutNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
- .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
- .setBody(TEST_JSON));
+ .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
+ .setBody(TEST_JSON));
Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON);
StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify();
@@ -101,7 +101,7 @@ class AsyncRestClientTest {
Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON);
StepVerifier.create(returnedMono)
- .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
+ .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
}
@Test
@@ -118,14 +118,14 @@ class AsyncRestClientTest {
Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL);
StepVerifier.create(returnedMono)
- .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
+ .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
}
@Test
void testPostNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
- .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
- .setBody(TEST_JSON));
+ .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
+ .setBody(TEST_JSON));
Mono<String> returnedMono = clientUnderTest.post(REQUEST_URL, TEST_JSON);
StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify();
@@ -137,14 +137,14 @@ class AsyncRestClientTest {
Mono<String> returnedMono = clientUnderTest.post(REQUEST_URL, TEST_JSON);
StepVerifier.create(returnedMono)
- .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
+ .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
}
@Test
void testPostWithAuthHeaderNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
- .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
- .setBody(TEST_JSON));
+ .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
+ .setBody(TEST_JSON));
Mono<String> returnedMono = clientUnderTest.postWithAuthHeader(REQUEST_URL, TEST_JSON, USERNAME, PASSWORD);
StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify();
@@ -156,6 +156,6 @@ class AsyncRestClientTest {
Mono<String> returnedMono = clientUnderTest.postWithAuthHeader(REQUEST_URL, TEST_JSON, USERNAME, PASSWORD);
StepVerifier.create(returnedMono)
- .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
+ .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
}
}
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 d6d12ba1..6aacc914 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
@@ -67,11 +67,11 @@ class OscA1ClientTest {
@BeforeEach
void init() {
RicConfig ricConfig = ImmutableRicConfig.builder() //
- .ricId("name") //
- .baseUrl("RicBaseUrl") //
- .managedElementIds(new ArrayList<>()) //
- .controllerName("") //
- .build();
+ .ricId("name") //
+ .baseUrl("RicBaseUrl") //
+ .managedElementIds(new ArrayList<>()) //
+ .controllerName("") //
+ .build();
asyncRestClientMock = mock(AsyncRestClient.class);
clientUnderTest = new OscA1Client(ricConfig, asyncRestClientMock);
}
@@ -93,7 +93,7 @@ class OscA1ClientTest {
Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString());
Mono<String> policyIdsType2Resp = Mono.just(Arrays.asList(POLICY_2_ID).toString());
when(asyncRestClientMock.get(anyString())).thenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp)
- .thenReturn(policyIdsType2Resp);
+ .thenReturn(policyIdsType2Resp);
List<String> returned = clientUnderTest.getPolicyIdentities().block();
@@ -113,7 +113,7 @@ class OscA1ClientTest {
Mono<String> 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();
+ .expectComplete().verify();
}
@Test
@@ -144,9 +144,10 @@ class OscA1ClientTest {
when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.empty());
clientUnderTest
- .putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID)).block();
+ .putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID))
+ .block();
verify(asyncRestClientMock).put(POLICYTYPES_URL + POLICY_TYPE_1_ID + POLICIES + "/" + POLICY_1_ID,
- POLICY_JSON_VALID);
+ POLICY_JSON_VALID);
}
@Test
@@ -154,7 +155,7 @@ class OscA1ClientTest {
when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty());
Mono<String> returnedMono = clientUnderTest
- .deletePolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID));
+ .deletePolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID));
verify(asyncRestClientMock).delete(POLICYTYPES_URL + POLICY_TYPE_1_ID + POLICIES + "/" + POLICY_1_ID);
StepVerifier.create(returnedMono).expectComplete().verify();
}
@@ -165,7 +166,7 @@ class OscA1ClientTest {
Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString());
Mono<String> policyIdsType2Resp = Mono.just(Arrays.asList(POLICY_2_ID).toString());
when(asyncRestClientMock.get(anyString())).thenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp)
- .thenReturn(policyIdsType2Resp);
+ .thenReturn(policyIdsType2Resp);
when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty());
Flux<String> returnedFlux = clientUnderTest.deleteAllPolicies();
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
index b1323859..c2118c12 100644
--- 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
@@ -69,78 +69,78 @@ class SdncOnapA1ClientTest {
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);
+ .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();
+ .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());
+ 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);
+ CONTROLLER_PASSWORD);
StepVerifier.create(returnedMono).expectNext(policyTypeIds).expectComplete().verify();
}
@Test
void testGetPolicyIdentities() {
SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .build();
+ .nearRtRicId(RIC_1_URL) //
+ .build();
String inputJsonStringGetTypeIds = SdncJsonHelper.createInputJsonString(inputParams);
inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .build();
+ .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();
+ .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());
+ 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());
+ 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());
+ 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);
+ CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType1,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
+ CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType2,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
+ CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
}
@Test
void testGetValidPolicyType() {
SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .build();
+ .nearRtRicId(RIC_1_URL) //
+ .policyTypeId(POLICY_TYPE_1_ID) //
+ .build();
String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_VALID + ", \"statusSchema\": {} }";
@@ -149,16 +149,16 @@ class SdncOnapA1ClientTest {
Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID);
verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_URL, inputJsonString, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ 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();
+ .nearRtRicId(RIC_1_URL) //
+ .policyTypeId(POLICY_TYPE_1_ID) //
+ .build();
String inputJsonString = SdncJsonHelper.createInputJsonString(inputParams);
String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_INVALID + ", \"statusSchema\": {} }";
@@ -167,105 +167,105 @@ class SdncOnapA1ClientTest {
Mono<String> returnedMono = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_ID);
verify(asyncRestClientMock).postWithAuthHeader(POLICYTYPES_URL, inputJsonString, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ 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();
+ .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));
+ .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);
+ 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();
+ .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));
+ .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);
+ CONTROLLER_PASSWORD);
StepVerifier.create(returnedMono).expectComplete().verify();
}
@Test
void testDeleteAllPolicies() {
SdncOnapA1Client.SdncOnapAdapterInput inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .build();
+ .nearRtRicId(RIC_1_URL) //
+ .build();
String inputJsonStringGetTypeIds = SdncJsonHelper.createInputJsonString(inputParams);
inputParams = ImmutableSdncOnapAdapterInput.builder() //
- .nearRtRicId(RIC_1_URL) //
- .policyTypeId(POLICY_TYPE_1_ID) //
- .build();
+ .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();
+ .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();
+ .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();
+ .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());
+ 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());
+ 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());
+ A1ClientHelper.createOutputJsonResponse("policy-instance-id-list", policyIdsType2.toString());
whenAsyncPostThenReturn(policyTypeIdsResp).thenReturn(policyIdsType1Resp).thenReturn(Mono.empty())
- .thenReturn(policyIdsType2Resp).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);
+ CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType1,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
+ CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonStringDeletePolicy1,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
+ CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(POLICIES_IDENTITIES_URL, inputJsonStringGetPolicyIdsType2,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
+ CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(DELETE_POLICY_URL, inputJsonStringDeletePolicy2,
- CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
+ CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
}
private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) {
return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString()))
- .thenReturn(response);
+ .thenReturn(response);
}
}
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/SdncOscA1ClientTest.java
index 1e9695c7..bbb2b8e9 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/SdncOscA1ClientTest.java
@@ -78,11 +78,11 @@ class SdncOscA1ClientTest {
private ControllerConfig controllerConfig() {
return ImmutableControllerConfig.builder() //
- .name("name") //
- .baseUrl("baseUrl") //
- .password(CONTROLLER_PASSWORD) //
- .userName(CONTROLLER_USERNAME) //
- .build();
+ .name("name") //
+ .baseUrl("baseUrl") //
+ .password(CONTROLLER_PASSWORD) //
+ .userName(CONTROLLER_USERNAME) //
+ .build();
}
@BeforeEach
@@ -90,7 +90,7 @@ class SdncOscA1ClientTest {
Ric ric = A1ClientHelper.createRic(RIC_1_URL);
clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, ric.getConfig(), controllerConfig(),
- asyncRestClientMock);
+ asyncRestClientMock);
}
@Test
@@ -111,8 +111,8 @@ class SdncOscA1ClientTest {
@Test
void getPolicyTypeIdentities_OSC() {
clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
- A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
- controllerConfig(), asyncRestClientMock);
+ A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
+ controllerConfig(), asyncRestClientMock);
String response = createOkResponseWithBody(Arrays.asList(POLICY_TYPE_1_ID));
whenAsyncPostThenReturn(Mono.just(response));
@@ -124,11 +124,11 @@ class SdncOscA1ClientTest {
String expUrl = RIC_1_URL + "/a1-p/policytypes";
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(expUrl) //
- .build();
+ .nearRtRicUrl(expUrl) //
+ .build();
String expInput = SdncJsonHelper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ CONTROLLER_PASSWORD);
}
@Test
@@ -141,8 +141,8 @@ class SdncOscA1ClientTest {
@Test
void getTypeSchema_OSC() throws IOException {
clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
- A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
- controllerConfig(), asyncRestClientMock);
+ A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
+ controllerConfig(), asyncRestClientMock);
String ricResponse = loadFile("test_osc_get_schema_response.json");
JsonElement elem = gson().fromJson(ricResponse, JsonElement.class);
@@ -153,7 +153,7 @@ class SdncOscA1ClientTest {
JsonElement respJson = gson().fromJson(response, JsonElement.class);
assertEquals("policyTypeId", respJson.getAsJsonObject().get("title").getAsString(),
- "title should be updated to contain policyType ID");
+ "title should be updated to contain policyType ID");
}
@Test
@@ -178,19 +178,19 @@ class SdncOscA1ClientTest {
assertEquals(2, returned.size());
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(policiesUrl()) //
- .build();
+ .nearRtRicUrl(policiesUrl()) //
+ .build();
String expInput = SdncJsonHelper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ CONTROLLER_PASSWORD);
}
@Test
void getPolicyIdentities_OSC() {
clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
- A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
- controllerConfig(), asyncRestClientMock);
+ A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
+ controllerConfig(), asyncRestClientMock);
String policytypeIdsResp = createOkResponseWithBody(Arrays.asList(POLICY_TYPE_1_ID));
String policyIdsResp = createOkResponseWithBody(Arrays.asList(POLICY_1_ID, POLICY_2_ID));
@@ -201,11 +201,11 @@ class SdncOscA1ClientTest {
assertEquals(2, returned.size());
ImmutableAdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(RIC_1_URL + "/a1-p/policytypes/type1/policies") //
- .build();
+ .nearRtRicUrl(RIC_1_URL + "/a1-p/policytypes/type1/policies") //
+ .build();
String expInput = SdncJsonHelper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ CONTROLLER_PASSWORD);
}
@Test
@@ -213,15 +213,15 @@ class SdncOscA1ClientTest {
whenPostReturnOkResponse();
String returned = clientUnderTest
- .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID))
- .block();
+ .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID))
+ .block();
assertEquals("OK", returned);
final String expUrl = policiesUrl() + "/" + POLICY_1_ID;
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(expUrl) //
- .body(POLICY_JSON_VALID) //
- .build();
+ .nearRtRicUrl(expUrl) //
+ .body(POLICY_JSON_VALID) //
+ .build();
String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams);
verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expInput, CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
@@ -231,30 +231,30 @@ class SdncOscA1ClientTest {
void putPolicyRejected() {
final String policyJson = "{}";
AdapterOutput adapterOutput = ImmutableAdapterOutput.builder() //
- .body("NOK") //
- .httpStatus(HttpStatus.BAD_REQUEST.value()) // ERROR
- .build();
+ .body("NOK") //
+ .httpStatus(HttpStatus.BAD_REQUEST.value()) // ERROR
+ .build();
String resp = SdncJsonHelper.createOutputJsonString(adapterOutput);
whenAsyncPostThenReturn(Mono.just(resp));
Mono<String> returnedMono = clientUnderTest
- .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, policyJson, POLICY_TYPE_1_ID));
+ .putPolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, policyJson, POLICY_TYPE_1_ID));
StepVerifier.create(returnedMono) //
- .expectSubscription() //
- .expectErrorMatches(t -> t instanceof WebClientResponseException) //
- .verify();
+ .expectSubscription() //
+ .expectErrorMatches(t -> t instanceof WebClientResponseException) //
+ .verify();
final String expUrl = policiesUrl() + "/" + POLICY_1_ID;
AdapterRequest expRequestParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(expUrl) //
- .body(policyJson) //
- .build();
+ .nearRtRicUrl(expUrl) //
+ .body(policyJson) //
+ .build();
String expRequest = SdncJsonHelper.createInputJsonString(expRequestParams);
verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expRequest, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ CONTROLLER_PASSWORD);
StepVerifier.create(returnedMono)
- .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
+ .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify();
}
@Test
@@ -262,18 +262,18 @@ class SdncOscA1ClientTest {
whenPostReturnOkResponse();
String returned = clientUnderTest
- .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID))
- .block();
+ .deletePolicy(A1ClientHelper.createPolicy(RIC_1_URL, POLICY_1_ID, POLICY_JSON_VALID, POLICY_TYPE_1_ID))
+ .block();
assertEquals("OK", returned);
final String expUrl = policiesUrl() + "/" + POLICY_1_ID;
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(expUrl) //
- .build();
+ .nearRtRicUrl(expUrl) //
+ .build();
String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams);
verify(asyncRestClientMock).postWithAuthHeader(DELETE_A1_URL, expInput, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ CONTROLLER_PASSWORD);
}
@Test
@@ -288,12 +288,12 @@ class SdncOscA1ClientTest {
final String expUrl = policiesUrl() + "/" + POLICY_1_ID + "/status";
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(expUrl) //
- .build();
+ .nearRtRicUrl(expUrl) //
+ .build();
String expInput = SdncJsonHelper.createInputJsonString(expectedInputParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_STATUS_URL, expInput, CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD);
+ CONTROLLER_PASSWORD);
}
@Test
@@ -314,8 +314,8 @@ class SdncOscA1ClientTest {
@Test
void getVersion_OSC() {
clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
- A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
- controllerConfig(), asyncRestClientMock);
+ A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
+ controllerConfig(), asyncRestClientMock);
whenAsyncPostThenReturn(Mono.error(new Exception("Error"))).thenReturn(Mono.just(createOkResponseString(true)));
@@ -349,9 +349,9 @@ class SdncOscA1ClientTest {
private String createOkResponseWithBody(Object body) {
AdapterOutput output = ImmutableAdapterOutput.builder() //
- .body(gson().toJson(body)) //
- .httpStatus(HttpStatus.OK.value()) //
- .build();
+ .body(gson().toJson(body)) //
+ .httpStatus(HttpStatus.OK.value()) //
+ .build();
return SdncJsonHelper.createOutputJsonString(output);
}
@@ -367,6 +367,6 @@ class SdncOscA1ClientTest {
private OngoingStubbing<Mono<String>> whenAsyncPostThenReturn(Mono<String> response) {
return when(asyncRestClientMock.postWithAuthHeader(anyString(), anyString(), anyString(), anyString()))
- .thenReturn(response);
+ .thenReturn(response);
}
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java
index 834a2a2f..b4709767 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientTest.java
@@ -102,7 +102,7 @@ class StdA1ClientTest {
when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.just(POLICY_JSON));
Mono<String> policyMono =
- clientUnderTest.putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON, POLICY_TYPE));
+ clientUnderTest.putPolicy(A1ClientHelper.createPolicy(RIC_URL, POLICY_1_ID, POLICY_JSON, POLICY_TYPE));
verify(asyncRestClientMock).put(policiesBaseUrl() + POLICY_1_ID, POLICY_JSON);
StepVerifier.create(policyMono).expectNext(POLICY_JSON).expectComplete().verify();
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java
index d0417a0a..0a75fd30 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParserTest.java
@@ -57,17 +57,17 @@ class ApplicationConfigParserTest {
topicUrl = result.dmaapConsumerTopicUrl();
assertEquals(
- "http://admin:admin@localhost:6845/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100",
- topicUrl, "controller contents");
+ "http://admin:admin@localhost:6845/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100",
+ topicUrl, "controller contents");
Map<String, ControllerConfig> controllers = result.controllerConfigs();
assertEquals(1, controllers.size(), "size");
ImmutableControllerConfig expectedControllerConfig = ImmutableControllerConfig.builder() //
- .baseUrl("http://localhost:8083/") //
- .name("controller1") //
- .userName("user") //
- .password("password") //
- .build(); //
+ .baseUrl("http://localhost:8083/") //
+ .name("controller1") //
+ .userName("user") //
+ .password("password") //
+ .build(); //
assertEquals(expectedControllerConfig, controllers.get("controller1"), "controller contents");
}
@@ -78,7 +78,7 @@ class ApplicationConfigParserTest {
private static InputStream getCorrectJson() throws IOException {
URL url = ApplicationConfigParser.class.getClassLoader()
- .getResource("test_application_configuration_with_dmaap_config.json");
+ .getResource("test_application_configuration_with_dmaap_config.json");
String string = Resources.toString(url, Charsets.UTF_8);
return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8)));
}
@@ -92,12 +92,12 @@ class ApplicationConfigParserTest {
json.add("fake_info_object", new Gson().toJsonTree(fake_info_object));
DataPublishing data = new Gson().fromJson(json.toString(), DataPublishing.class);
final String expectedMessage =
- "Invalid configuration. Number of streams must be one, config: " + data.toString();
+ "Invalid configuration. Number of streams must be one, config: " + data.toString();
Exception actualException = assertThrows(ServiceException.class, () -> parserUnderTest.parse(jsonRootObject));
assertEquals(expectedMessage, actualException.getMessage(),
- "Wrong error message when the DMaaP config has several streams publishing");
+ "Wrong error message when the DMaaP config has several streams publishing");
}
class DataPublishing {
@@ -107,7 +107,7 @@ class ApplicationConfigParserTest {
@Override
public String toString() {
return String.format("[dmaap_publisher=%s, fake_info_object=%s]", dmaap_publisher.toString(),
- fake_info_object.toString());
+ fake_info_object.toString());
}
}
@@ -120,12 +120,12 @@ class ApplicationConfigParserTest {
json.add("fake_info_object", new Gson().toJsonTree(fake_info_object));
DataSubscribing data = new Gson().fromJson(json.toString(), DataSubscribing.class);
final String expectedMessage =
- "Invalid configuration. Number of streams must be one, config: " + data.toString();
+ "Invalid configuration. Number of streams must be one, config: " + data.toString();
Exception actualException = assertThrows(ServiceException.class, () -> parserUnderTest.parse(jsonRootObject));
assertEquals(expectedMessage, actualException.getMessage(),
- "Wrong error message when the DMaaP config has several streams subscribing");
+ "Wrong error message when the DMaaP config has several streams subscribing");
}
private class DataSubscribing {
@@ -135,7 +135,7 @@ class ApplicationConfigParserTest {
@Override
public String toString() {
return String.format("[dmaap_subscriber=%s, fake_info_object=%s]", dmaap_subscriber.toString(),
- fake_info_object.toString());
+ fake_info_object.toString());
}
}
@@ -152,8 +152,8 @@ class ApplicationConfigParserTest {
}
JsonObject getDmaapInfo(JsonObject jsonRootObject, String streamsPublishesOrSubscribes,
- String dmaapPublisherOrSubscriber) throws Exception {
+ String dmaapPublisherOrSubscriber) throws Exception {
return jsonRootObject.getAsJsonObject("config").getAsJsonObject(streamsPublishesOrSubscribes)
- .getAsJsonObject(dmaapPublisherOrSubscriber).getAsJsonObject("dmaap_info");
+ .getAsJsonObject(dmaapPublisherOrSubscriber).getAsJsonObject("dmaap_info");
}
}
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 eb2c1477..cf4739c8 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
@@ -40,19 +40,19 @@ import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException
class ApplicationConfigTest {
private static final ImmutableRicConfig RIC_CONFIG_1 = ImmutableRicConfig.builder() //
- .ricId("ric1") //
- .baseUrl("ric1_url") //
- .managedElementIds(new Vector<>()) //
- .controllerName("") //
- .build();
+ .ricId("ric1") //
+ .baseUrl("ric1_url") //
+ .managedElementIds(new Vector<>()) //
+ .controllerName("") //
+ .build();
ConfigParserResult configParserResult(RicConfig... rics) {
return ImmutableConfigParserResult.builder() //
- .ricConfigs(Arrays.asList(rics)) //
- .dmaapConsumerTopicUrl("dmaapConsumerTopicUrl") //
- .dmaapProducerTopicUrl("dmaapProducerTopicUrl") //
- .controllerConfigs(new HashMap<>()) //
- .build();
+ .ricConfigs(Arrays.asList(rics)) //
+ .dmaapConsumerTopicUrl("dmaapConsumerTopicUrl") //
+ .dmaapProducerTopicUrl("dmaapProducerTopicUrl") //
+ .controllerConfigs(new HashMap<>()) //
+ .build();
}
@Test
@@ -77,7 +77,7 @@ class ApplicationConfigTest {
assertTrue(appConfigUnderTest.getRicConfigs().contains(RIC_CONFIG_1), "Ric not added to configurations.");
assertEquals(RIC_CONFIG_1, appConfigUnderTest.getRic(RIC_CONFIG_1.ricId()),
- "Not correct Ric retrieved from configurations.");
+ "Not correct Ric retrieved from configurations.");
update = appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1)).blockFirst();
assertNull(update, "Nothing should be updated");
@@ -92,17 +92,17 @@ class ApplicationConfigTest {
appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1));
ImmutableRicConfig changedRicConfig = ImmutableRicConfig.builder() //
- .ricId("ric1") //
- .baseUrl("changed_ric1_url") //
- .managedElementIds(new Vector<>()) //
- .controllerName("") //
- .build();
+ .ricId("ric1") //
+ .baseUrl("changed_ric1_url") //
+ .managedElementIds(new Vector<>()) //
+ .controllerName("") //
+ .build();
RicConfigUpdate update = appConfigUnderTest.setConfiguration(configParserResult(changedRicConfig)).blockFirst();
assertEquals(RicConfigUpdate.Type.CHANGED, update.getType());
assertEquals(changedRicConfig, appConfigUnderTest.getRic(RIC_CONFIG_1.ricId()),
- "Changed Ric not retrieved from configurations.");
+ "Changed Ric not retrieved from configurations.");
}
@Test
@@ -110,11 +110,11 @@ class ApplicationConfigTest {
ApplicationConfig appConfigUnderTest = new ApplicationConfig();
ImmutableRicConfig ricConfig2 = ImmutableRicConfig.builder() //
- .ricId("ric2") //
- .baseUrl("ric2_url") //
- .managedElementIds(new Vector<>()) //
- .controllerName("") //
- .build();
+ .ricId("ric2") //
+ .baseUrl("ric2_url") //
+ .managedElementIds(new Vector<>()) //
+ .controllerName("") //
+ .build();
appConfigUnderTest.setConfiguration(configParserResult(RIC_CONFIG_1, ricConfig2));
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
index 043524b8..f8c15b6a 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
@@ -88,8 +88,7 @@ import reactor.util.annotation.Nullable;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(
- properties = { //
+@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
"app.webclient.trust-store=./config/truststore.jks"})
class ApplicationTest {
@@ -120,8 +119,8 @@ class ApplicationTest {
Services services;
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
public static class MockApplicationConfig extends ApplicationConfig {
@Override
@@ -219,13 +218,13 @@ class ApplicationTest {
// This tests also validation of trusted certs restClient(true)
rsp = restClient(true).get(url).block();
assertThat(rsp).contains("ric2") //
- .doesNotContain("ric1") //
- .contains("AVAILABLE");
+ .doesNotContain("ric1") //
+ .contains("AVAILABLE");
// All RICs
rsp = restClient().get("/rics").block();
assertThat(rsp).contains("ric2") //
- .contains("ric1");
+ .contains("ric1");
// Non existing policy type
url = "/rics?policyType=XXXX";
@@ -285,13 +284,13 @@ class ApplicationTest {
}
private String putPolicyUrl(String serviceName, String ricName, String policyTypeName, String policyInstanceId,
- boolean isTransient) {
+ boolean isTransient) {
String url;
if (policyTypeName.isEmpty()) {
url = "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName;
} else {
url = "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName + "&type="
- + policyTypeName;
+ + policyTypeName;
}
if (isTransient) {
url += "&transient=true";
@@ -373,7 +372,7 @@ class ApplicationTest {
byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8);
WebClientResponseException a1Exception = new WebClientResponseException(httpStatus.value(), "statusText", null,
- responseBodyBytes, StandardCharsets.UTF_8, null);
+ responseBodyBytes, StandardCharsets.UTF_8, null);
doReturn(Mono.error(a1Exception)).when(a1Client).putPolicy(any());
// PUT Policy
@@ -461,7 +460,7 @@ class ApplicationTest {
String url = "/policy_schemas";
String rsp = this.restClient().get(url).block();
assertThat(rsp).contains("type1") //
- .contains("[{\"title\":\"type2\"}");
+ .contains("{\"title\":\"type2\"}");
List<String> info = parseSchemas(rsp);
assertThat(info).hasSize(2);
@@ -486,7 +485,7 @@ class ApplicationTest {
String rsp = restClient().get(url).block();
logger.info(rsp);
assertThat(rsp).contains("type1") //
- .contains("title");
+ .contains("title");
// Get non existing schema
url = "/policy_schema?id=type1XX";
@@ -537,15 +536,15 @@ class ApplicationTest {
String rsp = restClient().get(url).block();
logger.info(rsp);
assertThat(rsp).contains("id1") //
- .contains("id2") //
- .doesNotContain("id3");
+ .contains("id2") //
+ .doesNotContain("id3");
url = "/policies?type=type1&service=service2";
rsp = restClient().get(url).block();
logger.info(rsp);
assertThat(rsp).doesNotContain("id1") //
- .contains("id2") //
- .doesNotContain("id3");
+ .contains("id2") //
+ .doesNotContain("id3");
// Test get policies for non existing type
url = "/policies?type=type1XXX";
@@ -566,8 +565,8 @@ class ApplicationTest {
String rsp = restClient().get(url).block();
logger.info(rsp);
assertThat(rsp).contains("id1") //
- .contains("id2") //
- .doesNotContain("id3");
+ .contains("id2") //
+ .doesNotContain("id3");
url = "/policy_ids?type=type1&service=service1&ric=ric1";
rsp = restClient().get(url).block();
@@ -623,7 +622,7 @@ class ApplicationTest {
testErrorCode(restClient().put("/service", "{}"), HttpStatus.BAD_REQUEST);
testErrorCode(restClient().put("/service", createServiceJson(serviceName, -123)), HttpStatus.BAD_REQUEST);
testErrorCode(restClient().put("/service", createServiceJson(serviceName, 0, "missing.portandprotocol.com")),
- HttpStatus.BAD_REQUEST);
+ HttpStatus.BAD_REQUEST);
// GET non existing service
testErrorCode(restClient().get("/services?name=XXX"), HttpStatus.NOT_FOUND);
@@ -663,14 +662,14 @@ class ApplicationTest {
private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException {
addRic(ric);
Policy policy = ImmutablePolicy.builder() //
- .id(id) //
- .json(jsonString()) //
- .ownerServiceId(service) //
- .ric(rics.getRic(ric)) //
- .type(addPolicyType(typeName, ric)) //
- .lastModified(Instant.now()) //
- .isTransient(false) //
- .build();
+ .id(id) //
+ .json(jsonString()) //
+ .ownerServiceId(service) //
+ .ric(rics.getRic(ric)) //
+ .type(addPolicyType(typeName, ric)) //
+ .lastModified(Instant.now()) //
+ .isTransient(false) //
+ .build();
policies.put(policy);
return policy;
}
@@ -714,14 +713,14 @@ class ApplicationTest {
private AsyncRestClient restClient(boolean useTrustValidation) {
WebClientConfig config = this.applicationConfig.getWebClientConfig();
config = ImmutableWebClientConfig.builder() //
- .keyStoreType(config.keyStoreType()) //
- .keyStorePassword(config.keyStorePassword()) //
- .keyStore(config.keyStore()) //
- .keyPassword(config.keyPassword()) //
- .isTrustStoreUsed(useTrustValidation) //
- .trustStore(config.trustStore()) //
- .trustStorePassword(config.trustStorePassword()) //
- .build();
+ .keyStoreType(config.keyStoreType()) //
+ .keyStorePassword(config.keyStorePassword()) //
+ .keyStore(config.keyStore()) //
+ .keyPassword(config.keyPassword()) //
+ .isTrustStoreUsed(useTrustValidation) //
+ .trustStore(config.trustStore()) //
+ .trustStorePassword(config.trustStorePassword()) //
+ .build();
return new AsyncRestClient(baseUrl(), config);
}
@@ -736,9 +735,9 @@ class ApplicationTest {
private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains) {
StepVerifier.create(request) //
- .expectSubscription() //
- .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) //
- .verify();
+ .expectSubscription() //
+ .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) //
+ .verify();
}
private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains) {
@@ -755,9 +754,9 @@ class ApplicationTest {
private PolicyType createPolicyType(String policyTypeName) {
return ImmutablePolicyType.builder() //
- .id(policyTypeName) //
- .schema("{\"title\":\"" + policyTypeName + "\"}") //
- .build();
+ .id(policyTypeName) //
+ .schema("{\"title\":\"" + policyTypeName + "\"}") //
+ .build();
}
private PolicyType addPolicyType(String policyTypeName, String ricName) {
@@ -780,11 +779,11 @@ class ApplicationTest {
mes.add(managedElement);
}
RicConfig conf = ImmutableRicConfig.builder() //
- .ricId(ricName) //
- .baseUrl(ricName) //
- .managedElementIds(mes) //
- .controllerName("") //
- .build();
+ .ricId(ricName) //
+ .baseUrl(ricName) //
+ .managedElementIds(mes) //
+ .controllerName("") //
+ .build();
Ric ric = new Ric(conf);
ric.setState(Ric.RicState.AVAILABLE);
this.rics.put(ric);
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 243ded43..87589f22 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
@@ -87,8 +87,7 @@ import reactor.util.annotation.Nullable;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(
- properties = { //
+@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
"app.webclient.trust-store=./config/truststore.jks"})
class ApplicationTest {
@@ -119,8 +118,8 @@ class ApplicationTest {
Services services;
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
- .create(); //
+ .serializeNulls() //
+ .create(); //
public static class MockApplicationConfig extends ApplicationConfig {
@Override
@@ -218,13 +217,13 @@ class ApplicationTest {
// This tests also validation of trusted certs restClient(true)
rsp = restClient(true).get(url).block();
assertThat(rsp).contains("ric2") //
- .doesNotContain("ric1") //
- .contains("AVAILABLE");
+ .doesNotContain("ric1") //
+ .contains("AVAILABLE");
// All RICs
rsp = restClient().get("/rics").block();
assertThat(rsp).contains("ric2") //
- .contains("ric1");
+ .contains("ric1");
// Non existing policy type
url = "/rics?policytype_id=XXXX";
@@ -293,13 +292,13 @@ class ApplicationTest {
}
private String putPolicyUrl(String serviceName, String ricId, String policyTypeName, String policyInstanceId,
- boolean isTransient) {
+ boolean isTransient) {
String url;
if (policyTypeName.isEmpty()) {
url = "/policy?policy_id=" + policyInstanceId + "&ric_id=" + ricId + "&service_id=" + serviceName;
} else {
url = "/policy?policy_id=" + policyInstanceId + "&ric_id=" + ricId + "&service_id=" + serviceName
- + "&policytype_id=" + policyTypeName;
+ + "&policytype_id=" + policyTypeName;
}
if (isTransient) {
url += "&transient=true";
@@ -381,7 +380,7 @@ class ApplicationTest {
byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8);
WebClientResponseException a1Exception = new WebClientResponseException(httpStatus.value(), "statusText", null,
- responseBodyBytes, StandardCharsets.UTF_8, null);
+ responseBodyBytes, StandardCharsets.UTF_8, null);
doReturn(Mono.error(a1Exception)).when(a1Client).putPolicy(any());
// PUT Policy
@@ -472,7 +471,7 @@ class ApplicationTest {
String url = "/policy-schemas";
String rsp = this.restClient().get(url).block();
assertThat(rsp).contains("type1") //
- .contains("[{\"title\":\"type2\"}");
+ .contains("{\"title\":\"type2\"}");
PolicySchemaList info = parseSchemas(rsp);
assertThat(info.schemas).hasSize(2);
@@ -487,7 +486,7 @@ class ApplicationTest {
url = "/policy-schemas?policytype_id=type1";
rsp = restClient().get(url).block();
assertThat(rsp).contains("type1") //
- .contains("title");
+ .contains("title");
// Both type and ric specified
url = "/policy-schemas?ric_id=ric1&policytype_id=type1";
@@ -562,15 +561,15 @@ class ApplicationTest {
String rsp = restClient().get(url).block();
logger.info(rsp);
assertThat(rsp).contains("id1") //
- .contains("id2") //
- .doesNotContain("id3");
+ .contains("id2") //
+ .doesNotContain("id3");
url = "/policies?policytype_id=type1&service_id=service2";
rsp = restClient().get(url).block();
logger.info(rsp);
assertThat(rsp).doesNotContain("id1") //
- .contains("id2") //
- .doesNotContain("id3");
+ .contains("id2") //
+ .doesNotContain("id3");
// Test get policies for non existing type
url = "/policies?policytype_id=type1XXX";
@@ -591,8 +590,8 @@ class ApplicationTest {
String rsp = restClient().get(url).block();
logger.info(rsp);
assertThat(rsp).contains("id1") //
- .contains("id2") //
- .doesNotContain("id3");
+ .contains("id2") //
+ .doesNotContain("id3");
url = "/policy-ids?policytype_id=type1&service_id=service1&ric=ric1";
rsp = restClient().get(url).block();
@@ -648,9 +647,9 @@ class ApplicationTest {
testErrorCode(restClient().put("/services", "crap"), HttpStatus.BAD_REQUEST, false);
testErrorCode(restClient().put("/services", "{}"), HttpStatus.BAD_REQUEST, false);
testErrorCode(restClient().put("/services", createServiceJson(serviceName, -123)), HttpStatus.BAD_REQUEST,
- false);
+ false);
testErrorCode(restClient().put("/services", createServiceJson(serviceName, 0, "missing.portandprotocol.com")),
- HttpStatus.BAD_REQUEST, false);
+ HttpStatus.BAD_REQUEST, false);
// GET non existing service
testErrorCode(restClient().get("/services?service_id=XXX"), HttpStatus.NOT_FOUND);
@@ -690,14 +689,14 @@ class ApplicationTest {
private Policy addPolicy(String id, String typeName, String service, String ric) throws ServiceException {
addRic(ric);
Policy policy = ImmutablePolicy.builder() //
- .id(id) //
- .json(jsonString()) //
- .ownerServiceId(service) //
- .ric(rics.getRic(ric)) //
- .type(addPolicyType(typeName, ric)) //
- .lastModified(Instant.now()) //
- .isTransient(false) //
- .build();
+ .id(id) //
+ .json(jsonString()) //
+ .ownerServiceId(service) //
+ .ric(rics.getRic(ric)) //
+ .type(addPolicyType(typeName, ric)) //
+ .lastModified(Instant.now()) //
+ .isTransient(false) //
+ .build();
policies.put(policy);
return policy;
}
@@ -751,7 +750,7 @@ class ApplicationTest {
for (int i = 0; i < 10; ++i) {
AsyncRestClient restClient = restClient();
ConcurrencyTestRunnable test =
- new ConcurrencyTestRunnable(restClient, supervision, a1ClientFactory, rics, policyTypes);
+ new ConcurrencyTestRunnable(restClient, supervision, a1ClientFactory, rics, policyTypes);
Thread thread = new Thread(test, "TestThread_" + i);
thread.start();
threads.add(thread);
@@ -770,14 +769,14 @@ class ApplicationTest {
private AsyncRestClient restClient(boolean useTrustValidation) {
WebClientConfig config = this.applicationConfig.getWebClientConfig();
config = ImmutableWebClientConfig.builder() //
- .keyStoreType(config.keyStoreType()) //
- .keyStorePassword(config.keyStorePassword()) //
- .keyStore(config.keyStore()) //
- .keyPassword(config.keyPassword()) //
- .isTrustStoreUsed(useTrustValidation) //
- .trustStore(config.trustStore()) //
- .trustStorePassword(config.trustStorePassword()) //
- .build();
+ .keyStoreType(config.keyStoreType()) //
+ .keyStorePassword(config.keyStorePassword()) //
+ .keyStore(config.keyStore()) //
+ .keyPassword(config.keyPassword()) //
+ .isTrustStoreUsed(useTrustValidation) //
+ .trustStore(config.trustStore()) //
+ .trustStorePassword(config.trustStorePassword()) //
+ .build();
return new AsyncRestClient(baseUrl(), config);
}
@@ -799,12 +798,12 @@ class ApplicationTest {
}
private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains,
- boolean expectApplicationProblemJsonMediaType) {
+ boolean expectApplicationProblemJsonMediaType) {
StepVerifier.create(request) //
- .expectSubscription() //
- .expectErrorMatches(
- t -> checkWebClientError(t, expStatus, responseContains, expectApplicationProblemJsonMediaType)) //
- .verify();
+ .expectSubscription() //
+ .expectErrorMatches(
+ t -> checkWebClientError(t, expStatus, responseContains, expectApplicationProblemJsonMediaType)) //
+ .verify();
}
private void waitForRicState(String ricId, RicState state) throws ServiceException {
@@ -813,7 +812,7 @@ class ApplicationTest {
}
private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains,
- boolean expectApplicationProblemJsonMediaType) {
+ boolean expectApplicationProblemJsonMediaType) {
assertTrue(throwable instanceof WebClientResponseException);
WebClientResponseException responseException = (WebClientResponseException) throwable;
assertThat(responseException.getStatusCode()).isEqualTo(expStatus);
@@ -830,9 +829,9 @@ class ApplicationTest {
private PolicyType createPolicyType(String policyTypeName) {
return ImmutablePolicyType.builder() //
- .id(policyTypeName) //
- .schema("{\"title\":\"" + policyTypeName + "\"}") //
- .build();
+ .id(policyTypeName) //
+ .schema("{\"title\":\"" + policyTypeName + "\"}") //
+ .build();
}
private PolicyType addPolicyType(String policyTypeName, String ricId) {
@@ -855,11 +854,11 @@ class ApplicationTest {
mes.add(managedElement);
}
RicConfig conf = ImmutableRicConfig.builder() //
- .ricId(ricId) //
- .baseUrl(ricId) //
- .managedElementIds(mes) //
- .controllerName("") //
- .build();
+ .ricId(ricId) //
+ .baseUrl(ricId) //
+ .managedElementIds(mes) //
+ .controllerName("") //
+ .build();
Ric ric = new Ric(conf);
ric.setState(Ric.RicState.AVAILABLE);
this.rics.put(ric);
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java
index 45eddf84..89a76e95 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConcurrencyTestRunnable.java
@@ -53,7 +53,7 @@ class ConcurrencyTestRunnable implements Runnable {
private boolean failed = false;
ConcurrencyTestRunnable(AsyncRestClient client, RicSupervision supervision, MockA1ClientFactory a1ClientFactory,
- Rics rics, PolicyTypes types) {
+ Rics rics, PolicyTypes types) {
this.count = nextCount.incrementAndGet();
this.supervision = supervision;
this.a1ClientFactory = a1ClientFactory;
@@ -108,14 +108,14 @@ class ConcurrencyTestRunnable implements Runnable {
Ric ric = this.rics.get("ric");
PolicyType type = this.types.get("type1");
return ImmutablePolicy.builder() //
- .id(id) //
- .json("{}") //
- .type(type) //
- .ric(ric) //
- .ownerServiceId("") //
- .lastModified(Instant.now()) //
- .isTransient(false) //
- .build();
+ .id(id) //
+ .json("{}") //
+ .type(type) //
+ .ric(ric) //
+ .ownerServiceId("") //
+ .lastModified(Instant.now()) //
+ .isTransient(false) //
+ .build();
}
private void createInconsistency() {
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java
index 2bd8c7f4..b6d3cc07 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageConsumerTest.java
@@ -143,12 +143,12 @@ class DmaapMessageConsumerTest {
when(messageRouterConsumerMock.getForEntity(any())).thenReturn(response);
final ListAppender<ILoggingEvent> logAppender =
- LoggingUtils.getLogListAppender(DmaapMessageConsumer.class, WARN);
+ LoggingUtils.getLogListAppender(DmaapMessageConsumer.class, WARN);
messageConsumerUnderTest.start().join();
assertThat(logAppender.list.get(0).getFormattedMessage())
- .isEqualTo("Cannot fetch because of Error respons: 400 BAD_REQUEST Error");
+ .isEqualTo("Cannot fetch because of Error respons: 400 BAD_REQUEST Error");
verify(messageConsumerUnderTest).sleep(DmaapMessageConsumer.TIME_BETWEEN_DMAAP_RETRIES);
}
@@ -204,9 +204,9 @@ class DmaapMessageConsumerTest {
doReturn(messageHandlerMock).when(messageConsumerUnderTest).getDmaapMessageHandler();
doReturn(Mono.just("OK")).when(messageHandlerMock).sendDmaapResponse(any(), any(), any());
Exception actualException =
- assertThrows(ServiceException.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]"));
+ assertThrows(ServiceException.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]"));
assertThat(actualException.getMessage())
- .contains("Could not parse incomming request. Reason :com.google.gson.stream.MalformedJsonException");
+ .contains("Could not parse incomming request. Reason :com.google.gson.stream.MalformedJsonException");
verify(messageHandlerMock).sendDmaapResponse(any(), any(), any());
}
@@ -216,9 +216,9 @@ class DmaapMessageConsumerTest {
messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock));
doReturn(messageHandlerMock).when(messageConsumerUnderTest).getDmaapMessageHandler();
doReturn(Mono.error(new Exception("Sending response failed"))).when(messageHandlerMock).sendDmaapResponse(any(),
- any(), any());
+ any(), any());
Exception actualException =
- assertThrows(Exception.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]"));
+ assertThrows(Exception.class, () -> messageConsumerUnderTest.parseMessages("[\"abc:\"def\"]"));
assertThat(actualException.getMessage()).contains("Sending response failed");
verify(messageHandlerMock).sendDmaapResponse(any(), any(), any());
@@ -239,16 +239,16 @@ class DmaapMessageConsumerTest {
private DmaapRequestMessage dmaapRequestMessage(Operation operation) {
return ImmutableDmaapRequestMessage.builder() //
- .apiVersion("apiVersion") //
- .correlationId("correlationId") //
- .operation(operation) //
- .originatorId("originatorId") //
- .payload(new JsonObject()) //
- .requestId("requestId") //
- .target("target") //
- .timestamp("timestamp") //
- .url("URL") //
- .build();
+ .apiVersion("apiVersion") //
+ .correlationId("correlationId") //
+ .operation(operation) //
+ .originatorId("originatorId") //
+ .payload(new JsonObject()) //
+ .requestId("requestId") //
+ .target("target") //
+ .timestamp("timestamp") //
+ .url("URL") //
+ .build();
}
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java
index 3656ec1a..bab09931 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/dmaap/DmaapMessageHandlerTest.java
@@ -80,19 +80,19 @@ class DmaapMessageHandlerTest {
DmaapRequestMessage dmaapRequestMessage(Operation operation) {
Optional<JsonObject> payload =
- ((operation == Operation.PUT || operation == Operation.POST) ? Optional.of(payloadAsJson())
- : Optional.empty());
+ ((operation == Operation.PUT || operation == Operation.POST) ? Optional.of(payloadAsJson())
+ : Optional.empty());
return ImmutableDmaapRequestMessage.builder() //
- .apiVersion("apiVersion") //
- .correlationId("correlationId") //
- .operation(operation) //
- .originatorId("originatorId") //
- .payload(payload) //
- .requestId("requestId") //
- .target("target") //
- .timestamp("timestamp") //
- .url(URL) //
- .build();
+ .apiVersion("apiVersion") //
+ .correlationId("correlationId") //
+ .operation(operation) //
+ .originatorId("originatorId") //
+ .payload(payload) //
+ .requestId("requestId") //
+ .target("target") //
+ .timestamp("timestamp") //
+ .url(URL) //
+ .build();
}
private Mono<ResponseEntity<String>> okResponse() {
@@ -113,10 +113,10 @@ class DmaapMessageHandlerTest {
DmaapRequestMessage message = dmaapRequestMessage(Operation.DELETE);
StepVerifier //
- .create(testedObject.createTask(message)) //
- .expectSubscription() //
- .expectNext("OK") //
- .verifyComplete(); //
+ .create(testedObject.createTask(message)) //
+ .expectSubscription() //
+ .expectNext("OK") //
+ .verifyComplete(); //
verify(pmsClient).deleteForEntity(URL);
verifyNoMoreInteractions(pmsClient);
@@ -133,10 +133,10 @@ class DmaapMessageHandlerTest {
DmaapRequestMessage message = dmaapRequestMessage(Operation.GET);
StepVerifier //
- .create(testedObject.createTask(message)) //
- .expectSubscription() //
- .expectNext("OK") //
- .verifyComplete(); //
+ .create(testedObject.createTask(message)) //
+ .expectSubscription() //
+ .expectNext("OK") //
+ .verifyComplete(); //
verify(pmsClient).getForEntity(URL);
verifyNoMoreInteractions(pmsClient);
@@ -149,21 +149,21 @@ class DmaapMessageHandlerTest {
void exceptionFromPmsWhenGet_thenPostError() throws IOException {
String errorBody = "Unavailable";
WebClientResponseException webClientResponseException = new WebClientResponseException(
- HttpStatus.SERVICE_UNAVAILABLE.value(), "", (HttpHeaders) null, errorBody.getBytes(), (Charset) null);
+ HttpStatus.SERVICE_UNAVAILABLE.value(), "", (HttpHeaders) null, errorBody.getBytes(), (Charset) null);
doReturn(Mono.error(webClientResponseException)).when(pmsClient).getForEntity(anyString());
doReturn(Mono.just("OK")).when(dmaapClient).post(anyString(), anyString());
DmaapRequestMessage message = dmaapRequestMessage(Operation.GET);
StepVerifier //
- .create(testedObject.createTask(message)) //
- .expectSubscription() //
- .verifyComplete(); //
+ .create(testedObject.createTask(message)) //
+ .expectSubscription() //
+ .verifyComplete(); //
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(dmaapClient).post(anyString(), captor.capture());
String actualMessage = captor.getValue();
assertThat(actualMessage).contains(HttpStatus.SERVICE_UNAVAILABLE.toString()) //
- .contains(errorBody);
+ .contains(errorBody);
}
@Test
@@ -173,10 +173,10 @@ class DmaapMessageHandlerTest {
DmaapRequestMessage message = dmaapRequestMessage(Operation.PUT);
StepVerifier //
- .create(testedObject.createTask(message)) //
- .expectSubscription() //
- .expectNext("OK") //
- .verifyComplete(); //
+ .create(testedObject.createTask(message)) //
+ .expectSubscription() //
+ .expectNext("OK") //
+ .verifyComplete(); //
verify(pmsClient).putForEntity(URL, payloadAsString());
verifyNoMoreInteractions(pmsClient);
@@ -192,10 +192,10 @@ class DmaapMessageHandlerTest {
DmaapRequestMessage message = dmaapRequestMessage(Operation.POST);
StepVerifier //
- .create(testedObject.createTask(message)) //
- .expectSubscription() //
- .expectNext("OK") //
- .verifyComplete(); //
+ .create(testedObject.createTask(message)) //
+ .expectSubscription() //
+ .expectNext("OK") //
+ .verifyComplete(); //
verify(pmsClient).postForEntity(URL, payloadAsString());
verifyNoMoreInteractions(pmsClient);
@@ -220,7 +220,7 @@ class DmaapMessageHandlerTest {
verify(dmaapClient).post(anyString(), captor.capture());
String actualMessage = captor.getValue();
assertThat(actualMessage).as("Message \"%s\" sent to DMaaP contains %s", actualMessage, HttpStatus.BAD_GATEWAY)
- .contains(HttpStatus.BAD_GATEWAY.toString());
+ .contains(HttpStatus.BAD_GATEWAY.toString());
verifyNoMoreInteractions(dmaapClient);
}
@@ -228,24 +228,24 @@ class DmaapMessageHandlerTest {
@Test
void putWithoutPayload_thenNotFoundResponseWithWarning() throws Exception {
DmaapRequestMessage message = ImmutableDmaapRequestMessage.builder() //
- .apiVersion("apiVersion") //
- .correlationId("correlationId") //
- .operation(DmaapRequestMessage.Operation.PUT) //
- .originatorId("originatorId") //
- .payload(Optional.empty()) //
- .requestId("requestId") //
- .target("target") //
- .timestamp("timestamp") //
- .url(URL) //
- .build();
+ .apiVersion("apiVersion") //
+ .correlationId("correlationId") //
+ .operation(DmaapRequestMessage.Operation.PUT) //
+ .originatorId("originatorId") //
+ .payload(Optional.empty()) //
+ .requestId("requestId") //
+ .target("target") //
+ .timestamp("timestamp") //
+ .url(URL) //
+ .build();
final ListAppender<ILoggingEvent> logAppender =
- LoggingUtils.getLogListAppender(DmaapMessageHandler.class, WARN);
+ LoggingUtils.getLogListAppender(DmaapMessageHandler.class, WARN);
testedObject.handleDmaapMsg(message);
assertThat(logAppender.list.get(0).getFormattedMessage())
- .startsWith("Expected payload in message from DMAAP: ");
+ .startsWith("Expected payload in message from DMAAP: ");
}
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java
index 520e5c7a..a63f15f1 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/LockTest.java
@@ -73,14 +73,14 @@ class LockTest {
Lock lock = new Lock();
Mono<Lock> seq = lock.lock(LockType.EXCLUSIVE) //
- .flatMap(l -> lock.lock(LockType.EXCLUSIVE)) //
- .flatMap(l -> lock.unlock());
+ .flatMap(l -> lock.lock(LockType.EXCLUSIVE)) //
+ .flatMap(l -> lock.unlock());
asynchUnlock(lock);
StepVerifier.create(seq) //
- .expectSubscription() //
- .expectNext(lock) //
- .verifyComplete();
+ .expectSubscription() //
+ .expectNext(lock) //
+ .verifyComplete();
assertThat(lock.getLockCounter()).isZero();
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java
index e2bc8700..5a1dbea7 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/EnvironmentProcessorTest.java
@@ -55,14 +55,14 @@ class EnvironmentProcessorTest {
systemEnvironment.put(HOSTNAME, HOSTNAME_VALUE);
EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() //
- .consulHost(CONSUL_HOST_VALUE) //
- .consulPort(Integer.valueOf(consulPort)) //
- .cbsName(CONFIG_BINDING_SERVICE_VALUE) //
- .appName(HOSTNAME_VALUE) //
- .build();
+ .consulHost(CONSUL_HOST_VALUE) //
+ .consulPort(Integer.valueOf(consulPort)) //
+ .cbsName(CONFIG_BINDING_SERVICE_VALUE) //
+ .appName(HOSTNAME_VALUE) //
+ .build();
StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment))
- .expectNext(expectedEnvProperties).expectComplete();
+ .expectNext(expectedEnvProperties).expectComplete();
}
@Test
@@ -70,9 +70,9 @@ class EnvironmentProcessorTest {
Properties systemEnvironment = new Properties();
StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment))
- .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException
- && throwable.getMessage().equals("$CONSUL_HOST environment has not been defined"))
- .verify();
+ .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException
+ && throwable.getMessage().equals("$CONSUL_HOST environment has not been defined"))
+ .verify();
}
@Test
@@ -84,20 +84,20 @@ class EnvironmentProcessorTest {
String defaultConsulPort = "8500";
EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() //
- .consulHost(CONSUL_HOST_VALUE) //
- .consulPort(Integer.valueOf(defaultConsulPort)) //
- .cbsName(CONFIG_BINDING_SERVICE_VALUE) //
- .appName(HOSTNAME_VALUE) //
- .build();
+ .consulHost(CONSUL_HOST_VALUE) //
+ .consulPort(Integer.valueOf(defaultConsulPort)) //
+ .cbsName(CONFIG_BINDING_SERVICE_VALUE) //
+ .appName(HOSTNAME_VALUE) //
+ .build();
final ListAppender<ILoggingEvent> logAppender =
- LoggingUtils.getLogListAppender(EnvironmentProcessor.class, WARN);
+ LoggingUtils.getLogListAppender(EnvironmentProcessor.class, WARN);
StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment))
- .expectNext(expectedEnvProperties).expectComplete();
+ .expectNext(expectedEnvProperties).expectComplete();
assertThat(logAppender.list.get(0).getFormattedMessage())
- .isEqualTo("$CONSUL_PORT variable will be set to default port " + defaultConsulPort);
+ .isEqualTo("$CONSUL_PORT variable will be set to default port " + defaultConsulPort);
}
@Test
@@ -106,9 +106,9 @@ class EnvironmentProcessorTest {
systemEnvironment.put(CONSUL_HOST, CONSUL_HOST_VALUE);
StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment))
- .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException
- && throwable.getMessage().equals("$CONFIG_BINDING_SERVICE environment has not been defined"))
- .verify();
+ .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException
+ && throwable.getMessage().equals("$CONFIG_BINDING_SERVICE environment has not been defined"))
+ .verify();
}
@Test
@@ -121,14 +121,14 @@ class EnvironmentProcessorTest {
systemEnvironment.put("SERVICE_NAME", HOSTNAME_VALUE);
EnvProperties expectedEnvProperties = ImmutableEnvProperties.builder() //
- .consulHost(CONSUL_HOST_VALUE) //
- .consulPort(Integer.valueOf(consulPort)) //
- .cbsName(CONFIG_BINDING_SERVICE_VALUE) //
- .appName(HOSTNAME_VALUE) //
- .build();
+ .consulHost(CONSUL_HOST_VALUE) //
+ .consulPort(Integer.valueOf(consulPort)) //
+ .cbsName(CONFIG_BINDING_SERVICE_VALUE) //
+ .appName(HOSTNAME_VALUE) //
+ .build();
StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment))
- .expectNext(expectedEnvProperties).expectComplete();
+ .expectNext(expectedEnvProperties).expectComplete();
}
@Test
@@ -138,8 +138,9 @@ class EnvironmentProcessorTest {
systemEnvironment.put(CONFIG_BINDING_SERVICE, CONFIG_BINDING_SERVICE_VALUE);
StepVerifier.create(EnvironmentProcessor.readEnvironmentVariables(systemEnvironment))
- .expectErrorMatches(throwable -> throwable instanceof EnvironmentLoaderException && throwable.getMessage()
- .equals("Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment"))
- .verify();
+ .expectErrorMatches(
+ throwable -> throwable instanceof EnvironmentLoaderException && throwable.getMessage()
+ .equals("Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment"))
+ .verify();
}
}
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 572ba0b5..c62626c1 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
@@ -102,19 +102,19 @@ class RefreshConfigTaskTest {
private static final String RIC_1_NAME = "ric1";
private static final RicConfig CORRECT_RIC_CONIFG = ImmutableRicConfig.builder() //
- .ricId(RIC_1_NAME) //
- .baseUrl("http://localhost:8080/") //
- .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) //
- .controllerName("") //
- .build();
+ .ricId(RIC_1_NAME) //
+ .baseUrl("http://localhost:8080/") //
+ .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) //
+ .controllerName("") //
+ .build();
private static EnvProperties properties() {
return ImmutableEnvProperties.builder() //
- .consulHost("host") //
- .consulPort(123) //
- .cbsName("cbsName") //
- .appName("appName") //
- .build();
+ .consulHost("host") //
+ .consulPort(123) //
+ .cbsName("cbsName") //
+ .appName("appName") //
+ .build();
}
private RefreshConfigTask createTestObject(boolean configFileExists) {
@@ -122,9 +122,9 @@ class RefreshConfigTaskTest {
}
private RefreshConfigTask createTestObject(boolean configFileExists, Rics rics, Policies policies,
- boolean stubConfigFileExists) {
+ boolean stubConfigFileExists) {
RefreshConfigTask obj = spy(new RefreshConfigTask(appConfig, rics, policies, new Services(), new PolicyTypes(),
- new A1ClientFactory(appConfig)));
+ new A1ClientFactory(appConfig)));
if (stubConfigFileExists) {
doReturn(configFileExists).when(obj).fileExists(any());
}
@@ -163,12 +163,12 @@ class RefreshConfigTaskTest {
doReturn("fileName").when(appConfig).getLocalConfigurationFilePath();
StepVerifier //
- .create(refreshTaskUnderTest.createRefreshTask()) //
- .expectSubscription() //
- .expectNext(Type.ADDED) //
- .expectNext(Type.ADDED) //
- .thenCancel() //
- .verify();
+ .create(refreshTaskUnderTest.createRefreshTask()) //
+ .expectSubscription() //
+ .expectNext(Type.ADDED) //
+ .expectNext(Type.ADDED) //
+ .thenCancel() //
+ .verify();
// Then
verify(refreshTaskUnderTest).loadConfigurationFromFile();
@@ -194,11 +194,11 @@ class RefreshConfigTaskTest {
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
StepVerifier //
- .create(refreshTaskUnderTest.createRefreshTask()) //
- .expectSubscription() //
- .expectNoEvent(Duration.ofMillis(100)) //
- .thenCancel() //
- .verify();
+ .create(refreshTaskUnderTest.createRefreshTask()) //
+ .expectSubscription() //
+ .expectNoEvent(Duration.ofMillis(100)) //
+ .thenCancel() //
+ .verify();
// Then
verify(refreshTaskUnderTest).loadConfigurationFromFile();
@@ -206,7 +206,7 @@ class RefreshConfigTaskTest {
await().until(() -> logAppender.list.size() > 0);
assertThat(logAppender.list.get(0).getFormattedMessage())
- .startsWith("Local configuration file not loaded: fileName, ");
+ .startsWith("Local configuration file not loaded: fileName, ");
}
@Test
@@ -223,15 +223,15 @@ class RefreshConfigTaskTest {
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, WARN);
StepVerifier //
- .create(refreshTaskUnderTest.createRefreshTask()) //
- .expectSubscription() //
- .expectNoEvent(Duration.ofMillis(1000)) //
- .thenCancel() //
- .verify();
+ .create(refreshTaskUnderTest.createRefreshTask()) //
+ .expectSubscription() //
+ .expectNoEvent(Duration.ofMillis(1000)) //
+ .thenCancel() //
+ .verify();
await().until(() -> logAppender.list.size() > 0);
assertThat(logAppender.list.get(0).getFormattedMessage())
- .isEqualTo("Could not refresh application configuration. java.io.IOException");
+ .isEqualTo("Could not refresh application configuration. java.io.IOException");
}
@Test
@@ -262,13 +262,13 @@ class RefreshConfigTaskTest {
doNothing().when(refreshTaskUnderTest).runRicSynchronization(any(Ric.class));
StepVerifier //
- .create(refreshTaskUnderTest.createRefreshTask()) //
- .expectSubscription() //
- .expectNext(Type.CHANGED) //
- .expectNext(Type.ADDED) //
- .expectNext(Type.REMOVED) //
- .thenCancel() //
- .verify();
+ .create(refreshTaskUnderTest.createRefreshTask()) //
+ .expectSubscription() //
+ .expectNext(Type.CHANGED) //
+ .expectNext(Type.ADDED) //
+ .expectNext(Type.REMOVED) //
+ .thenCancel() //
+ .verify();
assertThat(appConfig.getRicConfigs()).hasSize(2);
assertThat(appConfig.getRic(RIC_1_NAME).baseUrl()).isEqualTo(newBaseUrl);
@@ -301,61 +301,61 @@ class RefreshConfigTaskTest {
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
StepVerifier //
- .create(refreshTaskUnderTest.createRefreshTask()) //
- .expectSubscription() //
- .expectNoEvent(Duration.ofMillis(1000)) //
- .thenCancel() //
- .verify();
+ .create(refreshTaskUnderTest.createRefreshTask()) //
+ .expectSubscription() //
+ .expectNoEvent(Duration.ofMillis(1000)) //
+ .thenCancel() //
+ .verify();
await().until(() -> logAppender.list.size() > 0);
assertThat(logAppender.list.get(0).getFormattedMessage()).startsWith(
- "Could not parse configuration org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException: ");
+ "Could not parse configuration org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException: ");
}
private RicConfig getRicConfig(String name) {
RicConfig ricConfig = ImmutableRicConfig.builder() //
- .ricId(name) //
- .baseUrl("url") //
- .managedElementIds(Collections.emptyList()) //
- .controllerName("controllerName") //
- .build();
+ .ricId(name) //
+ .baseUrl("url") //
+ .managedElementIds(Collections.emptyList()) //
+ .controllerName("controllerName") //
+ .build();
return ricConfig;
}
private Policy getPolicy(Ric ric) {
ImmutablePolicyType type = ImmutablePolicyType.builder() //
- .id("type") //
- .schema("{}") //
- .build();
+ .id("type") //
+ .schema("{}") //
+ .build();
Policy policy = ImmutablePolicy.builder() //
- .id("id") //
- .type(type) //
- .lastModified(Instant.now()) //
- .ric(ric) //
- .json("{}") //
- .ownerServiceId("ownerServiceId") //
- .isTransient(false) //
- .build();
+ .id("id") //
+ .type(type) //
+ .lastModified(Instant.now()) //
+ .ric(ric) //
+ .json("{}") //
+ .ownerServiceId("ownerServiceId") //
+ .isTransient(false) //
+ .build();
return policy;
}
ConfigParserResult configParserResult(RicConfig... rics) {
return ImmutableConfigParserResult.builder() //
- .ricConfigs(Arrays.asList(rics)) //
- .dmaapConsumerTopicUrl("") //
- .dmaapProducerTopicUrl("") //
- .controllerConfigs(new HashMap<>()) //
- .build();
+ .ricConfigs(Arrays.asList(rics)) //
+ .dmaapConsumerTopicUrl("") //
+ .dmaapProducerTopicUrl("") //
+ .controllerConfigs(new HashMap<>()) //
+ .build();
}
private void modifyTheRicConfiguration(JsonObject configAsJson, String newBaseUrl) {
((JsonObject) configAsJson.getAsJsonObject("config") //
- .getAsJsonArray("ric").get(0)) //
- .addProperty("baseUrl", newBaseUrl);
+ .getAsJsonArray("ric").get(0)) //
+ .addProperty("baseUrl", newBaseUrl);
}
private JsonObject getJsonRootObject(InputStream inStream)
- throws JsonIOException, JsonSyntaxException, IOException {
+ throws JsonIOException, JsonSyntaxException, IOException {
JsonObject rootObject = JsonParser.parseReader(new InputStreamReader(inStream)).getAsJsonObject();
return rootObject;
}
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 bb3b3461..25a7ddc4 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
@@ -60,37 +60,37 @@ import reactor.core.publisher.Mono;
class RicSupervisionTest {
private static final String POLICY_TYPE_1_NAME = "type1";
private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() //
- .id(POLICY_TYPE_1_NAME) //
- .schema("") //
- .build();
+ .id(POLICY_TYPE_1_NAME) //
+ .schema("") //
+ .build();
private static final Ric RIC_1 = new Ric(ImmutableRicConfig.builder() //
- .ricId("ric_1") //
- .baseUrl("baseUrl1") //
- .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) //
- .controllerName("controllerName") //
- .build());
+ .ricId("ric_1") //
+ .baseUrl("baseUrl1") //
+ .managedElementIds(new Vector<String>(Arrays.asList("kista_1", "kista_2"))) //
+ .controllerName("controllerName") //
+ .build());
private static final String POLICY_1_ID = "policyId1";
private static final Policy POLICY_1 = ImmutablePolicy.builder() //
- .id(POLICY_1_ID) //
- .json("") //
- .ownerServiceId("service") //
- .ric(RIC_1) //
- .type(POLICY_TYPE_1) //
- .lastModified(Instant.now()) //
- .isTransient(false) //
- .build();
+ .id(POLICY_1_ID) //
+ .json("") //
+ .ownerServiceId("service") //
+ .ric(RIC_1) //
+ .type(POLICY_TYPE_1) //
+ .lastModified(Instant.now()) //
+ .isTransient(false) //
+ .build();
private static final Policy POLICY_2 = ImmutablePolicy.builder() //
- .id("policyId2") //
- .json("") //
- .ownerServiceId("service") //
- .ric(RIC_1) //
- .type(POLICY_TYPE_1) //
- .lastModified(Instant.now()) //
- .isTransient(false) //
- .build();
+ .id("policyId2") //
+ .json("") //
+ .ownerServiceId("service") //
+ .ric(RIC_1) //
+ .type(POLICY_TYPE_1) //
+ .lastModified(Instant.now()) //
+ .isTransient(false) //
+ .build();
@Mock
private A1Client a1ClientMock;
@@ -285,9 +285,9 @@ class RicSupervisionTest {
void whenRicIdleAndSameAmountOfPolicyTypesButNotSameTypes_thenSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
PolicyType policyType2 = ImmutablePolicyType.builder() //
- .id("policyType2") //
- .schema("") //
- .build();
+ .id("policyType2") //
+ .schema("") //
+ .build();
RIC_1.setState(RicState.AVAILABLE);
RIC_1.addSupportedPolicyType(POLICY_TYPE_1);
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 93d252f7..e1c0c6b8 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
@@ -69,28 +69,28 @@ import reactor.core.publisher.Mono;
class RicSynchronizationTaskTest {
private static final String POLICY_TYPE_1_NAME = "type1";
private static final PolicyType POLICY_TYPE_1 = ImmutablePolicyType.builder() //
- .id(POLICY_TYPE_1_NAME) //
- .schema("") //
- .build();
+ .id(POLICY_TYPE_1_NAME) //
+ .schema("") //
+ .build();
private static final String RIC_1_NAME = "ric1";
private static final Ric RIC_1 = new Ric(ImmutableRicConfig.builder() //
- .ricId(RIC_1_NAME) //
- .baseUrl("baseUrl1") //
- .managedElementIds(Collections.emptyList()) //
- .controllerName("controllerName") //
- .build());
+ .ricId(RIC_1_NAME) //
+ .baseUrl("baseUrl1") //
+ .managedElementIds(Collections.emptyList()) //
+ .controllerName("controllerName") //
+ .build());
private static Policy createPolicy(String policyId, boolean isTransient) {
return ImmutablePolicy.builder() //
- .id(policyId) //
- .json("") //
- .ownerServiceId("service") //
- .ric(RIC_1) //
- .type(POLICY_TYPE_1) //
- .lastModified(Instant.now()) //
- .isTransient(isTransient) //
- .build();
+ .id(policyId) //
+ .json("") //
+ .ownerServiceId("service") //
+ .ric(RIC_1) //
+ .type(POLICY_TYPE_1) //
+ .lastModified(Instant.now()) //
+ .isTransient(isTransient) //
+ .build();
}
private static final Policy POLICY_1 = createPolicy("policyId1", false);
@@ -127,7 +127,7 @@ class RicSynchronizationTaskTest {
policies.put(POLICY_1);
RicSynchronizationTask synchronizerUnderTest =
- new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
+ new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
synchronizerUnderTest.run(RIC_1);
@@ -153,7 +153,7 @@ class RicSynchronizationTaskTest {
simulateRicWithOnePolicyType();
RicSynchronizationTask synchronizerUnderTest =
- spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services));
+ spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services));
AsyncRestClient restClientMock = setUpCreationOfAsyncRestClient(synchronizerUnderTest);
when(restClientMock.put(anyString(), anyString())).thenReturn(Mono.just("Ok"));
@@ -185,7 +185,7 @@ class RicSynchronizationTaskTest {
when(a1ClientMock.getPolicyTypeSchema(POLICY_TYPE_1_NAME)).thenReturn(Mono.just(typeSchema));
RicSynchronizationTask synchronizerUnderTest =
- new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
+ new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
synchronizerUnderTest.run(RIC_1);
@@ -214,7 +214,7 @@ class RicSynchronizationTaskTest {
when(a1ClientMock.putPolicy(any(Policy.class))).thenReturn(Mono.just("OK"));
RicSynchronizationTask synchronizerUnderTest =
- new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
+ new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
synchronizerUnderTest.run(RIC_1);
@@ -237,11 +237,11 @@ class RicSynchronizationTaskTest {
simulateRicWithNoPolicyTypes();
when(a1ClientMock.deleteAllPolicies()) //
- .thenReturn(Flux.error(new Exception("Exception"))) //
- .thenReturn(Flux.just("OK"));
+ .thenReturn(Flux.error(new Exception("Exception"))) //
+ .thenReturn(Flux.just("OK"));
RicSynchronizationTask synchronizerUnderTest =
- new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
+ new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
synchronizerUnderTest.run(RIC_1);
@@ -266,15 +266,15 @@ class RicSynchronizationTaskTest {
when(a1ClientMock.deleteAllPolicies()).thenReturn(Flux.error(new Exception(originalErrorMessage)));
RicSynchronizationTask synchronizerUnderTest =
- new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
+ new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services);
final ListAppender<ILoggingEvent> logAppender =
- LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN);
+ LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN);
synchronizerUnderTest.run(RIC_1);
verifyCorrectLogMessage(0, logAppender,
- "Synchronization failure for ric: " + RIC_1_NAME + ", reason: " + originalErrorMessage);
+ "Synchronization failure for ric: " + RIC_1_NAME + ", reason: " + originalErrorMessage);
verify(a1ClientMock, times(2)).deleteAllPolicies();
verifyNoMoreInteractions(a1ClientMock);
@@ -296,10 +296,10 @@ class RicSynchronizationTaskTest {
simulateRicWithOnePolicyType();
final ListAppender<ILoggingEvent> logAppender =
- LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN);
+ LoggingUtils.getLogListAppender(RicSynchronizationTask.class, WARN);
RicSynchronizationTask synchronizerUnderTest =
- spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services));
+ spy(new RicSynchronizationTask(a1ClientFactoryMock, policyTypes, policies, services));
AsyncRestClient restClientMock = setUpCreationOfAsyncRestClient(synchronizerUnderTest);
String originalErrorMessage = "Exception";
@@ -310,7 +310,7 @@ class RicSynchronizationTaskTest {
ILoggingEvent loggingEvent = logAppender.list.get(0);
assertThat(loggingEvent.getLevel()).isEqualTo(WARN);
verifyCorrectLogMessage(0, logAppender,
- "Service notification failed for service: " + SERVICE_1_NAME + ". Cause: " + originalErrorMessage);
+ "Service notification failed for service: " + SERVICE_1_NAME + ". Cause: " + originalErrorMessage);
}
private void setUpCreationOfA1Client() {
@@ -333,7 +333,7 @@ class RicSynchronizationTaskTest {
}
private void verifyCorrectLogMessage(int messageIndex, ListAppender<ILoggingEvent> logAppender,
- String expectedMessage) {
+ String expectedMessage) {
ILoggingEvent loggingEvent = logAppender.list.get(messageIndex);
assertThat(loggingEvent.getFormattedMessage()).isEqualTo(expectedMessage);
}
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 3e7bea64..1a8e9b3e 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
@@ -72,25 +72,25 @@ class ServiceSupervisionTest {
private Service service;
private Policies policies;
private RicConfig ricConfig = ImmutableRicConfig.builder() //
- .ricId(RIC_NAME) //
- .baseUrl("baseUrl") //
- .managedElementIds(Collections.emptyList()) //
- .controllerName("") //
- .build();
+ .ricId(RIC_NAME) //
+ .baseUrl("baseUrl") //
+ .managedElementIds(Collections.emptyList()) //
+ .controllerName("") //
+ .build();
private Ric ric = new Ric(ricConfig);
private PolicyType policyType = ImmutablePolicyType.builder() //
- .id("policyTypeName") //
- .schema("schema") //
- .build();
+ .id("policyTypeName") //
+ .schema("schema") //
+ .build();
private Policy policy = ImmutablePolicy.builder() //
- .id(POLICY_ID) //
- .json("json") //
- .ownerServiceId(SERVICE_NAME) //
- .ric(ric) //
- .type(policyType) //
- .lastModified(Instant.now()) //
- .isTransient(false) //
- .build();
+ .id(POLICY_ID) //
+ .json("json") //
+ .ownerServiceId(SERVICE_NAME) //
+ .ric(ric) //
+ .type(policyType) //
+ .lastModified(Instant.now()) //
+ .isTransient(false) //
+ .build();
@Test
void serviceExpired_policyAndServiceAreDeletedInRepoAndPolicyIsDeletedInRic() {
@@ -100,7 +100,7 @@ class ServiceSupervisionTest {
when(a1ClientMock.deletePolicy(any(Policy.class))).thenReturn(Mono.just("Policy deleted"));
ServiceSupervision serviceSupervisionUnderTest =
- new ServiceSupervision(services, policies, a1ClientFactoryMock);
+ new ServiceSupervision(services, policies, a1ClientFactoryMock);
await().atMost(Durations.FIVE_SECONDS).with().pollInterval(Durations.ONE_SECOND).until(service::isExpired);
@@ -122,7 +122,7 @@ class ServiceSupervisionTest {
when(a1ClientMock.deletePolicy(any(Policy.class))).thenReturn(Mono.error(new Exception(originalErrorMessage)));
ServiceSupervision serviceSupervisionUnderTest =
- new ServiceSupervision(services, policies, a1ClientFactoryMock);
+ new ServiceSupervision(services, policies, a1ClientFactoryMock);
await().atMost(Durations.FIVE_SECONDS).with().pollInterval(Durations.ONE_SECOND).until(service::isExpired);
@@ -136,7 +136,7 @@ class ServiceSupervisionTest {
ILoggingEvent loggingEvent = logAppender.list.get(0);
assertThat(loggingEvent.getLevel()).isEqualTo(WARN);
String expectedLogMessage =
- "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage;
+ "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage;
assertThat(loggingEvent.getFormattedMessage()).isEqualTo(expectedLogMessage);
}
@@ -145,7 +145,7 @@ class ServiceSupervisionTest {
setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
ServiceSupervision serviceSupervisionUnderTest =
- new ServiceSupervision(services, policies, a1ClientFactoryMock);
+ new ServiceSupervision(services, policies, a1ClientFactoryMock);
serviceSupervisionUnderTest.checkAllServices().blockLast();
@@ -161,7 +161,7 @@ class ServiceSupervisionTest {
setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(0));
ServiceSupervision serviceSupervisionUnderTest =
- new ServiceSupervision(services, policies, a1ClientFactoryMock);
+ new ServiceSupervision(services, policies, a1ClientFactoryMock);
serviceSupervisionUnderTest.checkAllServices().blockLast();
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java
index 14de691d..482fa395 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/utils/MockA1Client.java
@@ -101,7 +101,7 @@ public class MockA1Client implements A1Client {
public Flux<String> deleteAllPolicies() {
this.policies.clear();
return mono("OK") //
- .flatMapMany(Flux::just);
+ .flatMapMany(Flux::just);
}
@Override
@@ -120,7 +120,7 @@ public class MockA1Client implements A1Client {
Mono<String> monoError(String responseBody, HttpStatus status) {
byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8);
WebClientResponseException a1Exception = new WebClientResponseException(status.value(),
- status.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null);
+ status.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null);
return Mono.error(a1Exception);
}