- def 'Get request with runtime exception returns HTTP Status Internal Server Error.'() {
- when: 'runtime exception is thrown by the service'
- setupTestException(new IllegalStateException(errorMessage))
- def response = performTestRequest()
- then: 'an HTTP Internal Server Error response is returned with correct message and details'
- assertTestResponse(response, INTERNAL_SERVER_ERROR, errorMessage, null)
+ def 'Get request with generic #scenario exception returns correct HTTP Status.'() {
+ when: 'an exception is thrown by the service'
+ setupTestException(exception, NCMP)
+ def response = performTestRequest(NCMP)
+ then: 'an HTTP response is returned with correct message and details'
+ assertTestResponse(response, expectedErrorCode, expectedErrorMessage, expectedErrorDetails)
+ where:
+ scenario | exception || expectedErrorDetails | expectedErrorMessage | expectedErrorCode
+ 'CPS' | new CpsException(errorMessage, errorDetails) || errorDetails | errorMessage | INTERNAL_SERVER_ERROR
+ 'NCMP-server' | new ServerNcmpException(errorMessage, errorDetails) || null | errorMessage | INTERNAL_SERVER_ERROR
+ 'NCMP-client' | new DmiRequestException(errorMessage, errorDetails) || null | errorMessage | BAD_REQUEST
+ 'DataNode Validation' | new DataNodeNotFoundException(dataNodeNotFoundErrorMessage, errorDetails) || null | dataNodeNotFoundErrorMessage | BAD_REQUEST
+ 'other' | new IllegalStateException(errorMessage) || null | errorMessage | INTERNAL_SERVER_ERROR