use of com.linkedin.restli.common.ErrorResponse in project rest.li by linkedin.
the class TestErrorResponseBuilder method testNullStatus.
@Test
public void testNullStatus() {
RestLiServiceException exception = new RestLiServiceException((HttpStatus) null);
ErrorResponseBuilder builder = new ErrorResponseBuilder(ErrorResponseFormat.FULL);
ErrorResponse errorResponse = builder.buildErrorResponse(exception);
Assert.assertFalse(errorResponse.hasStatus());
}
use of com.linkedin.restli.common.ErrorResponse in project rest.li by linkedin.
the class TestErrorResponseBuilder method testErrorDetailsFromDataMap.
@Test
public void testErrorDetailsFromDataMap() {
RestLiServiceException exception = new RestLiServiceException(HttpStatus.S_200_OK, "Some message", new IllegalStateException("Some other message"));
exception.setCode("INVALID_SOMETHING");
exception.setDocUrl("www.documentation.com");
exception.setRequestId("id123");
exception.setErrorDetails((DataMap) null);
Assert.assertFalse(exception.hasErrorDetails());
ErrorResponseBuilder builder = new ErrorResponseBuilder(ErrorResponseFormat.FULL);
ErrorResponse errorResponse = builder.buildErrorResponse(exception);
Assert.assertFalse(errorResponse.hasErrorDetails());
Assert.assertTrue(errorResponse.hasExceptionClass());
Assert.assertTrue(errorResponse.hasStatus());
Assert.assertTrue(errorResponse.hasMessage());
Assert.assertTrue(errorResponse.hasCode());
Assert.assertTrue(errorResponse.hasStackTrace());
Assert.assertTrue(errorResponse.hasDocUrl());
Assert.assertTrue(errorResponse.hasRequestId());
exception.setOverridingFormat(ErrorResponseFormat.MESSAGE_AND_SERVICECODE);
errorResponse = builder.buildErrorResponse(exception);
Assert.assertFalse(errorResponse.hasErrorDetails());
Assert.assertFalse(errorResponse.hasExceptionClass());
Assert.assertTrue(errorResponse.hasStatus());
Assert.assertTrue(errorResponse.hasMessage());
Assert.assertTrue(errorResponse.hasCode());
Assert.assertFalse(errorResponse.hasStackTrace());
Assert.assertFalse(errorResponse.hasDocUrl());
Assert.assertFalse(errorResponse.hasRequestId());
}
Aggregations