Java Code Examples for io.vertx.sqlclient.Row#addDouble()

The following examples show how to use io.vertx.sqlclient.Row#addDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PostgresClientTest.java    From raml-module-builder with Apache License 2.0 6 votes vote down vote up
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.addStringArray(new String[] { "This", "is", "a", "test" } );
    rows.add(row);
  }
  return new LocalRowSet(total).withColumns(columnNames).withRows(rows);
}
 
Example 2
Source File: PostgresClientTest.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
@Test
public void testPopulateExternalColumns() throws InvocationTargetException, IllegalAccessException {
  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);
  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.addStringArray(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]));
}