summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2020-08-21 11:35:17 +0200
committerPatrik Buhr <patrik.buhr@est.tech>2020-08-25 13:32:57 +0000
commit4b4404a2ab0b239a1cc17510196195ec599d66ae (patch)
tree0930db90300985f24c2a63fac56ce903d7076859
parent923196e662717d8e631d89d29818b88db17e320a (diff)
Some improvements if NBI V2.0
Improved generated swagger API. Furter alignments to https://opensource.zalando.com/restful-api-guidelines/#118 Improved unitttest for faulty JSON in configuration. Changed names: "NonRT-RIC" to "Non-RT RIC" and "NearRT-RIC" to "Near-RT RIC" Change-Id: I4ca0d45605a770b5c33e34019671e088e3fe979d Issue-ID: CCSDK-2498 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
-rw-r--r--a1-policy-management/api/api.yaml12
-rw-r--r--a1-policy-management/api/api_generated.yaml138
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java36
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java10
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/SdncOscA1Client.java4
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java41
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyInfo.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicRepositoryController.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonObject.java4
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonSchema.java30
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java46
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicySchemaList.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java14
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java4
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicRepositoryController.java46
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java22
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java8
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java4
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java2
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java35
23 files changed, 237 insertions, 236 deletions
diff --git a/a1-policy-management/api/api.yaml b/a1-policy-management/api/api.yaml
index b41d4fc0..ac10f4b6 100644
--- a/a1-policy-management/api/api.yaml
+++ b/a1-policy-management/api/api.yaml
@@ -76,7 +76,7 @@ paths:
parameters:
- name: id
in: query
- description: The ID of the policy instance.
+ description: The identity of the policy instance.
required: true
allowEmptyValue: false
schema:
@@ -110,7 +110,7 @@ paths:
parameters:
- name: id
in: query
- description: The ID of the policy instance.
+ description: The identity of the policy instance.
required: true
allowEmptyValue: false
schema:
@@ -184,7 +184,7 @@ paths:
parameters:
- name: id
in: query
- description: The ID of the policy instance.
+ description: The identity of the policy instance.
required: true
allowEmptyValue: false
schema:
@@ -268,7 +268,7 @@ paths:
parameters:
- name: id
in: query
- description: The ID of the policy type to get the definition for.
+ description: The identity of the policy type to get the definition for.
required: true
allowEmptyValue: false
schema:
@@ -386,7 +386,7 @@ paths:
parameters:
- name: id
in: query
- description: The ID of the policy.
+ description: The identity of the policy.
required: true
allowEmptyValue: false
schema:
@@ -461,7 +461,7 @@ paths:
parameters:
- name: managedElementId
in: query
- description: The ID of the Managed Element
+ description: The identity of the Managed Element
required: true
allowEmptyValue: false
schema:
diff --git a/a1-policy-management/api/api_generated.yaml b/a1-policy-management/api/api_generated.yaml
index 06bbf334..fd7b3129 100644
--- a/a1-policy-management/api/api_generated.yaml
+++ b/a1-policy-management/api/api_generated.yaml
@@ -1,27 +1,22 @@
swagger: '2.0'
info:
- description: |
- The O-RAN NonRT-RIC PolicyAgent provides a REST API for management of policices.
- It provides support for:
- -Supervision of clients (R-APPs) to eliminate stray policies in case of failure
- -Consistency monitoring of the SMO view of policies and the actual situation in the NearRT-RICs
- -Consistency monitoring of NearRT-RIC capabilities (policy types)-Policy configuration.
- This includes:-One REST API towards all NearRT-RICs in the network
- -Query functions that can find all policies in a NearRT-RIC, all policies owned by a service (R-APP),
- all policies of a type etc.
- -Maps O1 resources (ManagedElement) as defined in O1 to the controlling NearRT-RIC of A1 policices.
+ description: |-
+ The O-RAN Non-RT RIC Policy Management Service provides a REST API for management of A1 policices.
+ 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>
version: 1.1.0
title: A1 Policy management service
contact:
name: Ericsson Software Technology
email: nonrtric@est.tech
+ x-api-id: 60f9a0e7-343f-43bf-9194-d8d65688d465
+ x-audience: external-partner
host: 'localhost:8081'
basePath: /
tags:
- name: A1 Policy Management Version 1.0
description: Policy Controller
- name: A1 Policy Management Version 2.0 (in progress)
- description: Policy Controller
+ description: Policy management
paths:
/policies:
get:
@@ -34,7 +29,7 @@ paths:
parameters:
- name: ric
in: query
- description: The name of the NearRT-RIC to get policies for.
+ description: The name of the Near-RT RIC to get policies for.
required: false
type: string
allowEmptyValue: false
@@ -62,7 +57,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC or type not found
+ description: Near-RT RIC or type not found
schema:
type: string
deprecated: false
@@ -117,7 +112,7 @@ paths:
type: object
- name: ric
in: query
- description: The name of the NearRT-RIC where the policy will be created.
+ description: The name of the Near-RT RIC where the policy will be created.
required: true
type: string
allowEmptyValue: false
@@ -129,7 +124,7 @@ paths:
allowEmptyValue: false
- name: transient
in: query
- description: 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 NearRT-RIC.
+ description: 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.
required: false
type: boolean
default: false
@@ -151,11 +146,11 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC or policy type is not found
+ description: Near-RT RIC or policy type is not found
schema:
type: string
'423':
- description: NearRT-RIC is not operational
+ description: Near-RT RIC is not operational
schema:
type: string
deprecated: false
@@ -187,7 +182,7 @@ paths:
schema:
type: string
'423':
- description: NearRT-RIC is not operational
+ description: Near-RT RIC is not operational
schema:
type: string
deprecated: false
@@ -195,14 +190,14 @@ paths:
get:
tags:
- A1 Policy Management Version 1.0
- summary: 'Query policies, only IDs returned'
+ summary: 'Query policies, only policy identities returned'
operationId: getPolicyIdsUsingGET_1
produces:
- '*/*'
parameters:
- name: ric
in: query
- description: The name of the NearRT-RIC to get policies for.
+ description: The name of the Near-RT RIC to get policies for.
required: false
type: string
allowEmptyValue: false
@@ -220,7 +215,7 @@ paths:
allowEmptyValue: false
responses:
'200':
- description: Policy ids
+ description: Policy identitiess
schema:
type: array
items:
@@ -230,7 +225,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC or type not found
+ description: Near-RT RIC or type not found
schema:
type: string
deprecated: false
@@ -274,7 +269,7 @@ paths:
parameters:
- name: ric
in: query
- description: The name of the NearRT-RIC to get the definitions for.
+ description: The name of the Near-RT RIC to get the definitions for.
required: false
type: string
allowEmptyValue: false
@@ -290,7 +285,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
type: string
deprecated: false
@@ -334,7 +329,7 @@ paths:
parameters:
- name: ric
in: query
- description: The name of the NearRT-RIC to get types for.
+ description: The name of the Near-RT RIC to get types for.
required: false
type: string
allowEmptyValue: false
@@ -350,7 +345,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
type: string
deprecated: false
@@ -371,7 +366,7 @@ paths:
allowEmptyValue: false
responses:
'200':
- description: NearRT-RIC is found
+ description: Near-RT RIC is found
schema:
type: string
'401':
@@ -379,7 +374,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
type: string
deprecated: false
@@ -387,7 +382,7 @@ paths:
get:
tags:
- A1 Policy Management Version 1.0
- summary: Query NearRT-RIC information
+ summary: Query Near-RT RIC information
operationId: getRicsUsingGET
produces:
- '*/*'
@@ -569,8 +564,8 @@ paths:
get:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: Query policies
- description: 'If several query parameters are defined, the policies matching all conditions are returned'
+ summary: Query for existing A1 policies
+ description: 'Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.'
operationId: getPoliciesUsingGET
produces:
- application/json
@@ -583,7 +578,7 @@ paths:
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of the NearRT-RIC to get policies for.
+ description: The identity of the Near-RT RIC to get policies for.
required: false
type: string
allowEmptyValue: false
@@ -603,7 +598,7 @@ paths:
'403':
description: Forbidden
'404':
- description: 'NearRT-RIC, policy type or service not found'
+ description: 'Near-RT RIC, policy type or service not found'
schema:
$ref: '#/definitions/error_information'
deprecated: false
@@ -666,7 +661,7 @@ paths:
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of the NearRT-RIC where the policy will be created.
+ description: The identity of the Near-RT RIC where the policy will be created.
required: true
type: string
allowEmptyValue: false
@@ -678,7 +673,7 @@ paths:
allowEmptyValue: false
- name: transient
in: query
- description: If the policy is transient or not (boolean defaulted to false). A policy is transient if it will not be recreated in the NearRT-RIC when it has been lost (for instance due to a restart)
+ description: 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)
required: false
type: boolean
default: false
@@ -694,11 +689,11 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC or policy type is not found
+ description: Near-RT RIC or policy type is not found
schema:
$ref: '#/definitions/error_information'
'423':
- description: NearRT-RIC is not operational
+ description: Near-RT RIC is not operational
schema:
$ref: '#/definitions/error_information'
deprecated: false
@@ -730,7 +725,7 @@ paths:
schema:
$ref: '#/definitions/error_information'
'423':
- description: NearRT-RIC is not operational
+ description: Near-RT RIC is not operational
schema:
$ref: '#/definitions/error_information'
deprecated: false
@@ -738,7 +733,8 @@ paths:
get:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: 'Query policies, only IDs returned'
+ summary: 'Query policies, only policy identities are returned'
+ description: 'Returns a list of A1 policies matching given search criteria. <br>If several query parameters are defined, the policies matching all conditions are returned.'
operationId: getPolicyIdsUsingGET
produces:
- application/json
@@ -751,7 +747,7 @@ paths:
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of the NearRT-RIC to get policies for.
+ description: The identity of the Near-RT RIC to get policies for.
required: false
type: string
allowEmptyValue: false
@@ -763,7 +759,7 @@ paths:
allowEmptyValue: false
responses:
'200':
- description: Policy ids
+ description: Policy identities
schema:
$ref: '#/definitions/policy_id_list_v2'
'401':
@@ -771,7 +767,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC or type not found
+ description: Near-RT RIC or type not found
schema:
$ref: '#/definitions/error_information'
deprecated: false
@@ -792,7 +788,7 @@ paths:
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of the NearRT-RIC to get the definitions for.
+ description: The identity of the Near-RT RIC to get the definitions for.
required: false
type: string
allowEmptyValue: false
@@ -806,7 +802,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
$ref: '#/definitions/error_information'
deprecated: false
@@ -850,7 +846,7 @@ paths:
parameters:
- name: ric_id
in: query
- description: The identity of the NearRT-RIC to get types for.
+ description: The identity of the Near-RT RIC to get types for.
required: false
type: string
allowEmptyValue: false
@@ -864,7 +860,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
$ref: '#/definitions/error_information'
deprecated: false
@@ -872,26 +868,27 @@ paths:
get:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: Returns info for the NearRT-RIC with the given identity or managing one Mananged Element
+ summary: Returns info for a Near-RT RIC
+ description: 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).
operationId: getRicUsingGET_1
produces:
- application/json
parameters:
- name: managed_element_id
in: query
- description: 'The identity of a Managed Element. If given, the NearRT-RIC managing the ME is returned.'
+ description: 'The identity of a Managed Element. If given, the Near-RT RIC managing the ME is returned.'
required: false
type: string
allowEmptyValue: false
- name: ric_id
in: query
- description: The identity of a NearRT-RIC to get information for.
+ description: The identity of a Near-RT RIC to get information for.
required: false
type: string
allowEmptyValue: false
responses:
'200':
- description: NearRT-RIC is found
+ description: Near-RT RIC is found
schema:
$ref: '#/definitions/ric_info_v2'
'401':
@@ -899,7 +896,7 @@ paths:
'403':
description: Forbidden
'404':
- description: NearRT-RIC is not found
+ description: Near-RT RIC is not found
schema:
$ref: '#/definitions/error_information'
deprecated: false
@@ -907,14 +904,15 @@ paths:
get:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: Query NearRT-RIC information
+ summary: Query Near-RT RIC information
+ description: The call returns all Near-RT RICs that supports a given policy type identity
operationId: getRicsUsingGET_1
produces:
- application/json
parameters:
- name: policytype_id
in: query
- description: 'The identity of a policy type. If given, all NearRT-RICs supporteing the policy type are returned'
+ description: 'The identity of a policy type. If given, all Near-RT RICs supporteing the policy type are returned'
required: false
type: string
allowEmptyValue: false
@@ -937,6 +935,7 @@ paths:
tags:
- A1 Policy Management Version 2.0 (in progress)
summary: Returns service information
+ description: Either information about a registered service with given identity or all registered services are returned.
operationId: getServicesUsingGET
produces:
- application/json
@@ -965,6 +964,7 @@ paths:
tags:
- A1 Policy Management Version 2.0 (in progress)
summary: Register a service
+ description: '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>'
operationId: putServiceUsingPUT
consumes:
- application/json
@@ -1000,14 +1000,14 @@ paths:
delete:
tags:
- A1 Policy Management Version 2.0 (in progress)
- summary: Delete a service
+ summary: Unregister a service
operationId: deleteServiceUsingDELETE
produces:
- '*/*'
parameters:
- name: service_id
in: query
- description: The name of the service
+ description: The idenitity of the service
required: true
type: string
allowEmptyValue: false
@@ -1015,7 +1015,7 @@ paths:
'200':
description: Not used
'204':
- description: Service deleted
+ description: Service unregistered
schema:
type: object
'401':
@@ -1104,7 +1104,7 @@ definitions:
json_object:
type: object
title: json_object
- description: A JSON object. The schema is defined by the Policy Type
+ description: A JSON object defining the configuration of the policy. The schema is defined by the Policy Type.
policy_id_list_v2:
type: object
properties:
@@ -1139,7 +1139,7 @@ definitions:
description: 'timestamp, last modification time'
ric:
type: string
- description: identity of the target NearRT-RIC
+ description: identity of the target Near-RT RIC
service:
type: string
description: the name of the service owning the policy
@@ -1164,7 +1164,7 @@ definitions:
description: name of the policy type
ric_id:
type: string
- description: identity of the target NearRT-RIC
+ description: identity of the target Near-RT RIC
service_id:
type: string
description: the name of the service owning the policy
@@ -1175,7 +1175,7 @@ definitions:
properties:
policy_schemas:
type: array
- description: Policy type json schemas
+ description: 'Policy type json schemas. The schema is a json object following http://json-schema.org/draft-07/schema'
items:
type: object
title: policy_schema_list_v2
@@ -1195,11 +1195,11 @@ definitions:
properties:
rics:
type: array
- description: List of NearRT-RIC information
+ description: List of Near-RT RIC information
items:
$ref: '#/definitions/ric_info_v2'
title: ric_info_list_v2
- description: List of NearRT-RIC information
+ description: List of Near-RT RIC information
ric_info_v1:
type: object
properties:
@@ -1215,7 +1215,7 @@ definitions:
type: string
ricName:
type: string
- description: identity of the NearRT-RIC
+ description: identity of the Near-RT RIC
state:
type: string
description: state info
@@ -1235,22 +1235,22 @@ definitions:
type: string
ric_id:
type: string
- description: identity of the NearRT-RIC
+ description: identity of the Near-RT RIC
state:
type: string
description: |-
- State for the NearRT-RIC, values:
- UNAVAILABLE: The NearRT-RIC is not avialable, information may be inconsistent
+ State for the Near-RT RIC, values:
+ UNAVAILABLE: The Near-RT RIC is not avialable, information may be inconsistent
AVAILABLE: The normal state. Policies can be configured. +
- SYNCHRONIZING: The Policy Management Service is synchronizing the view of the NearRT-RIC. Policies cannot be configured.
- CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the NearRT-RIC. Policies cannot be configured.
+ SYNCHRONIZING: The Policy Management Service is synchronizing the view of the Near-RT RIC. Policies cannot be configured.
+ CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the Near-RT RIC. Policies cannot be configured.
enum:
- UNAVAILABLE
- AVAILABLE
- SYNCHRONIZING
- CONSISTENCY_CHECK
title: ric_info_v2
- description: Information for a NearRT-RIC
+ description: Information for a Near-RT RIC
service_list_v2:
type: object
properties:
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 4b684288..a5636592 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
@@ -22,6 +22,9 @@ package org.onap.ccsdk.oran.a1policymanagementservice;
import com.google.common.base.Predicates;
+import java.util.ArrayList;
+import java.util.List;
+
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
@@ -32,6 +35,8 @@ import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
+import springfox.documentation.service.StringVendorExtension;
+import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@@ -48,16 +53,16 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
public class SwaggerConfig extends WebMvcConfigurationSupport {
static final String API_TITLE = "A1 Policy management service";
- static final String DESCRIPTION =
- "The O-RAN NonRT-RIC PolicyAgent provides a REST API for management of policices. \n"
- + "It provides support for: \n"
- + "-Supervision of clients (R-APPs) to eliminate stray policies in case of failure \n"
- + "-Consistency monitoring of the SMO view of policies and the actual situation in the NearRT-RICs \n"
- + "-Consistency monitoring of NearRT-RIC capabilities (policy types)" + "-Policy configuration. \n"
- + "This includes:" + "-One REST API towards all NearRT-RICs in the network \n"
- + "-Query functions that can find all policies in a NearRT-RIC, all policies owned by a service (R-APP), \n"
- + "all policies of a type etc. \n"
- + "-Maps O1 resources (ManagedElement) as defined in O1 to the controlling NearRT-RIC of A1 policices.\n";
+ 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>"//
+ ;
static final String VERSION = "1.1.0";
@SuppressWarnings("squid:S1075") // Refactor your code to get this URI from a customizable parameter.
static final String RESOURCES_PATH = "classpath:/META-INF/resources/";
@@ -90,9 +95,20 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
.description(DESCRIPTION) //
.version(VERSION) //
.contact(contact()) //
+ .extensions(vendorExtentions()) //
.build();
}
+ @SuppressWarnings("rawtypes") // VendorExtension is a raw type. References to generic type VendorExtension<T>
+ // should be parameterizedJava(16777788)
+ private static List<VendorExtension> vendorExtentions() {
+ final String URN = "60f9a0e7-343f-43bf-9194-d8d65688d465";
+ List<VendorExtension> extentions = new ArrayList<>();
+ extentions.add(new StringVendorExtension("x-api-id", URN));
+ extentions.add(new StringVendorExtension("x-audience", "external-partner"));
+ return extentions;
+ }
+
private static Contact contact() {
return new Contact("Ericsson Software Technology", "", "nonrtric@est.tech");
}
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 2b493575..31a706b4 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
@@ -60,9 +60,9 @@ public class A1ClientFactory {
* means that after the first successful creation it won't have to try which
* protocol to use, but can create the client directly.
*
- * @param ric The NearRT-RIC to get a client for.
+ * @param ric The Near-RT RIC to get a client for.
* @return a client with the correct protocol, or a ServiceException if none of
- * the protocols are supported by the NearRT-RIC.
+ * the protocols are supported by the Near-RT RIC.
*/
public Mono<A1Client> createA1Client(Ric ric) {
return getProtocolVersion(ric) //
@@ -91,7 +91,7 @@ public class A1ClientFactory {
String controllerName = ric.getConfig().controllerName();
if (controllerName.isEmpty()) {
ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
- throw new ServiceException("No controller configured for NearRT-RIC: " + ric.id());
+ throw new ServiceException("No controller configured for Near-RT RIC: " + ric.id());
}
try {
return this.appConfig.getControllerConfig(controllerName);
@@ -125,8 +125,8 @@ public class A1ClientFactory {
.onErrorResume(notUsed -> fetchVersion(ric, A1ProtocolType.SDNC_ONAP)) //
.doOnNext(ric::setProtocolVersion)
.doOnNext(
- version -> logger.debug("Established protocol version:{} for NearRT-RIC: {}", version, ric.id())) //
- .doOnError(notUsed -> logger.warn("Could not get protocol version from NearRT-RIC: {}", ric.id())) //
+ 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 {
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 dffb9dd8..4ad08ce2 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
@@ -83,7 +83,7 @@ public class SdncOscA1Client implements A1Client {
*
* @param protocolType the southbound protocol of the controller. Supported
* protocols are SDNC_OSC_STD_V1_1 and SDNC_OSC_OSC_V1
- * @param ricConfig the configuration of the NearRT-RIC to communicate
+ * @param ricConfig the configuration of the Near-RT RIC to communicate
* with
* @param controllerConfig the configuration of the SDNC controller to use
*
@@ -101,7 +101,7 @@ public class SdncOscA1Client implements A1Client {
*
* @param protocolType the southbound protocol of the controller. Supported
* protocols are SDNC_OSC_STD_V1_1 and SDNC_OSC_OSC_V1
- * @param ricConfig the configuration of the NearRT-RIC to communicate
+ * @param ricConfig the configuration of the Near-RT RIC to communicate
* with
* @param controllerConfig the configuration of the SDNC controller to use
* @param restClient the REST client to use
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 2c8ad7f2..90666e7a 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
@@ -100,9 +100,9 @@ public class PolicyController {
@ApiResponses(
value = {
@ApiResponse(code = 200, message = "Policy schemas", response = Object.class, responseContainer = "List"), //
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class)})
+ @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 NearRT-RIC to get the definitions for.") //
+ @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();
@@ -143,9 +143,9 @@ public class PolicyController {
message = "Policy type names",
response = String.class,
responseContainer = "List"),
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class)})
+ @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 NearRT-RIC to get types for.") //
+ @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();
@@ -185,7 +185,7 @@ public class PolicyController {
@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 = "NearRT-RIC is not operational", 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) {
@@ -208,27 +208,27 @@ public class PolicyController {
}
@PutMapping(path = "/policy")
- @ApiOperation(value = "Put a policy", response = String.class)
+ @ApiOperation(value = "Put a policy", response = VoidResponse.class)
@ApiResponses(
value = { //
@ApiResponse(code = 201, message = "Policy created", response = VoidResponse.class), //
@ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), //
- @ApiResponse(code = 423, message = "NearRT-RIC is not operational", response = String.class), //
- @ApiResponse(code = 404, message = "NearRT-RIC or policy type is not found", response = String.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 NearRT-RIC where the policy will be " + //
+ @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 NearRT-RIC.") //
+ "reconnect to the Near-RT RIC.") //
@RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, //
@RequestBody Object jsonBody) {
@@ -321,11 +321,11 @@ public class PolicyController {
@ApiResponses(
value = {
@ApiResponse(code = 200, message = "Policies", response = PolicyInfo.class, responseContainer = "List"),
- @ApiResponse(code = 404, message = "NearRT-RIC or type not found", response = String.class)})
+ @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 NearRT-RIC to get policies for.") //
+ @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) //
@@ -334,7 +334,7 @@ public class PolicyController {
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
}
if ((ric != null && this.rics.get(ric) == null)) {
- return new ResponseEntity<>("NearRT-RIC not found", HttpStatus.NOT_FOUND);
+ return new ResponseEntity<>("Near-RT RIC not found", HttpStatus.NOT_FOUND);
}
String filteredPolicies = policiesToJson(filter(type, ric, service));
@@ -342,14 +342,19 @@ public class PolicyController {
}
@GetMapping("/policy_ids")
- @ApiOperation(value = "Query policies, only IDs returned")
+ @ApiOperation(value = "Query policies, only policy identities returned")
@ApiResponses(
- value = {@ApiResponse(code = 200, message = "Policy ids", response = String.class, responseContainer = "List"),
- @ApiResponse(code = 404, message = "NearRT-RIC or type not found", response = String.class)})
+ 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 NearRT-RIC to get policies for.") //
+ @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) //
@@ -358,7 +363,7 @@ public class PolicyController {
return new ResponseEntity<>("Policy type not found", HttpStatus.NOT_FOUND);
}
if ((ric != null && this.rics.get(ric) == null)) {
- return new ResponseEntity<>("NearRT-RIC not found", HttpStatus.NOT_FOUND);
+ return new ResponseEntity<>("Near-RT RIC not found", HttpStatus.NOT_FOUND);
}
String policyIdsJson = toPolicyIdsJson(filter(type, ric, service));
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 4cb91c0d..c4862016 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
@@ -35,7 +35,7 @@ public class PolicyInfo {
@ApiModelProperty(value = "name of the policy type")
public String type;
- @ApiModelProperty(value = "identity of the target NearRT-RIC")
+ @ApiModelProperty(value = "identity of the target Near-RT RIC")
public String ric;
@ApiModelProperty(value = "the configuration of the policy")
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java
index 4257a263..467afdb9 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/RicInfo.java
@@ -30,7 +30,7 @@ import org.immutables.gson.Gson;
@Gson.TypeAdapters
@ApiModel(value = "ric_info_v1")
class RicInfo {
- @ApiModelProperty(value = "identity of the NearRT-RIC")
+ @ApiModelProperty(value = "identity of the Near-RT RIC")
public final String ricName;
@ApiModelProperty(value = "O1 identities for managed entities")
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 5036356e..cd56abda 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
@@ -64,8 +64,8 @@ public class RicRepositoryController {
@ApiOperation(value = "Returns the name of a RIC managing one Mananged Element")
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "NearRT-RIC is found", response = String.class), //
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = String.class) //
+ @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") //
@@ -83,7 +83,7 @@ public class RicRepositoryController {
* @return a Json array of all RIC data Example: http://localhost:8081/ric
*/
@GetMapping("/rics")
- @ApiOperation(value = "Query NearRT-RIC information")
+ @ApiOperation(value = "Query Near-RT RIC information")
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "OK", response = RicInfo.class, responseContainer = "List"), //
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 9290ca07..22227656 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,6 +25,8 @@ import io.swagger.annotations.ApiModel;
import org.immutables.gson.Gson;
@Gson.TypeAdapters
-@ApiModel(value = "json_object", description = "A JSON object. 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/JsonSchema.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonSchema.java
deleted file mode 100644
index ff1b8edc..00000000
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/JsonSchema.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ======================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- */
-
-package org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2;
-
-import io.swagger.annotations.ApiModel;
-
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
-@ApiModel(value = "json_schema", description = "A JSON schema following http://json-schema.org/draft-07/schema")
-class JsonSchema {
-}
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 9bf6c4b5..9d9aff45 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
@@ -66,7 +66,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti
import reactor.core.publisher.Mono;
@RestController("PolicyControllerV2")
-@Api(tags = Consts.V2_API_NAME)
+@Api(tags = {Consts.V2_API_NAME}, description = "Policy management")
public class PolicyController {
public static class RejectionException extends Exception {
@@ -102,12 +102,12 @@ public class PolicyController {
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "Policy schemas", response = PolicySchemaList.class), //
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.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 NearRT-RIC to get the definitions for.") //
+ 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,
@@ -141,12 +141,12 @@ public class PolicyController {
@ApiOperation(value = "Query policy type identities", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
value = {@ApiResponse(code = 200, message = "Policy type IDs", response = PolicyTypeIdList.class),
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.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 NearRT-RIC to get types for.") //
+ 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();
@@ -188,7 +188,7 @@ public class PolicyController {
@ApiResponse(code = 404, message = "Policy is not found", response = ErrorResponse.ErrorInfo.class),
@ApiResponse(
code = 423,
- message = "NearRT-RIC is not operational",
+ 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.") //
@@ -219,11 +219,11 @@ public class PolicyController {
@ApiResponse(code = 200, message = "Policy updated", response = VoidResponse.class), //
@ApiResponse(
code = 423,
- message = "NearRT-RIC is not operational",
+ message = "Near-RT RIC is not operational",
response = ErrorResponse.ErrorInfo.class), //
@ApiResponse(
code = 404,
- message = "NearRT-RIC or policy type is not found",
+ message = "Near-RT RIC or policy type is not found",
response = ErrorResponse.ErrorInfo.class) //
})
public Mono<ResponseEntity<Object>> putPolicy( //
@@ -234,7 +234,7 @@ public class PolicyController {
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = true,
- value = "The identity of the NearRT-RIC where the policy will be " + //
+ 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(
@@ -246,7 +246,7 @@ public class PolicyController {
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 NearRT-RIC " + //
+ "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) {
@@ -256,7 +256,7 @@ public class PolicyController {
PolicyType type = policyTypes.get(policyTypeId);
keepServiceAlive(serviceId);
if (ric == null || type == null) {
- return ErrorResponse.createMono("NearRT-RIC or policy type not found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.createMono("Near-RT RIC or policy type not found", HttpStatus.NOT_FOUND);
}
Policy policy = ImmutablePolicy.builder() //
.id(instanceId) //
@@ -329,16 +329,18 @@ public class PolicyController {
}
}
+ 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.";
+
@GetMapping(path = Consts.V2_API_ROOT + "/policies", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(
- value = "Query policies",
- notes = "If several query parameters are defined, the policies matching all conditions are returned")
+ @ApiOperation(value = "Query for existing A1 policies", notes = GET_POLICIES_QUERY_DETAILS)
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "Policies", response = PolicyInfoList.class),
@ApiResponse(
code = 404,
- message = "NearRT-RIC, policy type or service not found",
+ message = "Near-RT RIC, policy type or service not found",
response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicies( //
@ApiParam(
@@ -349,7 +351,7 @@ public class PolicyController {
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = false,
- value = "The identity of the NearRT-RIC to get policies for.") //
+ 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,
@@ -361,7 +363,7 @@ public class PolicyController {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
}
if ((ric != null && this.rics.get(ric) == null)) {
- return ErrorResponse.create("NearRT-RIC not found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.create("Near-RT RIC not found", HttpStatus.NOT_FOUND);
}
String filteredPolicies = policiesToJson(filter(type, ric, service));
@@ -369,13 +371,13 @@ public class PolicyController {
}
@GetMapping(path = Consts.V2_API_ROOT + "/policy-ids", produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Query policies, only IDs returned")
+ @ApiOperation(value = "Query policies, only policy identities are returned", notes = GET_POLICIES_QUERY_DETAILS)
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "Policy ids", response = PolicyIdList.class),
+ @ApiResponse(code = 200, message = "Policy identities", response = PolicyIdList.class),
@ApiResponse(
code = 404,
- message = "NearRT-RIC or type not found",
+ message = "Near-RT RIC or type not found",
response = ErrorResponse.ErrorInfo.class)})
public ResponseEntity<Object> getPolicyIds( //
@ApiParam(
@@ -386,7 +388,7 @@ public class PolicyController {
@ApiParam(
name = Consts.RIC_ID_PARAM,
required = false,
- value = "The identity of the NearRT-RIC to get policies for.") //
+ 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,
@@ -398,7 +400,7 @@ public class PolicyController {
return ErrorResponse.create("Policy type not found", HttpStatus.NOT_FOUND);
}
if ((ricId != null && this.rics.get(ricId) == null)) {
- return ErrorResponse.create("NearRT-RIC not found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.create("Near-RT RIC not found", HttpStatus.NOT_FOUND);
}
String policyIdsJson = toPolicyIdsJson(filter(policyTypeId, ricId, serviceId));
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 4ba3dc79..673c9455 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
@@ -42,7 +42,7 @@ public class PolicyInfo {
@JsonProperty("policy_type_id")
public String policyTypeId;
- @ApiModelProperty(value = "identity of the target NearRT-RIC")
+ @ApiModelProperty(value = "identity of the target Near-RT RIC")
@SerializedName("ric_id")
@JsonProperty("ric_id")
public String ricId;
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 66296f50..6768b76a 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
@@ -37,7 +37,8 @@ import org.immutables.gson.Gson;
@ApiModel(value = "policy_schema_list_v2", description = "Policy type json schemas")
public class PolicySchemaList {
- @ApiModelProperty(value = "Policy type json schemas")
+ @ApiModelProperty(
+ 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 63b4bd60..750f0dfb 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
@@ -31,22 +31,22 @@ import java.util.Collection;
import org.immutables.gson.Gson;
@Gson.TypeAdapters
-@ApiModel(value = "ric_info_v2", description = "Information for a NearRT-RIC")
+@ApiModel(value = "ric_info_v2", description = "Information for a Near-RT RIC")
public class RicInfo {
@Gson.TypeAdapters
- @ApiModel(value = "ric_state_v2", description = "Represents the states for a NearRT-RIC")
+ @ApiModel(value = "ric_state_v2", description = "Represents the states for a Near-RT RIC")
public enum RicState {
UNAVAILABLE, AVAILABLE, SYNCHRONIZING, CONSISTENCY_CHECK
}
- private static final String STATE_DESCRIPTION = "State for the NearRT-RIC, values: \n"
- + "UNAVAILABLE: The NearRT-RIC is not avialable, information may be inconsistent \n"
+ 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 NearRT-RIC. Policies cannot be configured. \n"
- + "CONSISTENCY_CHECK: A consistency check between the Policy Management Service and the NearRT-RIC. Policies cannot be configured.";
+ + "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 NearRT-RIC")
+ @ApiModelProperty(value = "identity of the Near-RT RIC")
@SerializedName("ric_id")
@JsonProperty("ric_id")
public final String ricId;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java
index 7ca49be7..7932dc54 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java
@@ -31,10 +31,10 @@ import java.util.Collection;
import org.immutables.gson.Gson;
@Gson.TypeAdapters
-@ApiModel(value = "ric_info_list_v2", description = "List of NearRT-RIC information")
+@ApiModel(value = "ric_info_list_v2", description = "List of Near-RT RIC information")
public class RicInfoList {
- @ApiModelProperty(value = "List of NearRT-RIC information")
+ @ApiModelProperty(value = "List of Near-RT RIC information")
@SerializedName("rics")
@JsonProperty("rics")
public final Collection<RicInfo> rics;
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 a0987ada..cc8a8e92 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
@@ -46,7 +46,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController("RicRepositoryControllerV2")
-@Api(tags = Consts.V2_API_NAME)
+@Api(tags = {Consts.V2_API_NAME})
public class RicRepositoryController {
@Autowired
@@ -59,26 +59,31 @@ public class RicRepositoryController {
.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).";
+
/**
* 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 = "Returns info for the NearRT-RIC with the given identity or managing one Mananged Element")
+ @ApiOperation(value = GET_RIC_BRIEF, notes = GET_RIC_DETAILS)
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "NearRT-RIC is found", response = RicInfo.class), //
- @ApiResponse(code = 404, message = "NearRT-RIC is not found", response = ErrorResponse.ErrorInfo.class) //
+ @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 NearRT-RIC managing the ME is returned.") //
+ 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 NearRT-RIC to get information for.") //
+ 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) {
@@ -88,7 +93,7 @@ public class RicRepositoryController {
if (ric.isPresent()) {
return new ResponseEntity<>(gson.toJson(toRicInfo(ric.get())), HttpStatus.OK);
} else {
- return ErrorResponse.create("No NearRT-RIC managing the ME is found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.create("No Near-RT RIC managing the ME is found", HttpStatus.NOT_FOUND);
}
} else if (ricId != null) {
RicInfo info = toRicInfo(this.rics.getRic(ricId));
@@ -101,11 +106,14 @@ public class RicRepositoryController {
}
}
+ static final String QUERY_RIC_INFO_DETAILS =
+ "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 NearRT-RIC information")
+ @ApiOperation(value = "Query Near-RT RIC information", notes = QUERY_RIC_INFO_DETAILS)
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "OK", response = RicInfoList.class), //
@@ -114,7 +122,7 @@ public class RicRepositoryController {
@ApiParam(
name = Consts.POLICY_TYPE_ID_PARAM,
required = false,
- value = "The identity of a policy type. If given, all NearRT-RICs supporteing the policy type are returned") //
+ 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);
@@ -131,16 +139,18 @@ public class RicRepositoryController {
}
private RicInfo.RicState toRicState(Ric.RicState state) {
- if (state == Ric.RicState.AVAILABLE) {
- return RicInfo.RicState.AVAILABLE;
- } else if (state == Ric.RicState.CONSISTENCY_CHECK) {
- return RicInfo.RicState.CONSISTENCY_CHECK;
- } else if (state == Ric.RicState.SYNCHRONIZING) {
- return RicInfo.RicState.SYNCHRONIZING;
- } else if (state == Ric.RicState.UNAVAILABLE) {
- return RicInfo.RicState.UNAVAILABLE;
+ switch (state) {
+ case AVAILABLE:
+ return RicInfo.RicState.AVAILABLE;
+ case CONSISTENCY_CHECK:
+ return RicInfo.RicState.CONSISTENCY_CHECK;
+ case SYNCHRONIZING:
+ return RicInfo.RicState.SYNCHRONIZING;
+ case UNAVAILABLE:
+ return RicInfo.RicState.UNAVAILABLE;
+ default:
+ return RicInfo.RicState.UNAVAILABLE;
}
- return RicInfo.RicState.UNAVAILABLE;
}
private RicInfo toRicInfo(Ric ric) {
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 19d68161..383e4f7f 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
@@ -68,8 +68,11 @@ public class ServiceController {
this.policies = policies;
}
+ private static final String GET_SERVICE_DETAILS =
+ "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")
+ @ApiOperation(value = "Returns service information", notes = GET_SERVICE_DETAILS)
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "OK", response = ServiceStatusList.class), //
@@ -78,7 +81,7 @@ public class ServiceController {
@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 type not found", HttpStatus.NOT_FOUND);
+ return ErrorResponse.create("Service not found", HttpStatus.NOT_FOUND);
}
Collection<ServiceStatus> servicesStatus = new ArrayList<>();
@@ -110,7 +113,14 @@ public class ServiceController {
}
}
- @ApiOperation(value = "Register a service")
+ 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>" //
+ ;
+
+ @ApiOperation(value = "Register a service", notes = REGISTER_SERVICE_DETAILS)
@ApiResponses(
value = { //
@ApiResponse(code = 200, message = "Service updated"),
@@ -132,15 +142,15 @@ public class ServiceController {
}
}
- @ApiOperation(value = "Delete a service")
+ @ApiOperation(value = "Unregister a service")
@ApiResponses(
value = { //
- @ApiResponse(code = 204, message = "Service deleted"),
+ @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 name of the service") //
+ @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);
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 154809de..05ba41da 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
@@ -32,7 +32,7 @@ import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client.A1Protocol
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
/**
- * Holds information about a NearRT-RIC.
+ * Holds information about a Near-RT RIC.
*/
public class Ric {
@@ -142,7 +142,7 @@ public class Ric {
*/
public enum RicState {
/**
- * The Policy Management Service's view of the NearRT-RIC may be inconsistent.
+ * The Policy Management Service's view of the Near-RT RIC may be inconsistent.
*/
UNAVAILABLE,
/**
@@ -150,12 +150,12 @@ public class Ric {
*/
AVAILABLE,
/**
- * The Policy Management Service is synchronizing the view of the NearRT-RIC.
+ * The Policy Management Service is synchronizing the view of the Near-RT RIC.
*/
SYNCHRONIZING,
/**
- * A consistency check between the Policy Management Service and the NearRT-RIC
+ * A consistency check between the Policy Management Service and the Near-RT RIC
* is done
*/
CONSISTENCY_CHECK
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 9bad36cc..332af8bc 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
@@ -44,7 +44,7 @@ import reactor.core.publisher.Mono;
/**
* Regularly checks the existing rics towards the local repository to keep it
- * consistent. When the policy types or instances in the NearRT-RIC is not
+ * consistent. When the policy types or instances in the Near-RT RIC is not
* consistent, a synchronization is performed.
*/
@Component
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 d8cd04e2..f810c659 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
@@ -43,12 +43,12 @@ import reactor.core.publisher.Mono;
import reactor.core.publisher.SignalType;
/**
- * Synchronizes the content of a NearRT-RIC with the content in the repository.
+ * Synchronizes the content of a Near-RT RIC with the content in the repository.
* This means:
* <p>
* load all policy types
* <p>
- * send all policy instances to the NearRT-RIC
+ * send all policy instances to the Near-RT RIC
* <p>
* if that fails remove all policy instances
* <p>
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java
index 3a7068d6..591b29c9 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/ApplicationTestV2.java
@@ -255,7 +255,7 @@ class ApplicationTestV2 {
Policy policy2 = addPolicy("policyId2", "typeName", "service", ric1Name);
Ric ric2 = addRic("ric2");
- getA1Client(ric1Name).putPolicy(policy2); // put it in the RIC (NearRT-RIC)
+ getA1Client(ric1Name).putPolicy(policy2); // put it in the RIC (Near-RT RIC)
policies.remove(policy2); // Remove it from the repo -> should be deleted in the RIC
String policyId = "policyId";
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 72b20600..572ba0b5 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
@@ -144,21 +144,6 @@ class RefreshConfigTaskTest {
}
@Test
- void startWithStubbedRefreshReturnError_thenErrorAndTerminationLogged() {
- refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
- String errorMessage = "Error";
- doReturn(Flux.error(new Exception(errorMessage))).when(refreshTaskUnderTest).createRefreshTask();
-
- final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
-
- refreshTaskUnderTest.start();
-
- ILoggingEvent event = logAppender.list.get(0);
- assertThat(event.getFormattedMessage())
- .isEqualTo("Configuration refresh terminated due to exception java.lang.Exception: " + errorMessage);
- }
-
- @Test
void stop_thenTaskIsDisposed() throws Exception {
refreshTaskUnderTest = this.createTestObject(CONFIG_FILE_DOES_NOT_EXIST, null, null, false);
refreshTaskUnderTest.systemEnvironment = new Properties();
@@ -202,7 +187,8 @@ class RefreshConfigTaskTest {
refreshTaskUnderTest.systemEnvironment = new Properties();
// When
- doReturn(getIncorrectJson()).when(refreshTaskUnderTest).createInputStream(any());
+ final String JUNK_JSON = "{\"junk }";
+ doReturn(getJsonSteam(JUNK_JSON)).when(refreshTaskUnderTest).createInputStream(any());
doReturn("fileName").when(appConfig).getLocalConfigurationFilePath();
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
@@ -269,7 +255,7 @@ class RefreshConfigTaskTest {
doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any());
doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props);
- JsonObject configAsJson = getJsonRootObject(true);
+ JsonObject configAsJson = getJsonRootObject(getCorrectJson());
String newBaseUrl = "newBaseUrl";
modifyTheRicConfiguration(configAsJson, newBaseUrl);
when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson));
@@ -309,8 +295,8 @@ class RefreshConfigTaskTest {
doReturn(Mono.just(props)).when(refreshTaskUnderTest).getEnvironment(any());
doReturn(Mono.just(cbsClient)).when(refreshTaskUnderTest).createCbsClient(props);
- JsonObject configAsJson = getJsonRootObject(false);
- when(cbsClient.get(any())).thenReturn(Mono.just(configAsJson));
+ JsonObject emptyJsonObject = new JsonObject();
+ when(cbsClient.get(any())).thenReturn(Mono.just(emptyJsonObject));
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(RefreshConfigTask.class, ERROR);
@@ -368,9 +354,9 @@ class RefreshConfigTaskTest {
.addProperty("baseUrl", newBaseUrl);
}
- private JsonObject getJsonRootObject(boolean valid) throws JsonIOException, JsonSyntaxException, IOException {
- JsonObject rootObject = JsonParser
- .parseReader(new InputStreamReader(valid ? getCorrectJson() : getIncorrectJson())).getAsJsonObject();
+ private JsonObject getJsonRootObject(InputStream inStream)
+ throws JsonIOException, JsonSyntaxException, IOException {
+ JsonObject rootObject = JsonParser.parseReader(new InputStreamReader(inStream)).getAsJsonObject();
return rootObject;
}
@@ -380,8 +366,7 @@ class RefreshConfigTaskTest {
return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8)));
}
- private static InputStream getIncorrectJson() {
- String string = "{}"; //
- return new ByteArrayInputStream((string.getBytes(StandardCharsets.UTF_8)));
+ private static InputStream getJsonSteam(String json) {
+ return new ByteArrayInputStream((json.getBytes(StandardCharsets.UTF_8)));
}
}