use of io.syndesis.server.jsondb.GetOptions in project syndesis by syndesisio.
the class ActivityTrackingControllerTest method testLogsController.
@Test
public void testLogsController() throws IOException {
final String expectedDBState = resource("logs-controller-db.json").trim();
final String podLogs = resource("test-pod-x23x.txt");
try (ActivityTrackingController controller = new ActivityTrackingController(jsondb, dbi, null) {
@Override
protected PodList listPods() {
return new PodListBuilder().addNewItem().withNewMetadata().withName("test-pod-x23x").addToLabels(OpenShiftService.COMPONENT_LABEL, "integration").addToLabels(OpenShiftService.DEPLOYMENT_VERSION_LABEL, "3").addToLabels(OpenShiftService.INTEGRATION_ID_LABEL, "my-integration").endMetadata().withNewStatus().withPhase("Running").endStatus().endItem().build();
}
@Override
protected boolean isPodRunning(String name) {
return true;
}
@Override
protected void watchLog(String podName, Consumer<InputStream> handler, String sinceTime) throws IOException {
executor.execute(() -> {
handler.accept(new ByteArrayInputStream(podLogs.getBytes(StandardCharsets.UTF_8)));
});
}
}) {
controller.setStartupDelay("0 seconds");
controller.setRetention("1000000000 days");
controller.open();
// Eventually all the log data should make it into the jsondb
given().await().atMost(20, SECONDS).pollInterval(1, SECONDS).untilAsserted(() -> {
String db = jsondb.getAsString("/", new GetOptions().prettyPrint(true));
assertThat(db).isEqualTo(expectedDBState);
});
}
}
use of io.syndesis.server.jsondb.GetOptions in project syndesis by syndesisio.
the class JsonDBTest method testGetStartAfterWithDESC.
@Test
public void testGetStartAfterWithDESC() throws IOException {
jsondb.set("/test", mapper.writeValueAsString(map("user1", "test 1", "user2", "test 2", "user3", "test 3", "user4", "test 4", "user5", "test 5", "user6", "test 6")));
String json = jsondb.getAsString("/test", new GetOptions().startAfter("user3").order(GetOptions.Order.DESC));
assertThat(json).isEqualTo("{\"user2\":\"test 2\",\"user1\":\"test 1\"}");
}
use of io.syndesis.server.jsondb.GetOptions in project syndesis by syndesisio.
the class JsonDBTest method testGetEndAtWithDESC.
@Test
public void testGetEndAtWithDESC() throws IOException {
jsondb.set("/test", mapper.writeValueAsString(map("user1", "test 1", "user2", "test 2", "user3", "test 3", "user4", "test 4", "user5", "test 5", "user6", "test 6")));
String json = jsondb.getAsString("/test", new GetOptions().endAt("user3").order(GetOptions.Order.DESC));
assertThat(json).isEqualTo("{\"user6\":\"test 6\",\"user5\":\"test 5\",\"user4\":\"test 4\",\"user3\":\"test 3\"}");
}
Aggregations