aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java8
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java18
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java4
4 files changed, 18 insertions, 16 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
index 4d142114..dc4a030b 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2023 Bell Canada. 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.
@@ -159,10 +159,8 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
return true;
}
- if (exceptionClazz.isInstance(thrown)) {
- if (isDuplicateKeyException(thrown.getCause(), exceptionClazz)) {
- return true;
- }
+ if (exceptionClazz.isInstance(thrown) && isDuplicateKeyException(thrown.getCause(), exceptionClazz)) {
+ return true;
}
thrown = thrown.getCause();
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java
index 11917e4e..f63fc1d5 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2023 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021, 2023 Bell Canada. 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.
@@ -45,7 +45,7 @@ import org.springframework.web.bind.annotation.RestController;
@Profile("default")
public class PdpGroupStateChangeControllerV1 extends PapRestControllerV1 implements PdpGroupStateChangeControllerV1Api {
- private static final Logger logger = LoggerFactory.getLogger(PdpGroupHealthCheckControllerV1.class);
+ private static final Logger logger = LoggerFactory.getLogger(PdpGroupStateChangeControllerV1.class);
private final PdpGroupStateChangeProvider provider;
/**
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java
index d2ab15fb..1f4f10f3 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,6 +45,9 @@ import org.springframework.stereotype.Service;
@Profile("stub")
class StubUtils {
private static final Logger log = LoggerFactory.getLogger(StubUtils.class);
+ private static final String APPLICATION_JSON = "application/json";
+ private static final String SERIALIZE_RESPONSE_FAILURE_MSG =
+ "Couldn't serialize response for content type application/json";
private final HttpServletRequest request;
private static final String ACCEPT = "Accept";
private static final String PAP_DB =
@@ -52,14 +56,14 @@ class StubUtils {
<T> ResponseEntity<T> getStubbedResponse(Class<T> clazz) {
var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains("application/json")) {
+ if (accept != null && accept.contains(APPLICATION_JSON)) {
final var resource = new ClassPathResource(PAP_DB);
try (var inputStream = resource.getInputStream()) {
final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
var targetObject = JSON_TRANSLATOR.fromJson(string, clazz);
return new ResponseEntity<>(targetObject, HttpStatus.OK);
} catch (IOException e) {
- log.error("Couldn't serialize response for content type application/json", e);
+ log.error(SERIALIZE_RESPONSE_FAILURE_MSG, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@@ -68,14 +72,14 @@ class StubUtils {
<T> ResponseEntity<List<T>> getStubbedResponseList(Class<T> clazz) {
var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains("application/json")) {
+ if (accept != null && accept.contains(APPLICATION_JSON)) {
final var resource = new ClassPathResource(PAP_DB);
try (var inputStream = resource.getInputStream()) {
final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
var targetObject = Arrays.asList(JSON_TRANSLATOR.fromJson(string, clazz));
return new ResponseEntity<>(targetObject, HttpStatus.OK);
} catch (IOException e) {
- log.error("Couldn't serialize response for content type application/json", e);
+ log.error(SERIALIZE_RESPONSE_FAILURE_MSG, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@@ -84,7 +88,7 @@ class StubUtils {
ResponseEntity<Map<String, Object>> getStubbedResponseMap() {
var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains("application/json")) {
+ if (accept != null && accept.contains(APPLICATION_JSON)) {
final var resource = new ClassPathResource(PAP_DB);
try (var inputStream = resource.getInputStream()) {
Map<String, Object> map = new HashMap<>();
@@ -93,7 +97,7 @@ class StubUtils {
JSON_TRANSLATOR.fromJson(string, Object.class));
return new ResponseEntity<>(map, HttpStatus.OK);
} catch (IOException e) {
- log.error("Couldn't serialize response for content type application/json", e);
+ log.error(SERIALIZE_RESPONSE_FAILURE_MSG, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@@ -102,7 +106,7 @@ class StubUtils {
ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> getStubbedResponseStatistics() {
var accept = request.getHeader(ACCEPT);
- if (accept != null && accept.contains("application/json")) {
+ if (accept != null && accept.contains(APPLICATION_JSON)) {
Map<String, Map<String, List<PdpStatistics>>> map = new HashMap<>();
return new ResponseEntity<>(map, HttpStatus.OK);
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java
index aeb2fdbb..6166580e 100644
--- a/main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/service/PolicyStatusServiceTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022-2023 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -141,7 +141,7 @@ public class PolicyStatusServiceTest extends CommonPapRestServer {
// Test delete
policyStatusService.cudPolicyStatus(null, null, List.of(status));
- assertThat(policyStatusService.getAllPolicyStatus()).hasSize(0);
+ assertThat(policyStatusService.getAllPolicyStatus()).isEmpty();
}
private List<PdpPolicyStatus> createStatusList() {