use of io.vertx.sqlclient.impl.RowDesc in project raml-module-builder by folio-org.
the class PostgresClientIT method selectReturnOneRow.
@Test
public void selectReturnOneRow(TestContext context) {
List<String> columns = new LinkedList<>();
columns.add("field");
RowDesc rowDesc = new RowDesc(columns);
List<Row> rows = new LinkedList<>();
Row row = new RowImpl(rowDesc);
row.addString("value");
rows.add(row);
RowSet rowSet = new LocalRowSet(1).withColumns(columns).withRows(rows);
Promise<RowSet<Row>> promise = Promise.promise();
promise.complete(rowSet);
PostgresClient.selectReturn(promise.future(), context.asyncAssertSuccess(res -> context.assertEquals("value", res.getString(0))));
}
use of io.vertx.sqlclient.impl.RowDesc in project raml-module-builder by folio-org.
the class PostgresClientTest method testPopulateExternalColumns.
@Test
public void testPopulateExternalColumns() throws Exception {
PostgresClient testClient = PostgresClient.testClient();
List<String> columnNames = new ArrayList<String>(Arrays.asList(new String[] { "id", "foo", "bar", "biz", "baz" }));
Map<String, Method> externalColumnSetters = new HashMap<>();
testClient.collectExternalColumnSetters(columnNames, TestPojo.class, false, externalColumnSetters);
externalColumnSetters.put("nonExistingColumn", TestPojo.class.getMethod("setBar", String.class));
TestPojo o = new TestPojo();
String foo = "Hello";
String bar = "World";
Double biz = 1.0;
String[] baz = new String[] { "This", "is", "a", "test" };
List<String> rowColumns = new LinkedList<>();
rowColumns.add("foo");
rowColumns.add("bar");
rowColumns.add("biz");
rowColumns.add("baz");
RowDesc desc = new RowDesc(rowColumns);
Row row = new RowImpl(desc);
row.addString(foo);
row.addString(bar);
row.addDouble(biz);
row.addArrayOfString(baz);
testClient.populateExternalColumns(externalColumnSetters, o, row);
assertThat(o.getFoo(), is(foo));
assertThat(o.getBar(), is(bar));
assertThat(o.getBiz(), is(biz));
assertThat(o.getBaz().size(), is(baz.length));
assertThat(o.getBaz().get(0), is(baz[0]));
assertThat(o.getBaz().get(1), is(baz[1]));
assertThat(o.getBaz().get(2), is(baz[2]));
assertThat(o.getBaz().get(3), is(baz[3]));
}
use of io.vertx.sqlclient.impl.RowDesc in project raml-module-builder by folio-org.
the class PostgresClientTest method getMockTestPojoResultSet.
private RowSet<Row> getMockTestPojoResultSet(int total) {
List<String> columnNames = new ArrayList<String>(Arrays.asList(new String[] { "id", "foo", "bar", "biz", "baz" }));
RowDesc rowDesc = new RowDesc(columnNames);
List<Row> rows = new LinkedList<>();
for (int i = 0; i < total; i++) {
Row row = new RowImpl(rowDesc);
row.addUUID(UUID.randomUUID());
row.addString("foo " + i);
row.addString("bar " + i);
row.addDouble((double) i);
row.addArrayOfString(new String[] { "This", "is", "a", "test" });
rows.add(row);
}
return new LocalRowSet(total).withColumns(columnNames).withRows(rows);
}
use of io.vertx.sqlclient.impl.RowDesc in project raml-module-builder by folio-org.
the class PostgresClientTest method getMockTestJsonbPojoResultSet.
private RowSet<Row> getMockTestJsonbPojoResultSet(int total) {
List<String> columnNames = new ArrayList<String>(Arrays.asList(new String[] { "jsonb" }));
RowDesc rowDesc = new RowDesc(columnNames);
List<String> baz = new ArrayList<String>(Arrays.asList(new String[] { "This", "is", "a", "test" }));
List<Row> rows = new LinkedList<>();
for (int i = 0; i < total; i++) {
Row row = new RowImpl(rowDesc);
row.addValue(new JsonObject().put("id", UUID.randomUUID().toString()).put("foo", "foo " + i).put("bar", "bar " + i).put("biz", (double) i).put("baz", baz));
rows.add(row);
}
return new LocalRowSet(total).withColumns(columnNames).withRows(rows);
}
Aggregations