use of org.assertj.core.api.Condition in project java-chassis by ServiceComb.
the class TestUpload method should_failed_when_connect_failed.
@Test
public void should_failed_when_connect_failed() {
Throwable throwable = catchThrowable(() -> consumersJaxrs.getIntf().uploadMultiformMix(EndpointUtils.parse(EndpointUtils.formatFromUri("http://149.159.169.179:54321")), fileSystemResource1, singletonList(fileSystemResource2), message, singletonList("2.中文测试")));
assertThat(throwable).isInstanceOf(InvocationException.class);
assertThat(throwable.toString()).is(anyOf(new Condition<>(v -> v.equals("InvocationException: code=500;msg=CommonExceptionData{code='SCB.00000000', message='connection timed out.', dynamic={}}"), "for filter"), new Condition<>(v -> v.equals("InvocationException: code=490;msg=CommonExceptionData [message=Unexpected consumer error, please check logs for details]"), "for handler")));
assertThat(throwable.getCause()).isInstanceOf(ConnectTimeoutException.class).hasMessage("connection timed out: /149.159.169.179:54321");
}
use of org.assertj.core.api.Condition in project neo4j by neo4j.
the class QueryResultsSerializationTest method restContainsNestedDeleted.
/**
* This condition is hardcoded to check for a list containing one deleted node and one map with a
* deleted node mapped to the key `someKey`.
*/
private static Condition<? super Response> restContainsNestedDeleted() {
return new Condition<>(response -> {
try {
JsonNode list = getJsonNodeWithName(response, "rest").iterator().next();
assertThat(list.get(0).get("metadata").get("deleted").asBoolean()).isEqualTo(Boolean.TRUE);
assertThat(list.get(1).get("someKey").get("metadata").get("deleted").asBoolean()).isEqualTo(Boolean.TRUE);
return true;
} catch (JsonParseException e) {
return false;
}
}, "Contains deleted data.");
}
use of org.assertj.core.api.Condition in project neo4j by neo4j.
the class FusionIndexTestHelp method verifyFusionCloseThrowIfAllThrow.
static void verifyFusionCloseThrowIfAllThrow(AutoCloseable fusionCloseable, AutoCloseable... autoCloseables) throws Exception {
// given
UncheckedIOException[] failures = new UncheckedIOException[autoCloseables.length];
for (int i = 0; i < autoCloseables.length; i++) {
failures[i] = new UncheckedIOException(new IOException("unknown"));
doThrow(failures[i]).when(autoCloseables[i]).close();
}
try {
// when
fusionCloseable.close();
fail("Should have failed");
} catch (UncheckedIOException e) {
// then
List<Condition<Throwable>> conditions = new ArrayList<>();
for (UncheckedIOException failure : failures) {
conditions.add(new Condition<>(e1 -> e1 == failure, "Same exception"));
}
assertThat(e).is(anyOf(conditions));
}
}
Aggregations