use of io.vertx.sqlclient.data.Numeric in project vertx-sql-client by eclipse-vertx.
the class NumericTypesExtendedCodecTest method testEncodeIntArray.
@Test
public void testEncodeIntArray(TestContext ctx) {
Async async = ctx.async();
PgConnection.connect(vertx, options, ctx.asyncAssertSuccess(conn -> {
conn.prepare("UPDATE \"ArrayDataType\" SET \"Integer\" = $1 WHERE \"id\" = $2 RETURNING \"Integer\"", ctx.asyncAssertSuccess(p -> {
p.query().execute(Tuple.tuple().addArrayOfInteger(new Integer[] { 3, 4, 5, 6 }).addInteger(2), ctx.asyncAssertSuccess(result -> {
ColumnChecker.checkColumn(0, "Integer").returns(Tuple::getValue, Row::getValue, ColumnChecker.toObjectArray(new int[] { 3, 4, 5, 6 })).returns(Tuple::getArrayOfShorts, Row::getArrayOfShorts, ColumnChecker.toObjectArray(new short[] { 3, 4, 5, 6 })).returns(Tuple::getArrayOfIntegers, Row::getArrayOfIntegers, ColumnChecker.toObjectArray(new int[] { 3, 4, 5, 6 })).returns(Tuple::getArrayOfLongs, Row::getArrayOfLongs, ColumnChecker.toObjectArray(new long[] { 3, 4, 5, 6 })).returns(Tuple::getArrayOfFloats, Row::getArrayOfFloats, ColumnChecker.toObjectArray(new float[] { 3, 4, 5, 6 })).returns(Tuple::getArrayOfDoubles, Row::getArrayOfDoubles, ColumnChecker.toObjectArray(new double[] { 3, 4, 5, 6 })).returns(Tuple::getArrayOfNumerics, Row::getArrayOfNumerics, ColumnChecker.toObjectArray(new Numeric[] { Numeric.create(3), Numeric.create(4), Numeric.create(5), Numeric.create(6) })).forRow(result.iterator().next());
async.complete();
}));
}));
}));
}
use of io.vertx.sqlclient.data.Numeric in project vertx-sql-client by eclipse-vertx.
the class NumericTypesExtendedCodecTest method testEncodeShortArray.
@Test
public void testEncodeShortArray(TestContext ctx) {
Async async = ctx.async();
PgConnection.connect(vertx, options, ctx.asyncAssertSuccess(conn -> {
conn.prepare("UPDATE \"ArrayDataType\" SET \"Short\" = $1 WHERE \"id\" = $2 RETURNING \"Short\"", ctx.asyncAssertSuccess(p -> {
p.query().execute(Tuple.tuple().addArrayOfShort(new Short[] { 2, 3, 4 }).addInteger(2), ctx.asyncAssertSuccess(result -> {
ColumnChecker.checkColumn(0, "Short").returns(Tuple::getValue, Row::getValue, ColumnChecker.toObjectArray(new short[] { 2, 3, 4 })).returns(Tuple::getArrayOfShorts, Row::getArrayOfShorts, ColumnChecker.toObjectArray(new short[] { 2, 3, 4 })).returns(Tuple::getArrayOfIntegers, Row::getArrayOfIntegers, ColumnChecker.toObjectArray(new int[] { 2, 3, 4 })).returns(Tuple::getArrayOfLongs, Row::getArrayOfLongs, ColumnChecker.toObjectArray(new long[] { 2, 3, 4 })).returns(Tuple::getArrayOfFloats, Row::getArrayOfFloats, ColumnChecker.toObjectArray(new float[] { 2, 3, 4 })).returns(Tuple::getArrayOfDoubles, Row::getArrayOfDoubles, ColumnChecker.toObjectArray(new double[] { 2, 3, 4 })).returns(Tuple::getArrayOfNumerics, Row::getArrayOfNumerics, ColumnChecker.toObjectArray(new Numeric[] { Numeric.create(2), Numeric.create(3), Numeric.create(4) })).forRow(result.iterator().next());
async.complete();
}));
}));
}));
}
use of io.vertx.sqlclient.data.Numeric in project vertx-sql-client by eclipse-vertx.
the class NumericTypesExtendedCodecTest method testDecodeNumericArray.
@Test
public void testDecodeNumericArray(TestContext ctx) {
Async async = ctx.async();
PgConnection.connect(vertx, options, ctx.asyncAssertSuccess(conn -> {
conn.prepare("SELECT \"Numeric\" FROM \"ArrayDataType\" WHERE \"id\" = $1", ctx.asyncAssertSuccess(p -> {
p.query().execute(Tuple.tuple().addInteger(1), ctx.asyncAssertSuccess(result -> {
Numeric[] expected = { Numeric.create(0), Numeric.create(1), Numeric.create(2), Numeric.create(3) };
ColumnChecker.checkColumn(0, "Numeric").returns(Tuple::getValue, Row::getValue, expected).returns(Tuple::getArrayOfShorts, Row::getArrayOfShorts, new Short[] { 0, 1, 2, 3 }).returns(Tuple::getArrayOfIntegers, Row::getArrayOfIntegers, new Integer[] { 0, 1, 2, 3 }).returns(Tuple::getArrayOfLongs, Row::getArrayOfLongs, new Long[] { 0L, 1L, 2L, 3L }).returns(Tuple::getArrayOfFloats, Row::getArrayOfFloats, new Float[] { 0f, 1f, 2f, 3f }).returns(Tuple::getArrayOfDoubles, Row::getArrayOfDoubles, new Double[] { 0D, 1D, 2D, 3D }).returns(Tuple::getArrayOfNumerics, Row::getArrayOfNumerics, new Numeric[] { Numeric.create(0), Numeric.create(1), Numeric.create(2), Numeric.create(3) }).forRow(result.iterator().next());
async.complete();
}));
}));
}));
}
use of io.vertx.sqlclient.data.Numeric in project vertx-sql-client by eclipse-vertx.
the class NumericTypesExtendedCodecTest method testEncodeEmptyArray.
@Test
public void testEncodeEmptyArray(TestContext ctx) {
Async async = ctx.async();
PgConnection.connect(vertx, options, ctx.asyncAssertSuccess(conn -> {
conn.prepare("UPDATE \"ArrayDataType\" SET \"Double\" = $1 WHERE \"id\" = $2 RETURNING \"Double\"", ctx.asyncAssertSuccess(p -> {
p.query().execute(Tuple.tuple().addArrayOfDouble(new Double[] {}).addInteger(2), ctx.asyncAssertSuccess(result -> {
ColumnChecker.checkColumn(0, "Double").returns(Tuple::getValue, Row::getValue, ColumnChecker.toObjectArray(new double[] {})).returns(Tuple::getArrayOfShorts, Row::getArrayOfShorts, ColumnChecker.toObjectArray(new short[] {})).returns(Tuple::getArrayOfIntegers, Row::getArrayOfIntegers, ColumnChecker.toObjectArray(new int[] {})).returns(Tuple::getArrayOfLongs, Row::getArrayOfLongs, ColumnChecker.toObjectArray(new long[] {})).returns(Tuple::getArrayOfFloats, Row::getArrayOfFloats, ColumnChecker.toObjectArray(new float[] {})).returns(Tuple::getArrayOfDoubles, Row::getArrayOfDoubles, ColumnChecker.toObjectArray(new double[] {})).returns(Tuple::getArrayOfNumerics, Row::getArrayOfNumerics, ColumnChecker.toObjectArray(new Numeric[] {})).forRow(result.iterator().next());
async.complete();
}));
}));
}));
}
use of io.vertx.sqlclient.data.Numeric in project vertx-sql-client by eclipse-vertx.
the class NumericTypesExtendedCodecTest method testDecodeIntArray.
@Test
public void testDecodeIntArray(TestContext ctx) {
Async async = ctx.async();
PgConnection.connect(vertx, options, ctx.asyncAssertSuccess(conn -> {
conn.prepare("SELECT \"Integer\" FROM \"ArrayDataType\" WHERE \"id\" = $1", ctx.asyncAssertSuccess(p -> {
p.query().execute(Tuple.tuple().addInteger(1), ctx.asyncAssertSuccess(result -> {
ColumnChecker.checkColumn(0, "Integer").returns(Tuple::getValue, Row::getValue, ColumnChecker.toObjectArray(new int[] { 2 })).returns(Tuple::getArrayOfShorts, Row::getArrayOfShorts, ColumnChecker.toObjectArray(new short[] { 2 })).returns(Tuple::getArrayOfIntegers, Row::getArrayOfIntegers, ColumnChecker.toObjectArray(new int[] { 2 })).returns(Tuple::getArrayOfLongs, Row::getArrayOfLongs, ColumnChecker.toObjectArray(new long[] { 2 })).returns(Tuple::getArrayOfFloats, Row::getArrayOfFloats, ColumnChecker.toObjectArray(new float[] { 2 })).returns(Tuple::getArrayOfDoubles, Row::getArrayOfDoubles, ColumnChecker.toObjectArray(new double[] { 2 })).returns(Tuple::getArrayOfNumerics, Row::getArrayOfNumerics, ColumnChecker.toObjectArray(new Numeric[] { Numeric.create(2) })).forRow(result.iterator().next());
async.complete();
}));
}));
}));
}
Aggregations