+ new DataValidationException(errorMessage, errorDetails, null),
+ new CpsPathException(errorMessage,errorDetails)]
+ }
+
+ @Unroll
+ def 'Delete request with a #exceptionThrown.class.simpleName returns HTTP Status Conflict'() {
+
+ when: 'CPS validation exception is thrown by the service'
+ setupTestException(exceptionThrown)
+ def response = performTestRequest()
+
+ then: 'an HTTP Conflict response is returned with correct message and details'
+ assertTestResponse(response, CONFLICT, exceptionThrown.getMessage(), exceptionThrown.getDetails())
+
+ where: 'the following exceptions are thrown'
+ exceptionThrown << [new DataInUseException(dataspaceName, existingObjectName),
+ new SchemaSetInUseException(dataspaceName, existingObjectName)]
+ }
+
+ def 'Get request without authentication is not authorized'() {
+ when: 'request is sent without authentication'
+ def response =
+ mvc.perform(get("$basePath/v1/dataspaces/dataspace-name/anchors")).andReturn().response
+ then: 'HTTP Unauthorized status code is returned'
+ assert UNAUTHORIZED.value() == response.status
+ }
+
+ def 'Get request with invalid authentication is not authorized'() {
+ when: 'request is sent with invalid authentication'
+ def response =
+ mvc.perform(
+ get("$basePath/v1/dataspaces/dataspace-name/anchors")
+ .header("Authorization", 'Basic invalid auth'))
+ .andReturn().response
+ then: 'HTTP Unauthorized status code is returned'
+ assert UNAUTHORIZED.value() == response.status