summaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2023-12-08 16:47:19 +0100
committerFiete Ostkamp <fiete.ostkamp@telekom.de>2023-12-08 16:01:39 +0000
commit33521592f3a466fd5cb6959340c1ec70e412dfa8 (patch)
tree659c25943b5eb35da24f4aea09107b6676446a96 /aai-traversal/src/test
parentefe52a581c4a1217ae9117e2177e157841e75ffa (diff)
Separate entity retrieval from jax-rs Response creation
- move logic to retrieve entity from db into a separate method - do not use runner() from AAI core [1][2] - use global ExceptionHandler to provide a common exception to error response mapping [1] the runner will spawn a separate thread to process the request. In this change there is nothing to replace this functionality. The reason that it is removed is that it tightly couples the app with a) aai-common and b) jax-rs and is also catching all exceptions. Also the timeout mechanism that is implemented is not actually stopping the execution of the thread after the timeout, but rather returning an early response (after 3 minutes(!)). [2] these changes are also done to make a future full migration to spring boot/the removal of jax-rs easier Issue-ID: AAI-3693 Change-Id: I177913c5f6295e1cab476e3c206fecacd7620f69 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-traversal/src/test')
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java1
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java17
2 files changed, 10 insertions, 8 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
index 81f47b1..ac6b749 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
@@ -267,6 +267,7 @@ public class DslConsumerTest extends AbstractSpringRestTest {
assertEquals("SVC6152", response.getBody().getRequestError().getServiceException().getMessageId());
assertEquals("DSL Generic Error (msg=%1) (ec=%2)", response.getBody().getRequestError().getServiceException().getText());
assertEquals("DSL Generic Error:Error while processing the query: org.onap.aai.exceptions.AAIException: No nodes marked for output", response.getBody().getRequestError().getServiceException().getVariables().get(0));
+ assertEquals("/aai/v11/dsl", response.getBody().getRequestError().getServiceException().getVariables().get(3));
}
@Test
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
index c7314bc..bed964e 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
@@ -81,6 +81,7 @@ public class ExceptionHandlerTest {
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
when(request.getMethod()).thenReturn("PUT");
+ when(request.getRequestURI()).thenReturn("/aai/v14/dsl");
}
@Test
@@ -108,8 +109,8 @@ public class ExceptionHandlerTest {
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals("SVC3102",responseEntity.getRequestError().getServiceException().getMessageId());
assertEquals("Error parsing input performing %1 on %2 (msg=%3) (ec=%4)",responseEntity.getRequestError().getServiceException().getText());
- assertEquals("UnmarshalException",responseEntity.getRequestError().getServiceException().getVariables().get(0));
- assertEquals("null",responseEntity.getRequestError().getServiceException().getVariables().get(1));
+ assertEquals("PUT",responseEntity.getRequestError().getServiceException().getVariables().get(0));
+ assertEquals("/aai/v14/dsl",responseEntity.getRequestError().getServiceException().getVariables().get(1));
assertEquals("Input parsing error:javax.ws.rs.WebApplicationException: HTTP 500 Internal Server Error",responseEntity.getRequestError().getServiceException().getVariables().get(2));
assertEquals("ERR.5.4.4007",responseEntity.getRequestError().getServiceException().getVariables().get(3));
}
@@ -127,8 +128,8 @@ public class ExceptionHandlerTest {
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals("SVC3102",responseEntity.getRequestError().getServiceException().getMessageId());
assertEquals("Error parsing input performing %1 on %2 (msg=%3) (ec=%4)",responseEntity.getRequestError().getServiceException().getText());
- assertEquals("JsonParseException",responseEntity.getRequestError().getServiceException().getVariables().get(0));
- assertEquals("null",responseEntity.getRequestError().getServiceException().getVariables().get(1));
+ assertEquals("PUT",responseEntity.getRequestError().getServiceException().getVariables().get(0));
+ assertEquals("/aai/v14/dsl",responseEntity.getRequestError().getServiceException().getVariables().get(1));
assertEquals("Input parsing error:com.fasterxml.jackson.core.JsonParseException: ",responseEntity.getRequestError().getServiceException().getVariables().get(2));
assertEquals("ERR.5.4.4007",responseEntity.getRequestError().getServiceException().getVariables().get(3));
}
@@ -145,8 +146,8 @@ public class ExceptionHandlerTest {
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals("SVC3102",responseEntity.getRequestError().getServiceException().getMessageId());
assertEquals("Error parsing input performing %1 on %2 (msg=%3) (ec=%4)",responseEntity.getRequestError().getServiceException().getText());
- assertEquals("JsonMappingException",responseEntity.getRequestError().getServiceException().getVariables().get(0));
- assertEquals("null",responseEntity.getRequestError().getServiceException().getVariables().get(1));
+ assertEquals("PUT",responseEntity.getRequestError().getServiceException().getVariables().get(0));
+ assertEquals("/aai/v14/dsl",responseEntity.getRequestError().getServiceException().getVariables().get(1));
assertEquals("Input parsing error:com.fasterxml.jackson.databind.JsonMappingException: ",responseEntity.getRequestError().getServiceException().getVariables().get(2));
assertEquals("ERR.5.4.4007",responseEntity.getRequestError().getServiceException().getVariables().get(3));
}
@@ -164,7 +165,7 @@ public class ExceptionHandlerTest {
assertEquals("SVC3002",responseEntity.getRequestError().getServiceException().getMessageId());
assertEquals("Error writing output performing %1 on %2 (msg=%3) (ec=%4)",responseEntity.getRequestError().getServiceException().getText());
assertEquals("PUT",responseEntity.getRequestError().getServiceException().getVariables().get(0));
- assertEquals("unknown",responseEntity.getRequestError().getServiceException().getVariables().get(1));
+ assertEquals("/aai/v14/dsl",responseEntity.getRequestError().getServiceException().getVariables().get(1));
assertEquals("Internal Error:java.lang.Exception",responseEntity.getRequestError().getServiceException().getVariables().get(2));
assertEquals("ERR.5.4.4000",responseEntity.getRequestError().getServiceException().getVariables().get(3));
}
@@ -186,7 +187,7 @@ public class ExceptionHandlerTest {
assertEquals("SVC3002",responseEntity.getRequestError().getServiceException().getMessageId());
assertEquals("Error writing output performing %1 on %2 (msg=%3) (ec=%4)",responseEntity.getRequestError().getServiceException().getText());
assertEquals("PUT",responseEntity.getRequestError().getServiceException().getVariables().get(0));
- assertEquals("unknown",responseEntity.getRequestError().getServiceException().getVariables().get(1));
+ assertEquals("/aai/v14/dsl",responseEntity.getRequestError().getServiceException().getVariables().get(1));
assertEquals("Internal Error:java.lang.Exception",responseEntity.getRequestError().getServiceException().getVariables().get(2));
assertEquals("ERR.5.4.4000",responseEntity.getRequestError().getServiceException().getVariables().get(3));
}