Ниже приведен интеграционный тест:
Код: Выделить всё
@Test
public void shouldHandleUnknownRuntimeException() {
var rootException = new Throwable("Root cause");
var intermediateException = new Exception("Intermediate cause", rootException);
var originalThrowable = new Exception("Test message", intermediateException);
var message = new GenericMessage(validLogisticAttributesDraft().build());
var messageId = Optional.ofNullable(message.getHeaders().getId()).map(Object::toString).orElse(null);
stubFor(put(urlPathEqualTo("/errors")).withHeader("Content-Type", equalTo("application/json")));
assertThatThrownBy(() -> errorHandler.handle(message, originalThrowable)).isInstanceOf(RuntimeException.class)
.hasMessageContaining(rootException.getMessage());
verify(sqsTemplate, never()).send(anyString(), any());
assertThat(messageId).isNotNull().isNotBlank();
await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> verify(eagleEyeRestClient).put());
}
Код: Выделить всё
stubFor(put(urlPathEqualTo("/errors")).withHeader("Content-Type", equalTo("application/json")));
Код: Выделить всё
{
"errors" : [ {
"code" : 10,
"source" : {
"pointer" : "/timestamp"
},
"title" : "Error parsing JSON",
"detail" : "Unrecognized field \"timestamp\" (class com.github.tomakehurst.wiremock.common.Errors), not marked as ignorable"
} ]
}
com.github.tomakehurst.wiremock.common.JsonException: {
"errors" : [ {
"code" : 10,
"source" : {
"pointer" : "/timestamp"
},
"title" : "Error parsing JSON",
"detail" : "Unrecognized field \"timestamp\" (class com.github.tomakehurst.wiremock.common.Errors), not marked as ignorable"
} ]
}
Я пробовал использовать @JsonIgnoreProperties для класса, не помогло.
Подробнее здесь: https://stackoverflow.com/questions/792 ... k-common-e
Мобильная версия