Search in sources :

Example 1 with Row

use of io.vertx.mutiny.sqlclient.Row in project smallrye-mutiny-vertx-bindings by smallrye.

the class PostGreSQLClientTest method testSequence.

@Test
public void testSequence() {
    PgConnectOptions options = new PgConnectOptions().setPort(container.getMappedPort(5432)).setHost(container.getContainerIpAddress()).setDatabase(container.getDatabaseName()).setUser(container.getUsername()).setPassword(container.getPassword());
    Pool client = PgPool.pool(vertx, options, new PoolOptions().setMaxSize(5));
    Uni<Tuple2<RowSet<Row>, RowSet<Row>>> uni = client.getConnection().flatMap(c -> Uni.combine().all().unis(c.preparedQuery("SELECT 1").execute(), c.preparedQuery("SELECT 1").execute()).asTuple());
    Tuple2<RowSet<Row>, RowSet<Row>> results = uni.await().indefinitely();
    assertThat(results).isNotNull();
    assertThat(results.size()).isEqualTo(2);
    assertThat(results.getItem1()).isNotNull();
    assertThat(results.getItem2()).isNotNull();
}
Also used : PgConnectOptions(io.vertx.pgclient.PgConnectOptions) Tuple2(io.smallrye.mutiny.tuples.Tuple2) PoolOptions(io.vertx.sqlclient.PoolOptions) RowSet(io.vertx.mutiny.sqlclient.RowSet) PgPool(io.vertx.mutiny.pgclient.PgPool) Pool(io.vertx.mutiny.sqlclient.Pool) Row(io.vertx.mutiny.sqlclient.Row)

Example 2 with Row

use of io.vertx.mutiny.sqlclient.Row in project smallrye-mutiny-vertx-bindings by smallrye.

the class DB2ClientTest method testSequence.

@Test
public void testSequence() {
    DB2ConnectOptions options = new DB2ConnectOptions().setPort(container.getMappedPort(50000)).setHost(container.getContainerIpAddress()).setDatabase(container.getDatabaseName()).setUser(container.getUsername()).setPassword(container.getPassword());
    Pool client = DB2Pool.pool(vertx, options, new PoolOptions().setMaxSize(5));
    Uni<Tuple2<RowSet<Row>, RowSet<Row>>> uni = client.getConnection().flatMap(c -> Uni.combine().all().unis(c.preparedQuery("SELECT 1 FROM SYSIBM.SYSDUMMY1").execute(), c.preparedQuery("SELECT 1 FROM SYSIBM.SYSDUMMY1").execute()).asTuple());
    Tuple2<RowSet<Row>, RowSet<Row>> results = uni.await().indefinitely();
    assertThat(results).isNotNull();
    assertThat(results.size()).isEqualTo(2);
    assertThat(results.getItem1()).isNotNull();
    assertThat(results.getItem2()).isNotNull();
}
Also used : Tuple2(io.smallrye.mutiny.tuples.Tuple2) PoolOptions(io.vertx.sqlclient.PoolOptions) RowSet(io.vertx.mutiny.sqlclient.RowSet) DB2ConnectOptions(io.vertx.db2client.DB2ConnectOptions) Pool(io.vertx.mutiny.sqlclient.Pool) DB2Pool(io.vertx.mutiny.db2client.DB2Pool) Row(io.vertx.mutiny.sqlclient.Row) Test(org.junit.Test)

Example 3 with Row

use of io.vertx.mutiny.sqlclient.Row in project kogito-apps by kiegroup.

the class PostgreSqlJobRepositoryTest method from.

@Test
void from() {
    PointInTimeTrigger trigger = new PointInTimeTrigger(time.toInstant().getEpochSecond(), null, null);
    Recipient recipient = new Recipient.HTTPRecipient("test");
    Row row = mock(Row.class);
    when(row.getString("id")).thenReturn("test");
    when(row.getString("correlation_id")).thenReturn("test");
    when(row.getString("status")).thenReturn("SCHEDULED");
    when(row.getOffsetDateTime("last_update")).thenReturn(time.toOffsetDateTime());
    when(row.getInteger("retries")).thenReturn(1);
    when(row.getInteger("execution_counter")).thenReturn(1);
    when(row.getString("scheduled_id")).thenReturn("test");
    when(row.get(JsonObject.class, 7)).thenReturn(new JsonObject("{\"payload\": \"test\"}"));
    when(row.getString("type")).thenReturn("HTTP");
    when(row.getInteger("priority")).thenReturn(1);
    when(row.get(JsonObject.class, 10)).thenReturn(new JsonObject().put("recipientMarshaller", "test"));
    when(row.get(JsonObject.class, 11)).thenReturn(new JsonObject().put("triggerMarshaller", "test"));
    JobDetails jobDetails = repository.from(row);
    JobDetails expected = JobDetails.builder().id("test").correlationId("test").status(JobStatus.SCHEDULED).lastUpdate(time).retries(1).executionCounter(1).scheduledId("test").payload("{\"payload\": \"test\"}").type(JobDetails.Type.HTTP).priority(1).recipient(recipient).trigger(trigger).build();
    assertEquals(expected, jobDetails);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) Recipient(org.kie.kogito.jobs.service.model.job.Recipient) Row(io.vertx.mutiny.sqlclient.Row) PointInTimeTrigger(org.kie.kogito.timer.impl.PointInTimeTrigger) JobDetails(org.kie.kogito.jobs.service.model.job.JobDetails) Test(org.junit.jupiter.api.Test)

Aggregations

Row (io.vertx.mutiny.sqlclient.Row)3 Tuple2 (io.smallrye.mutiny.tuples.Tuple2)2 Pool (io.vertx.mutiny.sqlclient.Pool)2 RowSet (io.vertx.mutiny.sqlclient.RowSet)2 PoolOptions (io.vertx.sqlclient.PoolOptions)2 JsonObject (io.vertx.core.json.JsonObject)1 DB2ConnectOptions (io.vertx.db2client.DB2ConnectOptions)1 DB2Pool (io.vertx.mutiny.db2client.DB2Pool)1 PgPool (io.vertx.mutiny.pgclient.PgPool)1 PgConnectOptions (io.vertx.pgclient.PgConnectOptions)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 JobDetails (org.kie.kogito.jobs.service.model.job.JobDetails)1 Recipient (org.kie.kogito.jobs.service.model.job.Recipient)1 PointInTimeTrigger (org.kie.kogito.timer.impl.PointInTimeTrigger)1