aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src
diff options
context:
space:
mode:
authorJohnKeeney <john.keeney@est.tech>2023-03-31 15:27:16 +0100
committerJohn Keeney <John.Keeney@est.tech>2023-03-31 14:50:04 +0000
commit2d985bd69d9425ab8f747aec0550674034d7d7ac (patch)
tree0210b4674bfe71d8d8d75b1468a7b9fed812d4e8 /a1-policy-management/src
parenta9cc0c3bfbc42892f3df007a27b9730b6d5a17a1 (diff)
Fix some issues identified by sonar
Change-Id: Ia1f1ebb3c0dec111d4544d750f983ebb7976d761 Issue-ID: CCSDK-3882 Signed-off-by: JohnKeeney <john.keeney@est.tech>
Diffstat (limited to 'a1-policy-management/src')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java17
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java11
-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/exceptions/GlobalExceptionHandler.java4
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java2
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java5
7 files changed, 28 insertions, 22 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java
index ec23f838..eb3c6a42 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
@Schema(name = "service_callback_info_v2",
description = "Information transferred as in Service callbacks (callback_url)")
@@ -37,12 +38,12 @@ public class ServiceCallbackInfo {
AVAILABLE
}
- @Schema(name = "ric_id", description = "identity of a Near-RT RIC", required = true)
+ @Schema(name = "ric_id", description = "identity of a Near-RT RIC", requiredMode = RequiredMode.REQUIRED)
@SerializedName("ric_id")
@JsonProperty(value = "ric_id", required = true)
public String ricId;
- @Schema(name = "event_type", description = EVENT_TYPE_DESCRIPTION, required = true)
+ @Schema(name = "event_type", description = EVENT_TYPE_DESCRIPTION, requiredMode = RequiredMode.REQUIRED)
@SerializedName("event_type")
@JsonProperty(value = "event_type", required = true)
public EventType eventType;
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 a3870b2c..f7bc22ca 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
@@ -24,47 +24,48 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
@Schema(name = "policy_info_v2", description = "Information for one A1-P Policy")
public class PolicyInfo {
- @Schema(name = "policy_id", description = "identity of the policy", required = true)
+ @Schema(name = "policy_id", description = "identity of the policy", requiredMode = RequiredMode.REQUIRED)
@JsonProperty(value = "policy_id", required = true)
@SerializedName("policy_id")
public String policyId;
- @Schema(name = "policytype_id", description = "identity of the policy type", required = true)
+ @Schema(name = "policytype_id", description = "identity of the policy type", requiredMode = RequiredMode.REQUIRED)
@JsonProperty(value = "policytype_id", required = true)
@SerializedName("policytype_id")
public String policyTypeId;
- @Schema(name = "ric_id", description = "identity of the target Near-RT RIC", required = true)
+ @Schema(name = "ric_id", description = "identity of the target Near-RT RIC", requiredMode = RequiredMode.REQUIRED)
@JsonProperty(value = "ric_id", required = true)
@SerializedName("ric_id")
public String ricId;
- @Schema(name = "policy_data", description = "the configuration of the policy", required = true)
+ @Schema(name = "policy_data", description = "the configuration of the policy", requiredMode = RequiredMode.REQUIRED)
@JsonProperty(value = "policy_data", required = true)
@SerializedName("policy_data")
public Object policyData;
private static final String SERVICE_ID_DESCRIPTION = "the identity of the service owning the policy."
+ " This can be used to group the policies (it is possible to get all policies associated to a service)."
- + " Note that the service does not need to be registerred.";
+ + " Note that the service does not need to be registered.";
- @Schema(name = "service_id", description = SERVICE_ID_DESCRIPTION, required = false, defaultValue = "")
+ @Schema(name = "service_id", description = SERVICE_ID_DESCRIPTION, requiredMode = RequiredMode.NOT_REQUIRED, defaultValue = "")
@JsonProperty(value = "service_id", required = false)
@SerializedName("service_id")
public String serviceId = "";
@Schema(name = "transient",
description = "if true, the policy is deleted at RIC restart. If false, its value is maintained by this service until explicitly deleted. Default false.",
- required = false, defaultValue = "false", example = "false")
+ requiredMode = RequiredMode.NOT_REQUIRED, defaultValue = "false", example = "false")
@JsonProperty(value = "transient", required = false, defaultValue = "false")
@SerializedName("transient")
public boolean isTransient = false;
- @Schema(name = "status_notification_uri", description = "Callback URI for policy status updates", required = false,
+ @Schema(name = "status_notification_uri", description = "Callback URI for policy status updates", requiredMode = RequiredMode.NOT_REQUIRED,
defaultValue = "")
@JsonProperty(value = "status_notification_uri", required = false)
@SerializedName("status_notification_uri")
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 6843cd1e..d6069aa2 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
@@ -35,11 +35,12 @@ public class RicInfo {
UNAVAILABLE, AVAILABLE, SYNCHRONIZING, CONSISTENCY_CHECK
}
- 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.";
+ private static final String STATE_DESCRIPTION = """
+ State for the Near-RT RIC, values:
+ UNAVAILABLE: The Near-RT RIC is not available, information may be inconsistent
+ AVAILABLE: The normal state. Policies can 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.""";
@Schema(description = "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/ServiceRegistrationInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
index c016b6fb..16494076 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
@@ -24,11 +24,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
+
@Schema(name = "service_registration_info_v2", description = "Information for one service")
public class ServiceRegistrationInfo {
- @Schema(description = "identity of the service", required = true)
+ @Schema(description = "identity of the service", requiredMode = RequiredMode.REQUIRED)
@SerializedName("service_id")
@JsonProperty("service_id")
public String serviceId = "";
@@ -42,7 +44,7 @@ public class ServiceRegistrationInfo {
@JsonProperty("keep_alive_interval_seconds")
public long keepAliveIntervalSeconds = 0;
- @Schema(description = "callback for notifying of Near-RT RIC state changes", required = false, defaultValue = "")
+ @Schema(description = "callback for notifying of Near-RT RIC state changes", requiredMode = RequiredMode.NOT_REQUIRED, defaultValue = "")
@SerializedName("callback_url")
@JsonProperty("callback_url")
public String callbackUrl = "";
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/exceptions/GlobalExceptionHandler.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/exceptions/GlobalExceptionHandler.java
index 77d01969..76ce6f97 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/exceptions/GlobalExceptionHandler.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/exceptions/GlobalExceptionHandler.java
@@ -35,7 +35,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep
@ControllerAdvice(annotations = RestController.class)
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
- private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Logger loggerx = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@ExceptionHandler(ServiceException.class)
public final ResponseEntity<Object> handleServiceException(ServiceException ex) {
@@ -44,7 +44,7 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(RuntimeException.class)
public final ResponseEntity<Object> handleRuntimeException(RuntimeException ex) {
- logger.error("Runtime exception {}", ex.getMessage());
+ loggerx.error("Runtime exception {}", ex.getMessage());
return ErrorResponse.create(ex, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java
index 459eb801..9696aabc 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/MetersTest.java
@@ -42,7 +42,7 @@ import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
@ExtendWith(MockitoExtension.class)
-public class MetersTest {
+class MetersTest {
private static final String POLICY_TYPE_1_NAME = "type1";
private static final PolicyType POLICY_TYPE_1 = PolicyType.builder().id(POLICY_TYPE_1_NAME).schema("").build();
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTaskTest.java
index d84359ad..bfdb58ca 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
@@ -113,8 +113,9 @@ class RefreshConfigTaskTest {
verify(refreshTaskUnderTest.rics, times(2)).put(any(Ric.class));
java.util.Collection<RicConfig> ricConfigs = appConfig.getRicConfigs();
- assertThat(ricConfigs).isNotNull();
- assertThat(ricConfigs).hasSize(2);
+ assertThat(ricConfigs)
+ .isNotNull()
+ .hasSize(2);
}
@Test