Skip to content

Commit 9527c56

Browse files
committed
Improve a couple of tests
1 parent ae2d36f commit 9527c56

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

vertx-pg-client/src/test/java/io/vertx/pgclient/data/BooleanTypeExtendedCodecTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import org.junit.Test;
1010

1111
public class BooleanTypeExtendedCodecTest extends ExtendedQueryDataTypeCodecTestBase {
12+
1213
@Test
1314
public void testDecodeBoolean(TestContext ctx) {
14-
testGeneric(ctx, "SELECT $1::BOOLEAN \"Boolean\"", new Boolean[]{true}, Tuple::getBoolean);
15+
testDecode(ctx, "SELECT true", Tuple::getBoolean, true);
1516
}
1617

1718
@Test
@@ -38,14 +39,12 @@ public void testEncodeBoolean(TestContext ctx) {
3839
}
3940

4041
@Test
41-
public void testBooleanArray(TestContext ctx) {
42-
testGeneric(ctx,
43-
"SELECT c FROM (VALUES ($1 :: BOOL[])) AS t (c)",
44-
new Boolean[][]{new Boolean[]{true, null, false}}, Tuple::getArrayOfBooleans);
42+
public void testDecodeBooleanArray(TestContext ctx) {
43+
testDecode(ctx, "SELECT '{ true, false }'::BOOL[]", Tuple::getArrayOfBooleans, (Object)(new Boolean[] { true, false }));
4544
}
4645

4746
@Test
48-
public void testDecodeBooleanArray(TestContext ctx) {
47+
public void testDecodeBooleanArray_(TestContext ctx) {
4948
Async async = ctx.async();
5049
PgConnection.connect(vertx, options, ctx.asyncAssertSuccess(conn -> {
5150
conn.prepare("SELECT \"Boolean\" FROM \"ArrayDataType\" WHERE \"id\" = $1",

vertx-pg-client/src/test/java/io/vertx/pgclient/data/CharacterTypesExtendedCodecTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import org.junit.Test;
1010

1111
public class CharacterTypesExtendedCodecTest extends ExtendedQueryDataTypeCodecTestBase {
12+
1213
@Test
1314
public void testDecodeName(TestContext ctx) {
14-
testGeneric(ctx, "SELECT $1::NAME \"Name\"", new String[]{"What is my name ?"}, Tuple::getString);
15+
testDecode(ctx, "SELECT 'What is my name ?'::NAME", Tuple::getString, "What is my name ?");
1516
}
1617

1718
@Test
@@ -37,10 +38,9 @@ public void testEncodeName(TestContext ctx) {
3738
}));
3839
}
3940

40-
4141
@Test
4242
public void testDecodeChar(TestContext ctx) {
43-
testGeneric(ctx, "SELECT $1::CHAR \"SingleChar\"", new String[]{"A"}, Tuple::getString);
43+
testDecode(ctx, "SELECT 'A'::CHAR", Tuple::getString, "A");
4444
}
4545

4646
@Test
@@ -68,7 +68,7 @@ public void testEncodeChar(TestContext ctx) {
6868

6969
@Test
7070
public void testDecodeFixedChar(TestContext ctx) {
71-
testGeneric(ctx, "SELECT $1::CHAR(3) \"FixedChar\"", new String[]{"YES"}, Tuple::getString);
71+
testDecode(ctx, "SELECT 'YES'::CHAR(3)", Tuple::getString, "YES");
7272
}
7373

7474
@Test
@@ -96,7 +96,7 @@ public void testEncodeFixedChar(TestContext ctx) {
9696

9797
@Test
9898
public void testDecodeText(TestContext ctx) {
99-
testGeneric(ctx, "SELECT $1::TEXT \"Text\"", new String[]{"Hello World"}, Tuple::getString);
99+
testDecode(ctx, "SELECT 'Hello World'::TEXT", Tuple::getString, "Hello World");
100100
}
101101

102102
@Test
@@ -123,8 +123,8 @@ public void testEncodeText(TestContext ctx) {
123123
}
124124

125125
@Test
126-
public void testDecodeVarCharacter(TestContext ctx) {
127-
testGeneric(ctx, "SELECT $1::VARCHAR \"VarCharacter\"", new String[]{"Great!"}, Tuple::getString);
126+
public void testDecodeVarchar(TestContext ctx) {
127+
testDecode(ctx, "SELECT 'Great!'::VARCHAR", Tuple::getString, "Great!");
128128
}
129129

130130
@Test
@@ -171,8 +171,8 @@ public void testEncodeLargeVarchar(TestContext ctx) {
171171
}
172172

173173
@Test
174-
public void testDecodeStringArray(TestContext ctx) {
175-
testGeneric(ctx, "SELECT $1::TEXT[]\"Text\"", new String[][]{new String[]{"Knock, knock.Who’s there?very long pause….Java."}}, Tuple::getArrayOfStrings);
174+
public void testDecodeTextArray(TestContext ctx) {
175+
testDecode(ctx, "SELECT '{ \"Knock, knock.Who’s there?very long pause... Java.\" }'::TEXT[]", Tuple::getArrayOfStrings, (Object) new String[] {"Knock, knock.Who’s there?very long pause... Java."});
176176
}
177177

178178
@Test

vertx-pg-client/src/test/java/io/vertx/pgclient/data/MoneyTypeSimpleCodecTest.java renamed to vertx-pg-client/src/test/java/io/vertx/pgclient/data/MonetaryTypeSimpleCodecTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import io.vertx.sqlclient.Tuple;
1616
import org.junit.Test;
1717

18-
public class MoneyTypeSimpleCodecTest extends SimpleQueryDataTypeCodecTestBase {
18+
public class MonetaryTypeSimpleCodecTest extends SimpleQueryDataTypeCodecTestBase {
1919

2020
@Test
2121
public void testMoney(TestContext ctx) {

vertx-pg-client/src/test/java/io/vertx/pgclient/data/UUIDTypeExtendedCodecTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
import java.util.UUID;
1212

1313
public class UUIDTypeExtendedCodecTest extends ExtendedQueryDataTypeCodecTestBase {
14+
1415
@Test
1516
public void testDecodeUUID(TestContext ctx) {
16-
testGeneric(ctx, "SELECT $1::UUID \"uuid\"", new UUID[]{uuid}, Tuple::getUUID);
17+
testDecode(ctx, "SELECT '" + uuid + "'::UUID", Tuple::getUUID, uuid);
1718
}
1819

1920
@Test
@@ -41,7 +42,7 @@ public void testEncodeUUID(TestContext ctx) {
4142

4243
@Test
4344
public void testDecodeUUIDArray(TestContext ctx) {
44-
testGeneric(ctx, "SELECT $1::UUID[] \"UUID\"", new UUID[][]{new UUID[]{uuid}}, Tuple::getArrayOfUUIDs);
45+
testDecode(ctx, "SELECT '{ " + uuid + " }'::UUID[]", Tuple::getArrayOfUUIDs, (Object)(new UUID[] { uuid }));
4546
}
4647

4748
@Test

0 commit comments

Comments
 (0)