Improve javadoc. Rename one of the values for RMCode.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@161971 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2018-01-04 20:09:37 +00:00
parent fc90485dca
commit 3b4e4b17a8
5 changed files with 10 additions and 9 deletions

View File

@ -3,7 +3,7 @@ package org.gcube.resourcemanagement.manager.io.exceptions;
import javax.ws.rs.core.GenericEntity;
/**
* Don't forget to comment!
* An entity to wrapf {@link SerializableErrorCode}s into a {@link WebCodeException}.
*
* @author Manuele Simi (ISTI CNR)
*

View File

@ -3,19 +3,20 @@ package org.gcube.resourcemanagement.manager.io.rs;
import org.gcube.resourcemanagement.manager.io.exceptions.ErrorCode;
/**
* Exception codes handled with {@link WebCodeException}.
* Error codes returned by the context resource.
*
* @author Manuele Simi (ISTI CNR)
*
*/
public enum RMCode implements ErrorCode {
INVALID_REQUEST(0, "The request is invalid."),
INVALID_METHOD__REQUEST(0, "The request is invalid."),
MISSING_PARAMETER(1,"Required query parameter is missing."),
MISSING_HEADER(2, "Required header is missing."),
CONTEXT_ALREADY_EXIST(3, "Context already exists at the same level of the hierarchy."),
INVALID_REQUEST_FOR_RR(4, "Failed to validate the request. The request was not submitted to the Resource Registry."),
GENERIC_ERROR_FROM_RR(0, "The Resource Registry returned an error.");
CONTEXT_ALREADY_EXISTS(3, "Context already exists at the same level of the hierarchy."),
CONTEXT_PARENT_DOES_NOT_EXIST(4, "Failed to validate the request. The request was not submitted to the Resource Registry."),
INVALID_REQUEST_FOR_RR(5, "Failed to validate the request. The request was not submitted to the Resource Registry."),
GENERIC_ERROR_FROM_RR(6, "The Resource Registry returned an error.");
private int id;
private String msg;

View File

@ -25,7 +25,7 @@ public class WebCodeExceptionTest {
*/
@Test
public void testWebCodeException() {
WebCodeException exception = new WebCodeException(RMCode.CONTEXT_ALREADY_EXIST);
WebCodeException exception = new WebCodeException(RMCode.CONTEXT_ALREADY_EXISTS);
// unfortunately, we cannot test the response readEntity method on an
// outbound response
assertTrue("Unexpected code", Objects.nonNull(exception.getResponse()));

View File

@ -52,7 +52,7 @@ public final class CreateRequest extends RequestToResourceRegistry {
return ResponseFromResourceRegistry.newFailureResponse("Invalid response from the RR (null?)");
}
} catch (ContextAlreadyPresentException cape) {
return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCode.CONTEXT_ALREADY_EXIST));
return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCode.CONTEXT_ALREADY_EXISTS));
} catch (ResourceRegistryException e) {
return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCode.GENERIC_ERROR_FROM_RR));
}

View File

@ -120,7 +120,7 @@ public class RMContextTest extends JerseyTest {
// functional
assertEquals("Unexpected returned code. Reason: " + create.getStatusInfo().getReasonPhrase(),
Status.NOT_ACCEPTABLE.getStatusCode(), create.getStatus());
assertEquals(RMCode.CONTEXT_ALREADY_EXIST, realCode);
assertEquals(RMCode.CONTEXT_ALREADY_EXISTS, realCode);
} catch (JsonProcessingException e) {
assertFalse("Failed to marshal the context.", false);
}