summaryrefslogtreecommitdiffstats
path: root/cps-rest
diff options
context:
space:
mode:
authorToineSiebelink <toine.siebelink@est.tech>2021-05-20 16:44:21 +0100
committerToineSiebelink <toine.siebelink@est.tech>2021-06-01 10:12:55 +0100
commitc37678a3eb62685d32a1581729e2a4e26002bffc (patch)
tree1901f7e3517ae339f99905f7ffc0021553874842 /cps-rest
parent9de3b68373dd8554e64f34bb3093403521f8759f (diff)
Introducing Antlr4 for cpsPath parsing
-created new module for cpPathParser -added antlr rule for cpsPathWithSingleLeafCondition -added antlr rule for cpsPathWithDescendant (and with leaf conditions) -added antlr rule for ancestor axis -added unit test (copied from existing CpsPathQuerySpec) -udpated cps-ri to use new cpPathQuery from parser module -'imported' lexer rules from publix xPath grammar -Re-used existing CpsPathException but conversion happens in cps-ri to prevent additional dependency in cps-path-parser module Issue-ID: CPS-376 Change-Id: I2c5df98969402cbf69f6573c52705879450ce606 Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-rest')
-rw-r--r--cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy23
1 files changed, 12 insertions, 11 deletions
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy
index b4872908fa..7da3df265c 100644
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/exceptions/CpsRestExceptionHandlerSpec.groovy
@@ -21,13 +21,6 @@
package org.onap.cps.rest.exceptions
-import static org.springframework.http.HttpStatus.BAD_REQUEST
-import static org.springframework.http.HttpStatus.CONFLICT
-import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR
-import static org.springframework.http.HttpStatus.NOT_FOUND
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
-
import groovy.json.JsonSlurper
import org.modelmapper.ModelMapper
import org.onap.cps.api.CpsAdminService
@@ -52,6 +45,13 @@ import org.springframework.test.web.servlet.MockMvc
import spock.lang.Shared
import spock.lang.Specification
+import static org.springframework.http.HttpStatus.BAD_REQUEST
+import static org.springframework.http.HttpStatus.CONFLICT
+import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR
+import static org.springframework.http.HttpStatus.NOT_FOUND
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
+
@WebMvcTest
class CpsRestExceptionHandlerSpec extends Specification {
@@ -128,11 +128,12 @@ class CpsRestExceptionHandlerSpec extends Specification {
setupTestException(exceptionThrown)
def response = performTestRequest()
then: 'an HTTP Bad Request response is returned with correct message and details'
- assertTestResponse(response, BAD_REQUEST, errorMessage, errorDetails)
+ assertTestResponse(response, BAD_REQUEST, expectedErrorMessage, expectedErrorDetails)
where: 'the following exceptions are thrown'
- exceptionThrown << [new ModelValidationException(errorMessage, errorDetails, null),
- new DataValidationException(errorMessage, errorDetails, null),
- new CpsPathException(errorMessage, errorDetails)]
+ exceptionThrown || expectedErrorMessage | expectedErrorDetails
+ new ModelValidationException(errorMessage, errorDetails, null) || errorMessage | errorDetails
+ new DataValidationException(errorMessage, errorDetails, null) || errorMessage | errorDetails
+ new CpsPathException(errorDetails) || CpsPathException.ERROR_MESSAGE | errorDetails
}
def 'Delete request with a #exceptionThrown.class.simpleName returns HTTP Status Conflict'() {