Search in sources :

Example 1 with NessieInternalServerException

use of org.projectnessie.client.rest.NessieInternalServerException in project nessie by projectnessie.

the class TestTranslatingVersionNessieApi method exceptionsInternalError.

@Test
void exceptionsInternalError() throws Exception {
    int statusCode = 500;
    String type = "internal error";
    String nessieErrorMessage = "Message " + type;
    String reason = "Reason " + type;
    String serverStackTrace = "Stack trace " + type;
    String exceptionMessage = String.format("%s (HTTP/%d): %s\n%s", reason, statusCode, nessieErrorMessage, serverStackTrace);
    String oldVersionType = "org.projectnessie.client.rest.NessieInternalServerException";
    Class<? extends Throwable> expectedType = NessieInternalServerException.class;
    ErrorCode errorCode = ErrorCode.UNKNOWN;
    Throwable translated = translateException(oldVersionType, errorCode.httpStatus(), nessieErrorMessage, reason, serverStackTrace);
    assertThat(translated).isInstanceOf(expectedType).asInstanceOf(InstanceOfAssertFactories.type(NessieInternalServerException.class)).extracting(Throwable::getMessage, NessieInternalServerException::getError).containsExactly(exceptionMessage, ImmutableNessieError.builder().reason(reason).message(nessieErrorMessage).status(statusCode).errorCode(errorCode).serverStackTrace(serverStackTrace).build());
}
Also used : ErrorCode(org.projectnessie.error.ErrorCode) NessieInternalServerException(org.projectnessie.client.rest.NessieInternalServerException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 NessieInternalServerException (org.projectnessie.client.rest.NessieInternalServerException)1 ErrorCode (org.projectnessie.error.ErrorCode)1