Search in sources :

Example 11 with GetOptions

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);
        });
    }
}
Also used : PodListBuilder(io.fabric8.kubernetes.api.model.PodListBuilder) Consumer(java.util.function.Consumer) ByteArrayInputStream(java.io.ByteArrayInputStream) GetOptions(io.syndesis.server.jsondb.GetOptions) Test(org.junit.Test)

Example 12 with GetOptions

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\"}");
}
Also used : GetOptions(io.syndesis.server.jsondb.GetOptions) Test(org.junit.Test)

Example 13 with GetOptions

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\"}");
}
Also used : GetOptions(io.syndesis.server.jsondb.GetOptions) Test(org.junit.Test)

Aggregations

GetOptions (io.syndesis.server.jsondb.GetOptions)13 Test (org.junit.Test)9 Map (java.util.Map)3 Consumer (java.util.function.Consumer)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 MapType (com.fasterxml.jackson.databind.type.MapType)1 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)1 PodListBuilder (io.fabric8.kubernetes.api.model.PodListBuilder)1 ListResult (io.syndesis.common.model.ListResult)1 IdPrefixFilter (io.syndesis.server.dao.manager.operators.IdPrefixFilter)1 Activity (io.syndesis.server.endpoint.v1.handler.activity.Activity)1 ActivityStep (io.syndesis.server.endpoint.v1.handler.activity.ActivityStep)1 JsonDB (io.syndesis.server.jsondb.JsonDB)1 JsonDBException (io.syndesis.server.jsondb.JsonDBException)1 InputStream (java.io.InputStream)1