Search in sources :

Example 1 with StaleEntityException

use of org.alfresco.rest.framework.core.exceptions.StaleEntityException in project alfresco-remote-api by Alfresco.

the class ExceptionResolverTests method testMatchException.

// 04180006 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get
@Test
public void testMatchException() {
    ErrorResponse response = assistant.resolveException(new ApiException(null));
    assertNotNull(response);
    // default to INTERNAL_SERVER_ERROR
    assertEquals(500, response.getStatusCode());
    response = assistant.resolveException(new InvalidArgumentException(null));
    // default to STATUS_BAD_REQUEST
    assertEquals(400, response.getStatusCode());
    response = assistant.resolveException(new InvalidQueryException(null));
    // default to STATUS_BAD_REQUEST
    assertEquals(400, response.getStatusCode());
    response = assistant.resolveException(new NotFoundException(null));
    // default to STATUS_NOT_FOUND
    assertEquals(404, response.getStatusCode());
    response = assistant.resolveException(new EntityNotFoundException(null));
    // default to STATUS_NOT_FOUND
    assertEquals(404, response.getStatusCode());
    response = assistant.resolveException(new RelationshipResourceNotFoundException(null, null));
    // default to STATUS_NOT_FOUND
    assertEquals(404, response.getStatusCode());
    response = assistant.resolveException(new PermissionDeniedException(null));
    // default to STATUS_FORBIDDEN
    assertEquals(403, response.getStatusCode());
    response = assistant.resolveException(new UnsupportedResourceOperationException(null));
    // default to STATUS_METHOD_NOT_ALLOWED
    assertEquals(405, response.getStatusCode());
    response = assistant.resolveException(new DeletedResourceException(null));
    // default to STATUS_METHOD_NOT_ALLOWED
    assertEquals(405, response.getStatusCode());
    response = assistant.resolveException(new ConstraintViolatedException(null));
    // default to STATUS_CONFLICT
    assertEquals(409, response.getStatusCode());
    response = assistant.resolveException(new StaleEntityException(null));
    // default to STATUS_CONFLICT
    assertEquals(409, response.getStatusCode());
    // Try a random exception
    response = assistant.resolveException(new FormNotFoundException(null));
    // default to INTERNAL_SERVER_ERROR
    assertEquals(500, response.getStatusCode());
    response = assistant.resolveException(new InsufficientStorageException(null));
    assertEquals(507, response.getStatusCode());
    response = assistant.resolveException(new IntegrityException(null));
    assertEquals(422, response.getStatusCode());
}
Also used : UnsupportedResourceOperationException(org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException) InsufficientStorageException(org.alfresco.rest.framework.core.exceptions.InsufficientStorageException) FormNotFoundException(org.alfresco.repo.forms.FormNotFoundException) RelationshipResourceNotFoundException(org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) NotFoundException(org.alfresco.rest.framework.core.exceptions.NotFoundException) IntegrityException(org.alfresco.repo.node.integrity.IntegrityException) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) DeletedResourceException(org.alfresco.rest.framework.core.exceptions.DeletedResourceException) ConstraintViolatedException(org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException) ErrorResponse(org.alfresco.rest.framework.core.exceptions.ErrorResponse) RelationshipResourceNotFoundException(org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) FormNotFoundException(org.alfresco.repo.forms.FormNotFoundException) PermissionDeniedException(org.alfresco.rest.framework.core.exceptions.PermissionDeniedException) StaleEntityException(org.alfresco.rest.framework.core.exceptions.StaleEntityException) InvalidQueryException(org.alfresco.rest.framework.resource.parameters.where.InvalidQueryException) ApiException(org.alfresco.rest.framework.core.exceptions.ApiException) Test(org.junit.Test)

Aggregations

FormNotFoundException (org.alfresco.repo.forms.FormNotFoundException)1 IntegrityException (org.alfresco.repo.node.integrity.IntegrityException)1 ApiException (org.alfresco.rest.framework.core.exceptions.ApiException)1 ConstraintViolatedException (org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException)1 DeletedResourceException (org.alfresco.rest.framework.core.exceptions.DeletedResourceException)1 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)1 ErrorResponse (org.alfresco.rest.framework.core.exceptions.ErrorResponse)1 InsufficientStorageException (org.alfresco.rest.framework.core.exceptions.InsufficientStorageException)1 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)1 NotFoundException (org.alfresco.rest.framework.core.exceptions.NotFoundException)1 PermissionDeniedException (org.alfresco.rest.framework.core.exceptions.PermissionDeniedException)1 RelationshipResourceNotFoundException (org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException)1 StaleEntityException (org.alfresco.rest.framework.core.exceptions.StaleEntityException)1 UnsupportedResourceOperationException (org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException)1 InvalidQueryException (org.alfresco.rest.framework.resource.parameters.where.InvalidQueryException)1 Test (org.junit.Test)1