Search in sources :

Example 1 with CQL2PgJSONException

use of org.folio.cql2pgjson.exception.CQL2PgJSONException in project raml-module-builder by folio-org.

the class ConnIT method streamGetDoneHandlerWithThrowable.

@Test
void streamGetDoneHandlerWithThrowable(VertxTestContext vtc) throws CQL2PgJSONException {
    CQLWrapper cqlWrapper = new CQLWrapper(new CQL2PgJSON("jsonb"), "key=b");
    with(randomUuid(), "a", randomUuid(), "b", trans -> {
        return trans.streamGet("t", Pojo.class, cqlWrapper, info -> info.result().handler(x -> {
            throw new RuntimeException("foo");
        }));
    }).onComplete(failingThenComplete(vtc, t -> assertThat(t).hasMessage("foo")));
}
Also used : VertxTestContext(io.vertx.junit5.VertxTestContext) BeforeEach(org.junit.jupiter.api.BeforeEach) CsvSource(org.junit.jupiter.params.provider.CsvSource) CQLWrapper(org.folio.rest.persist.cql.CQLWrapper) BiFunction(java.util.function.BiFunction) PostgresTesterContainer(org.folio.postgres.testing.PostgresTesterContainer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WithAssertions(org.assertj.core.api.WithAssertions) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Timeout(io.vertx.junit5.Timeout) AfterAll(org.junit.jupiter.api.AfterAll) CQL2PgJSONException(org.folio.cql2pgjson.exception.CQL2PgJSONException) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BeforeAll(org.junit.jupiter.api.BeforeAll) JsonObject(io.vertx.core.json.JsonObject) AsyncResult(io.vertx.core.AsyncResult) Vertx(io.vertx.core.Vertx) UUID(java.util.UUID) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) JsonArray(io.vertx.core.json.JsonArray) CQL2PgJSON(org.folio.cql2pgjson.CQL2PgJSON) PgConnection(io.vertx.pgclient.PgConnection) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Handler(io.vertx.core.Handler) Collections(java.util.Collections) CQL2PgJSON(org.folio.cql2pgjson.CQL2PgJSON) CQLWrapper(org.folio.rest.persist.cql.CQLWrapper) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with CQL2PgJSONException

use of org.folio.cql2pgjson.exception.CQL2PgJSONException in project raml-module-builder by folio-org.

the class ConnIT method streamGet.

@ParameterizedTest
@CsvSource({ "key=*, 2", "key=b, 1", "key=x, 0" })
void streamGet(String cql, int total, VertxTestContext vtc) throws CQL2PgJSONException {
    AtomicInteger count = new AtomicInteger();
    AtomicBoolean end = new AtomicBoolean();
    CQLWrapper cqlWrapper = new CQLWrapper(new CQL2PgJSON("jsonb"), cql);
    with(randomUuid(), "a", randomUuid(), "b", trans -> {
        return trans.streamGet("t", Pojo.class, cqlWrapper, as -> {
            PostgresClientStreamResult<Pojo> r = as.result();
            assertThat(r.resultInfo().getTotalRecords()).isEqualTo(total);
            r.handler(x -> count.incrementAndGet());
            r.exceptionHandler(t -> vtc.failNow(t));
            r.endHandler(x -> end.set(true));
        });
    }).onComplete(succeedingThenComplete(vtc, x -> {
        assertThat(count.get()).isEqualTo(total);
        assertThat(end.get()).isTrue();
    }));
}
Also used : VertxTestContext(io.vertx.junit5.VertxTestContext) BeforeEach(org.junit.jupiter.api.BeforeEach) CsvSource(org.junit.jupiter.params.provider.CsvSource) CQLWrapper(org.folio.rest.persist.cql.CQLWrapper) BiFunction(java.util.function.BiFunction) PostgresTesterContainer(org.folio.postgres.testing.PostgresTesterContainer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WithAssertions(org.assertj.core.api.WithAssertions) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Timeout(io.vertx.junit5.Timeout) AfterAll(org.junit.jupiter.api.AfterAll) CQL2PgJSONException(org.folio.cql2pgjson.exception.CQL2PgJSONException) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BeforeAll(org.junit.jupiter.api.BeforeAll) JsonObject(io.vertx.core.json.JsonObject) AsyncResult(io.vertx.core.AsyncResult) Vertx(io.vertx.core.Vertx) UUID(java.util.UUID) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) JsonArray(io.vertx.core.json.JsonArray) CQL2PgJSON(org.folio.cql2pgjson.CQL2PgJSON) PgConnection(io.vertx.pgclient.PgConnection) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Handler(io.vertx.core.Handler) Collections(java.util.Collections) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CQL2PgJSON(org.folio.cql2pgjson.CQL2PgJSON) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CQLWrapper(org.folio.rest.persist.cql.CQLWrapper) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AsyncResult (io.vertx.core.AsyncResult)2 Future (io.vertx.core.Future)2 Handler (io.vertx.core.Handler)2 Vertx (io.vertx.core.Vertx)2 JsonArray (io.vertx.core.json.JsonArray)2 JsonObject (io.vertx.core.json.JsonObject)2 Timeout (io.vertx.junit5.Timeout)2 VertxExtension (io.vertx.junit5.VertxExtension)2 VertxTestContext (io.vertx.junit5.VertxTestContext)2 PgConnection (io.vertx.pgclient.PgConnection)2 Collections (java.util.Collections)2 UUID (java.util.UUID)2 TimeUnit (java.util.concurrent.TimeUnit)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 BiFunction (java.util.function.BiFunction)2 Function (java.util.function.Function)2 Supplier (java.util.function.Supplier)2 WithAssertions (org.assertj.core.api.WithAssertions)2 CQL2PgJSON (org.folio.cql2pgjson.CQL2PgJSON)2