aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-05-15 16:25:00 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-05-15 16:25:00 +0200
commitda3a0ffd66b14e450f648bfe3737f3c933280087 (patch)
tree3ad092236a931d720c6fe16df6739eaa3ad7bdfe /aai-resources
parent13a082c7c8529612c7890e52e3e2b35024cf289f (diff)
Do not use an exception to communicate an ok response in the /echo endpoint
- do not use an AAIException to return a 200 OK response Issue-ID: AAI-3847 Change-Id: I29b20bb408fa55d5a18ab4e1981d7c2c435410a4 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-resources')
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java10
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java11
2 files changed, 5 insertions, 16 deletions
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java b/aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java
index 745fb00..d4d8d32 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/util/EchoResponse.java
@@ -56,6 +56,8 @@ public class EchoResponse extends RESTAPI {
private static final String CHECK_DB_STATUS_NOW_ACTION = "checkDBNow";
+ private static final String UP_RESPONSE="{\"status\":\"UP\",\"groups\":[\"liveness\",\"readiness\"]}";
+
private final AaiGraphChecker aaiGraphChecker;
public EchoResponse(AaiGraphChecker aaiGraphChecker) {
@@ -101,7 +103,7 @@ public class EchoResponse extends RESTAPI {
|| CHECK_DB_STATUS_NOW_ACTION.equalsIgnoreCase(myAction)) {
validateDBStatus(myAction);
}
- return generateSuccessResponse(headers, templateVars);
+ return generateSuccessResponse();
} catch (AAIException aaiException) {
LOGGER.error("Error while processing echo request ", aaiException);
@@ -136,11 +138,9 @@ public class EchoResponse extends RESTAPI {
}
- private Response generateSuccessResponse(HttpHeaders headers, ArrayList<String> templateVariables) {
- HashMap<AAIException, ArrayList<String>> exceptionList = new HashMap<>();
- exceptionList.put(new AAIException("AAI_0002", "OK"), templateVariables);
+ private Response generateSuccessResponse() {
return Response.status(Status.OK)
- .entity(ErrorLogHelper.getRESTAPIInfoResponse(new ArrayList<>(headers.getAcceptableMediaTypes()), exceptionList))
+ .entity(UP_RESPONSE)
.build();
}
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java b/aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
index f754449..030e870 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
@@ -124,17 +124,6 @@ public class EchoResponseTest extends AAISetup {
}
@Test
- public void testEchoResultWhenValidHeadersButMediaTypeWrong() {
-
- when(httpHeaders.getAcceptableMediaTypes()).thenThrow(new IllegalStateException()).thenReturn(outputMediaTypes);
-
- Response response = echoResponse.echoResult(httpHeaders, null, "");
-
- assertNotNull(response);
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
- }
-
- @Test
public void testCheckDbAction_CachedSuccess() {
// Prepare
when(aaiGraphCheckerMock.isAaiGraphDbAvailable(CheckerType.CACHED)).thenReturn(Boolean.TRUE);