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());
}
Aggregations