use of org.folio.rest.persist.helpers.LocalRowSet 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 org.folio.rest.persist.helpers.LocalRowSet 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 org.folio.rest.persist.helpers.LocalRowSet in project raml-module-builder by folio-org.
the class PostgresClientIT method selectReturnEmptySet.
@Test
public void selectReturnEmptySet(TestContext context) {
RowSet rowSet = new LocalRowSet(0);
Promise<RowSet<Row>> promise = Promise.promise();
promise.complete(rowSet);
PostgresClient.selectReturn(promise.future(), context.asyncAssertSuccess(res -> context.assertEquals(null, res)));
}
use of org.folio.rest.persist.helpers.LocalRowSet 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