Skip to content

Commit 807ca6c

Browse files
committed
Remove callback usage in tests
1 parent 98a435d commit 807ca6c

File tree

137 files changed

+3097
-1490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+3097
-1490
lines changed

vertx-db2-client/src/test/java/io/vertx/db2client/DB2DataTypeTest.java

Lines changed: 76 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
public class DB2DataTypeTest extends DB2TestBase {
3838

3939

40-
// Enum for enum testing
40+
// Enum for enum testing
4141
enum Days {
4242
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
4343
}
4444

45-
45+
4646
/**
4747
* In DB2 the FLOAT and DOUBLE column types both map to an 8-byte
4848
* double-precision column (i.e. Java double). Ensure that a Java
@@ -51,10 +51,14 @@ enum Days {
5151
@Test
5252
public void testFloatIntoFloatColumn(TestContext ctx) {
5353
connect(ctx.asyncAssertSuccess(conn -> {
54-
conn.preparedQuery("INSERT INTO db2_types (id,test_float) VALUES (?, ?)")
55-
.execute(Tuple.of(1, 5.0f), ctx.asyncAssertSuccess(insertResult -> {
56-
conn.preparedQuery("SELECT id,test_float FROM db2_types WHERE id = 1")
57-
.execute(ctx.asyncAssertSuccess(rows -> {
54+
conn
55+
.preparedQuery("INSERT INTO db2_types (id,test_float) VALUES (?, ?)")
56+
.execute(Tuple.of(1, 5.0f))
57+
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
58+
conn
59+
.preparedQuery("SELECT id,test_float FROM db2_types WHERE id = 1")
60+
.execute()
61+
.onComplete(ctx.asyncAssertSuccess(rows -> {
5862
ctx.assertEquals(1, rows.size());
5963
Row row = rows.iterator().next();
6064
ctx.assertEquals(1, row.getInteger(0));
@@ -72,10 +76,14 @@ public void testFloatIntoFloatColumn(TestContext ctx) {
7276
@Test
7377
public void testByteIntoSmallIntColumn(TestContext ctx) {
7478
connect(ctx.asyncAssertSuccess(conn -> {
75-
conn.preparedQuery("INSERT INTO db2_types (id,test_byte) VALUES (?, ?)")
76-
.execute(Tuple.of(2, (byte) 0xCA), ctx.asyncAssertSuccess(insertResult -> {
77-
conn.preparedQuery("SELECT id,test_byte FROM db2_types WHERE id = 2")
78-
.execute(ctx.asyncAssertSuccess(rows -> {
79+
conn
80+
.preparedQuery("INSERT INTO db2_types (id,test_byte) VALUES (?, ?)")
81+
.execute(Tuple.of(2, (byte) 0xCA))
82+
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
83+
conn
84+
.preparedQuery("SELECT id,test_byte FROM db2_types WHERE id = 2")
85+
.execute()
86+
.onComplete(ctx.asyncAssertSuccess(rows -> {
7987
ctx.assertEquals(1, rows.size());
8088
Row row = rows.iterator().next();
8189
ctx.assertEquals(2, row.getInteger(0));
@@ -89,10 +97,14 @@ public void testByteIntoSmallIntColumn(TestContext ctx) {
8997
public void testByteArrayIntoVarchar(TestContext ctx) {
9098
byte[] expected = "hello world".getBytes();
9199
connect(ctx.asyncAssertSuccess(conn -> {
92-
conn.preparedQuery("INSERT INTO db2_types (id,test_bytes) VALUES (?, ?)")
93-
.execute(Tuple.of(3, "hello world".getBytes()), ctx.asyncAssertSuccess(insertResult -> {
94-
conn.preparedQuery("SELECT id,test_bytes FROM db2_types WHERE id = 3")
95-
.execute(ctx.asyncAssertSuccess(rows -> {
100+
conn
101+
.preparedQuery("INSERT INTO db2_types (id,test_bytes) VALUES (?, ?)")
102+
.execute(Tuple.of(3, "hello world".getBytes()))
103+
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
104+
conn
105+
.preparedQuery("SELECT id,test_bytes FROM db2_types WHERE id = 3")
106+
.execute()
107+
.onComplete(ctx.asyncAssertSuccess(rows -> {
96108
ctx.assertEquals(1, rows.size());
97109
Row row = rows.iterator().next();
98110
ctx.assertEquals(3, row.getInteger(0));
@@ -108,10 +120,14 @@ public void testByteArrayIntoVarchar(TestContext ctx) {
108120
public void testByteBufIntoVarchar(TestContext ctx) {
109121
byte[] expected = "hello world".getBytes();
110122
connect(ctx.asyncAssertSuccess(conn -> {
111-
conn.preparedQuery("INSERT INTO db2_types (id,test_bytes) VALUES (?, ?)")
112-
.execute(Tuple.of(4, Buffer.buffer(expected)), ctx.asyncAssertSuccess(insertResult -> {
113-
conn.preparedQuery("SELECT id,test_bytes FROM db2_types WHERE id = 4")
114-
.execute(ctx.asyncAssertSuccess(rows -> {
123+
conn
124+
.preparedQuery("INSERT INTO db2_types (id,test_bytes) VALUES (?, ?)")
125+
.execute(Tuple.of(4, Buffer.buffer(expected)))
126+
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
127+
conn
128+
.preparedQuery("SELECT id,test_bytes FROM db2_types WHERE id = 4")
129+
.execute()
130+
.onComplete(ctx.asyncAssertSuccess(rows -> {
115131
ctx.assertEquals(1, rows.size());
116132
Row row = rows.iterator().next();
117133
ctx.assertEquals(4, row.getInteger(0));
@@ -127,10 +143,14 @@ public void testByteBufIntoVarchar(TestContext ctx) {
127143
public void testTimestamp(TestContext ctx) {
128144
LocalDateTime now = LocalDateTime.now();
129145
connect(ctx.asyncAssertSuccess(conn -> {
130-
conn.preparedQuery("INSERT INTO db2_types (id,test_tstamp) VALUES (?,?)")
131-
.execute(Tuple.of(5, now), ctx.asyncAssertSuccess(insertResult -> {
132-
conn.preparedQuery("SELECT id,test_tstamp FROM db2_types WHERE id = ?")
133-
.execute(Tuple.of(5), ctx.asyncAssertSuccess(rows -> {
146+
conn
147+
.preparedQuery("INSERT INTO db2_types (id,test_tstamp) VALUES (?,?)")
148+
.execute(Tuple.of(5, now))
149+
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
150+
conn
151+
.preparedQuery("SELECT id,test_tstamp FROM db2_types WHERE id = ?")
152+
.execute(Tuple.of(5))
153+
.onComplete(ctx.asyncAssertSuccess(rows -> {
134154
ctx.assertEquals(1, rows.size());
135155
Row row = rows.iterator().next();
136156
int nowNanos = now.getNano() - (1000 * now.get(ChronoField.MICRO_OF_SECOND));
@@ -146,9 +166,15 @@ public void testTimestamp(TestContext ctx) {
146166
public void testUUID(TestContext ctx) {
147167
UUID uuid = UUID.randomUUID();
148168
connect(ctx.asyncAssertSuccess(conn -> {
149-
conn.preparedQuery("INSERT INTO db2_types (id,test_vchar) VALUES (?,?)").execute(Tuple.of(6, uuid),
169+
conn
170+
.preparedQuery("INSERT INTO db2_types (id,test_vchar) VALUES (?,?)")
171+
.execute(Tuple.of(6, uuid))
172+
.onComplete(
150173
ctx.asyncAssertSuccess(insertResult -> {
151-
conn.preparedQuery("SELECT id,test_vchar FROM db2_types WHERE id = ?").execute(Tuple.of(6),
174+
conn
175+
.preparedQuery("SELECT id,test_vchar FROM db2_types WHERE id = ?")
176+
.execute(Tuple.of(6))
177+
.onComplete(
152178
ctx.asyncAssertSuccess(rows -> {
153179
ctx.assertEquals(1, rows.size());
154180
Row row = rows.iterator().next();
@@ -168,32 +194,41 @@ public void testRowId(TestContext ctx) {
168194
final String msg = "insert data for testRowId";
169195
connect(ctx.asyncAssertSuccess(conn -> {
170196
// Insert some data
171-
conn.preparedQuery("INSERT INTO ROWTEST (message) VALUES ('" + msg + "')")
172-
.execute(ctx.asyncAssertSuccess(insertResult -> {
197+
conn
198+
.preparedQuery("INSERT INTO ROWTEST (message) VALUES ('" + msg + "')")
199+
.execute()
200+
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
173201
// Find it by msg
174-
conn.preparedQuery("SELECT * FROM ROWTEST WHERE message = '" + msg + "'")
175-
.execute(ctx.asyncAssertSuccess(rows -> {
202+
conn
203+
.preparedQuery("SELECT * FROM ROWTEST WHERE message = '" + msg + "'")
204+
.execute()
205+
.onComplete(ctx.asyncAssertSuccess(rows -> {
176206
RowId rowId = verifyRowId(ctx, rows, msg);
177207
// Now find it by rowid
178-
conn.preparedQuery("SELECT * FROM ROWTEST WHERE id = ?")
179-
.execute(Tuple.of(rowId), ctx.asyncAssertSuccess(rows2 -> {
208+
conn
209+
.preparedQuery("SELECT * FROM ROWTEST WHERE id = ?")
210+
.execute(Tuple.of(rowId))
211+
.onComplete(ctx.asyncAssertSuccess(rows2 -> {
180212
verifyRowId(ctx, rows2, msg);
181213
}));
182214
}));
183215
}));
184216
}));
185217
}
186-
218+
187219
/**
188220
* Test to support using enum string values in the Row and Tuple methods.
189221
*/
190222
@Test
191223
public void testUsingEnumNameValue(TestContext ctx) {
192224
connect(ctx.asyncAssertSuccess(conn -> {
193225
conn.preparedQuery("INSERT INTO db2_types (id,test_vchar) VALUES (?, ?)")
194-
.execute(Tuple.of(10, Days.WEDNESDAY), ctx.asyncAssertSuccess(insertResult -> {
195-
conn.preparedQuery("SELECT id,test_vchar FROM db2_types WHERE id = 10")
196-
.execute(ctx.asyncAssertSuccess(rows -> {
226+
.execute(Tuple.of(10, Days.WEDNESDAY))
227+
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
228+
conn
229+
.preparedQuery("SELECT id,test_vchar FROM db2_types WHERE id = 10")
230+
.execute()
231+
.onComplete(ctx.asyncAssertSuccess(rows -> {
197232
ctx.assertEquals(1, rows.size());
198233
Row row = rows.iterator().next();
199234
ctx.assertEquals(10, row.getInteger(0));
@@ -210,9 +245,12 @@ public void testUsingEnumNameValue(TestContext ctx) {
210245
public void testUsingEnumOrdinalValue(TestContext ctx) {
211246
connect(ctx.asyncAssertSuccess(conn -> {
212247
conn.preparedQuery("INSERT INTO db2_types (id,test_int) VALUES (?, ?)")
213-
.execute(Tuple.of(11, Days.FRIDAY.ordinal()), ctx.asyncAssertSuccess(insertResult -> {
214-
conn.preparedQuery("SELECT id,test_int FROM db2_types WHERE id = 11")
215-
.execute(ctx.asyncAssertSuccess(rows -> {
248+
.execute(Tuple.of(11, Days.FRIDAY.ordinal()))
249+
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
250+
conn
251+
.preparedQuery("SELECT id,test_int FROM db2_types WHERE id = 11")
252+
.execute()
253+
.onComplete(ctx.asyncAssertSuccess(rows -> {
216254
ctx.assertEquals(1, rows.size());
217255
Row row = rows.iterator().next();
218256
ctx.assertEquals(11, row.getInteger(0));
@@ -221,7 +259,7 @@ public void testUsingEnumOrdinalValue(TestContext ctx) {
221259
}));
222260
}));
223261
}
224-
262+
225263
private RowId verifyRowId(TestContext ctx, RowSet<Row> rows, String msg) {
226264
ctx.assertEquals(1, rows.size());
227265
Row row = rows.iterator().next();

0 commit comments

Comments
 (0)