aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/main/java
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2020-09-01 06:41:16 +0200
committerPatrikBuhr <patrik.buhr@est.tech>2020-09-01 06:43:17 +0200
commit50daaac12878c4acd2a5d38e8964f293db02f674 (patch)
tree8de1fc1315255227654f3ada78ba002d45da35db /a1-policy-management/src/main/java
parent4556f1e83720778a22e89a7102d99b8f77eaff2b (diff)
Fixing instable test
The testcase in question should wait util the available so that the data synchronization does not iterfere. Change-Id: I152bb5db25cb7d55a0c677595027ef72577f84c0 Issue-ID: CCSDK-2502 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Diffstat (limited to 'a1-policy-management/src/main/java')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java35
1 files changed, 24 insertions, 11 deletions
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 9d9aff45..d42d51e9 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
@@ -115,18 +115,25 @@ public class PolicyController {
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 {
- if (ricId == null && policyTypeId == null) {
+ Ric ric = ricId == null ? null : rics.getRic(ricId);
+ if (ric == null && policyTypeId == null) {
Collection<PolicyType> types = this.policyTypes.getAll();
return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
- } else if (ricId != null && policyTypeId != null) {
- Collection<PolicyType> types = new ArrayList<>();
- if (rics.getRic(ricId).isSupportingType(policyTypeId)) {
- types.add(policyTypes.getType(policyTypeId));
+ } else if (ric != null && policyTypeId != null) {
+ synchronized (ric) {
+ assertRicStateIdleSync(ric);
+ Collection<PolicyType> types = new ArrayList<>();
+ if (rics.getRic(ricId).isSupportingType(policyTypeId)) {
+ types.add(policyTypes.getType(policyTypeId));
+ }
+ return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
+ }
+ } else if (ric != null) {
+ synchronized (ric) {
+ assertRicStateIdleSync(ric);
+ Collection<PolicyType> types = rics.getRic(ricId).getSupportedPolicyTypes();
+ return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
}
- return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
- } else if (ricId != null) {
- Collection<PolicyType> types = rics.getRic(ricId).getSupportedPolicyTypes();
- return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
} else {
Collection<PolicyType> types = new ArrayList<>();
types.add(policyTypes.getType(policyTypeId));
@@ -318,13 +325,19 @@ public class PolicyController {
return Mono.just("{}");
}
+ private void assertRicStateIdleSync(Ric ric) throws ServiceException {
+ if (ric.getState() != Ric.RicState.AVAILABLE) {
+ throw new ServiceException("Near-RT RIC: " + ric.id() + " is " + ric.getState());
+ }
+ }
+
private Mono<Object> assertRicStateIdle(Ric ric) {
if (ric.getState() == Ric.RicState.AVAILABLE) {
return Mono.just("{}");
} else {
- logger.debug("Request rejected RIC not IDLE, ric: {}", ric);
+ logger.debug("Request rejected Near-RT RIC not IDLE, ric: {}", ric);
RejectionException e = new RejectionException(
- "Ric is not operational, RIC name: " + 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);
}
}