use of org.assertj.core.api.Condition in project syndesis-qe by syndesisio.
the class SupportPageSteps method downloadAllLogs.
@When("^.*downloads? diagnostics for all integrations$")
public void downloadAllLogs() throws InterruptedException, IOException {
supportPage.selectAllIntegrationDownload();
File downloadedLogs = supportPage.downloadZipLogs();
assertThat(downloadedLogs).exists().isFile().has(new Condition<>(f -> f.length() > 0, "File size should be greater than 0"));
checkDownloadedFileContent(downloadedLogs);
}
use of org.assertj.core.api.Condition in project syndesis-qe by syndesisio.
the class SupportPageSteps method downloadSpecificLogs.
@When("^.*downloads? diagnostics for \"([^\"]*)\" integration$")
public void downloadSpecificLogs(String integrationName) throws InterruptedException, IOException {
supportPage.selectSpecificIntegrationDownload(integrationName);
File downloadedLogs = supportPage.downloadZipLogs();
assertThat(downloadedLogs).exists().isFile().has(new Condition<>(f -> f.length() > 0, "File size should be greater than 0"));
checkDownloadedFileContent(downloadedLogs);
}
use of org.assertj.core.api.Condition in project syndesis-qe by syndesisio.
the class SupportPageSteps method checkDownloadedFileContent.
private void checkDownloadedFileContent(File file) throws IOException {
try (ZipFile zipFile = new ZipFile(file)) {
assertThat(zipFile).has(new Condition<>(f -> f.size() > 4, "Inside of zip file should be at least 5 log files???"));
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry zipEntry = entries.nextElement();
log.info("I found this file in downloaded zip: " + zipEntry.getName());
assertThat(zipEntry).has(new Condition<>(f -> f.getSize() > 0, "Log file should not be empty!"));
}
}
}
use of org.assertj.core.api.Condition in project cassandra by apache.
the class AbstractClientSizeWarning method failThreshold.
public void failThreshold(String cql) throws UnknownHostException {
ICoordinator node = CLUSTER.coordinator(1);
for (int i = 0; i < failThresholdRowCount(); i++) node.execute("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, ?, ?)", ConsistencyLevel.ALL, i + 1, bytes(512));
if (shouldFlush())
CLUSTER.stream().forEach(i -> i.flush(KEYSPACE));
enable(true);
checkpointHistogram();
List<String> warnings = CLUSTER.get(1).callsOnInstance(() -> {
ClientWarn.instance.captureWarnings();
CoordinatorWarnings.init();
try {
QueryProcessor.execute(cql, org.apache.cassandra.db.ConsistencyLevel.ALL, QueryState.forInternalCalls());
Assert.fail("Expected query failure");
} catch (ReadSizeAbortException e) {
// expected, client transport returns an error message and includes client warnings
}
CoordinatorWarnings.done();
CoordinatorWarnings.reset();
return ClientWarn.instance.getWarnings();
}).call();
assertAbortWarnings(warnings);
assertHistogramUpdated();
assertWarnAborts(0, 1, 1);
try {
driverQueryAll(cql);
Assert.fail("Query should have thrown ReadFailureException");
} catch (com.datastax.driver.core.exceptions.ReadFailureException e) {
// without changing the client can't produce a better message...
// client does NOT include the message sent from the server in the exception; so the message doesn't work
// well in this case
assertThat(e.getMessage()).contains("responses were required but only 0 replica responded");
ImmutableSet<InetAddress> expectedKeys = ImmutableSet.of(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), InetAddress.getByAddress(new byte[] { 127, 0, 0, 2 }), InetAddress.getByAddress(new byte[] { 127, 0, 0, 3 }));
assertThat(e.getFailuresMap()).hasSizeBetween(1, 3).containsValue(RequestFailureReason.READ_SIZE.code).hasKeySatisfying(new Condition<InetAddress>() {
public boolean matches(InetAddress value) {
return expectedKeys.contains(value);
}
});
}
assertHistogramUpdated();
assertWarnAborts(0, 2, 1);
// query should no longer fail
enable(false);
SimpleQueryResult result = node.executeWithResult(cql, ConsistencyLevel.ALL);
assertThat(result.warnings()).isEmpty();
assertHistogramNotUpdated();
assertThat(driverQueryAll(cql).getExecutionInfo().getWarnings()).isEmpty();
assertHistogramNotUpdated();
assertWarnAborts(0, 2, 0);
}
use of org.assertj.core.api.Condition in project mockito by mockito.
the class Conditions method bridgeMethod.
public static Condition<Object> bridgeMethod(final String methodName) {
return new Condition<Object>() {
public boolean matches(Object o) {
Class<?> clazz = null;
if (o instanceof Class) {
clazz = (Class<?>) o;
} else {
clazz = o.getClass();
}
for (Method m : clazz.getMethods()) {
if (m.isBridge() && m.getName().equals(methodName)) {
return true;
}
}
Assertions.fail("Bridge method [" + methodName + "]\nnot found in:\n" + o);
return false;
}
};
}
Aggregations