snuyanzin commented on code in PR #19807:
URL: https://github.com/apache/flink/pull/19807#discussion_r881243667
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcInputFormatTest.java:
##########
@@ -279,7 +279,7 @@ public void
testJdbcInputFormatWithParallelismAndNumericColumnSplitting() throws
jdbcInputFormat.openInputFormat();
InputSplit[] splits = jdbcInputFormat.createInputSplits(1);
// this query exploit parallelism (1 split for every id)
- Assert.assertEquals(TEST_DATA.length, splits.length);
+ assertThat(splits).hasSize(TEST_DATA.length);
Review Comment:
```suggestion
assertThat(splits).hasSameSizeAs(TEST_DATA);
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcInputFormatTest.java:
##########
@@ -356,7 +356,7 @@ public void
testJdbcInputFormatWithParallelismAndGenericSplitting() throws IOExc
jdbcInputFormat.openInputFormat();
InputSplit[] splits = jdbcInputFormat.createInputSplits(1);
// this query exploit parallelism (1 split for every queryParameters
row)
- Assert.assertEquals(queryParameters.length, splits.length);
+ assertThat(splits).hasSize(queryParameters.length);
Review Comment:
```suggestion
assertThat(splits).hasSameSizeAs(queryParameters);
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcDataTypeTest.java:
##########
@@ -170,7 +170,7 @@ public static List<TestItem> testData() {
}
private static TestItem createTestItem(Object... args) {
- assert args.length >= 2;
+ assertThat(args.length).isGreaterThanOrEqualTo(2);
Review Comment:
```suggestion
assertThat(args).hasSizeGreaterThanOrEqualTo(2);
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -54,7 +54,7 @@ public void testSelectField() {
tEnv.sqlQuery(String.format("select id from %s",
TABLE1))
.execute()
.collect());
- assertEquals("[+I[1]]", results.toString());
+ assertThat(results.toString()).isEqualTo("[+I[1]]");
Review Comment:
```suggestion
assertThat(results).hasToString("[+I[1]]");
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -125,9 +125,9 @@ public void testGroupByInsert() throws Exception {
tEnv.sqlQuery(String.format("select * from `%s`",
TABLE_PRIMITIVE_TYPE2))
.execute()
.collect());
- assertEquals(
- "[+I[1, [52, 49], 3, 4, 5.5, 6.6, 7.70000, 8.8, true, a, B, C
, d, 2016-06-22T19:10:25, 2015-01-01, 00:51:03, 500.000000000000000000]]",
- results.toString());
+ assertThat(results.toString())
+ .isEqualTo(
+ "[+I[1, [52, 49], 3, 4, 5.5, 6.6, 7.70000, 8.8, true,
a, B, C , d, 2016-06-22T19:10:25, 2015-01-01, 00:51:03,
500.000000000000000000]]");
Review Comment:
```suggestion
assertThat(results).hasToString(
"[+I[1, [52, 49], 3, 4, 5.5, 6.6, 7.70000, 8.8, true, a, B,
C , d, 2016-06-22T19:10:25, 2015-01-01, 00:51:03, 500.000000000000000000]]");
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -151,28 +151,28 @@ public void testArrayTypes() {
.execute()
.collect());
- assertEquals(
- "[+I["
- + "[1, 2, 3], "
- + "[[50], [51], [52]], "
- + "[3, 4, 5], "
- + "[4, 5, 6], "
- + "[5.5, 6.6, 7.7], "
- + "[6.6, 7.7, 8.8], "
- + "[7.70000, 8.80000, 9.90000], "
- + "[8.800000000000000000, 9.900000000000000000,
10.100000000000000000], "
- + "[9.90, 10.10, 11.11], "
- + "[true, false, true], "
- + "[a, b, c], "
- + "[b, c, d], "
- + "[b , c , d ], "
- + "[b, c, d], "
- + "[2016-06-22T19:10:25, 2019-06-22T19:10:25], "
- + "[2015-01-01, 2020-01-01], "
- + "[00:51:03, 00:59:03], "
- + "null, "
- + "null]]",
- results.toString());
+ assertThat(results.toString())
+ .isEqualTo(
+ "[+I["
+ + "[1, 2, 3], "
+ + "[[50], [51], [52]], "
+ + "[3, 4, 5], "
+ + "[4, 5, 6], "
+ + "[5.5, 6.6, 7.7], "
+ + "[6.6, 7.7, 8.8], "
+ + "[7.70000, 8.80000, 9.90000], "
+ + "[8.800000000000000000,
9.900000000000000000, 10.100000000000000000], "
+ + "[9.90, 10.10, 11.11], "
+ + "[true, false, true], "
+ + "[a, b, c], "
+ + "[b, c, d], "
+ + "[b , c , d ], "
+ + "[b, c, d], "
+ + "[2016-06-22T19:10:25, 2019-06-22T19:10:25],
"
+ + "[2015-01-01, 2020-01-01], "
+ + "[00:51:03, 00:59:03], "
+ + "null, "
+ + "null]]");
Review Comment:
hasToString
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/table/JdbcRowDataInputFormatTest.java:
##########
@@ -234,7 +234,7 @@ public void
testJdbcInputFormatWithParallelismAndNumericColumnSplitting() throws
inputFormat.openInputFormat();
InputSplit[] splits = inputFormat.createInputSplits(1);
// this query exploit parallelism (1 split for every id)
- Assert.assertEquals(TEST_DATA.length, splits.length);
+ assertThat(splits).hasSize(TEST_DATA.length);
Review Comment:
```suggestion
assertThat(splits).hasSameSizeAs(TEST_DATA);
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/internal/connection/SimpleJdbcConnectionProviderTest.java:
##########
@@ -71,49 +61,49 @@ private static JdbcConnectionProvider
newFakeConnectionProvider() {
@Test
public void testEstablishConnection() throws Exception {
JdbcConnectionProvider provider = newFakeConnectionProvider();
- assertNull(provider.getConnection());
- assertFalse(provider.isConnectionValid());
+ assertThat(provider.getConnection()).isNull();
+ assertThat(provider.isConnectionValid()).isFalse();
Connection connection = provider.getOrEstablishConnection();
- assertNotNull(connection);
- assertFalse(connection.isClosed());
- assertTrue(provider.isConnectionValid());
- assertThat(connection, instanceOf(FakeConnection.class));
-
- assertNotNull(provider.getConnection());
- assertSame(connection, provider.getConnection());
- assertSame(connection, provider.getOrEstablishConnection());
+ assertThat(connection).isNotNull();
+ assertThat(connection.isClosed()).isFalse();
+ assertThat(provider.isConnectionValid()).isTrue();
+ assertThat(connection).isInstanceOf(FakeConnection.class);
+
+ assertThat(provider.getConnection()).isNotNull();
+ assertThat(provider.getConnection()).isSameAs(connection);
+ assertThat(provider.getOrEstablishConnection()).isSameAs(connection);
}
@Test
public void testEstablishConnectionWithoutDriverName() throws Exception {
JdbcConnectionProvider provider = newProvider(FakeDBUtils.TEST_DB_URL,
null);
- assertNull(provider.getConnection());
- assertFalse(provider.isConnectionValid());
+ assertThat(provider.getConnection()).isNull();
+ assertThat(provider.isConnectionValid()).isFalse();
Connection connection = provider.getOrEstablishConnection();
- assertNotNull(connection);
- assertFalse(connection.isClosed());
- assertTrue(provider.isConnectionValid());
- assertThat(connection, instanceOf(FakeConnection.class));
- assertThat(connection, not(instanceOf(FakeConnection3.class)));
-
- assertNotNull(provider.getConnection());
- assertSame(connection, provider.getConnection());
- assertSame(connection, provider.getOrEstablishConnection());
+ assertThat(connection).isNotNull();
+ assertThat(connection.isClosed()).isFalse();
+ assertThat(provider.isConnectionValid()).isTrue();
+ assertThat(connection).isInstanceOf(FakeConnection.class);
+ assertThat(connection).isNotInstanceOf(FakeConnection3.class);
+
+ assertThat(provider.getConnection()).isNotNull();
+ assertThat(provider.getConnection()).isSameAs(connection);
Review Comment:
could be joined as
```suggestion
assertThat(connection).isInstanceOf(FakeConnection.class)
.isNotInstanceOf(FakeConnection3.class);
assertThat(provider.getConnection()).isNotNull()
.isSameAs(connection);
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -92,7 +92,7 @@ public void testFullPath() {
PostgresTablePath.fromFlinkTableName(TABLE1)))
.execute()
.collect());
- assertEquals("[+I[1]]", results.toString());
+ assertThat(results.toString()).isEqualTo("[+I[1]]");
Review Comment:
```suggestion
assertThat(results).hasToString("[+I[1]]");
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -77,7 +77,7 @@ public void testWithSchema() {
PostgresTablePath.fromFlinkTableName(TABLE1)))
.execute()
.collect());
- assertEquals("[+I[1]]", results.toString());
+ assertThat(results.toString()).isEqualTo("[+I[1]]");
Review Comment:
```suggestion
assertThat(results).hasToString("[+I[1]]");
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -104,7 +104,7 @@ public void testInsert() throws Exception {
tEnv.sqlQuery(String.format("select * from %s",
TABLE4))
.execute()
.collect());
- assertEquals("[+I[1]]", results.toString());
+ assertThat(results.toString()).isEqualTo("[+I[1]]");
Review Comment:
```suggestion
assertThat(results).hasToString("[+I[1]]");
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -64,7 +64,7 @@ public void testWithoutSchema() {
tEnv.sqlQuery(String.format("select * from %s",
TABLE1))
.execute()
.collect());
- assertEquals("[+I[1]]", results.toString());
+ assertThat(results.toString()).isEqualTo("[+I[1]]");
Review Comment:
```suggestion
assertThat(results).hasToString("[+I[1]]");
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/dialect/oracle/OracleTableSourceITCase.java:
##########
@@ -240,9 +239,9 @@ public void testLimit() throws Exception {
"+I[1, 2020-01-01T15:35:00.123456,
2020-01-01T15:35:00.123456789, 1.175E-10, 1.79769E40, 100.1234]");
expected.add(
"+I[2, 2020-01-01T15:36:01.123456,
2020-01-01T15:36:01.123456789, -1.175E-10, -1.79769E40, 101.1234]");
- assertEquals(1, result.size());
- assertTrue(
- "The actual output is not a subset of the expected set.",
- expected.containsAll(result));
+ assertThat(result).hasSize(1);
+ assertThat(expected.containsAll(result))
+ .as("The actual output is not a subset of the expected set.")
+ .isTrue();
Review Comment:
```suggestion
assertThat(expected)
.as("The actual output is not a subset of the expected
set.").containsAll(result);
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -138,9 +138,9 @@ public void testPrimitiveTypes() {
.execute()
.collect());
- assertEquals(
- "[+I[1, [50], 3, 4, 5.5, 6.6, 7.70000, 8.8, true, a, b, c ,
d, 2016-06-22T19:10:25, 2015-01-01, 00:51:03, 500.000000000000000000]]",
- results.toString());
+ assertThat(results.toString())
+ .isEqualTo(
+ "[+I[1, [50], 3, 4, 5.5, 6.6, 7.70000, 8.8, true, a,
b, c , d, 2016-06-22T19:10:25, 2015-01-01, 00:51:03,
500.000000000000000000]]");
Review Comment:
```suggestion
assertThat(results).hasToString(
"[+I[1, [50], 3, 4, 5.5, 6.6, 7.70000, 8.8, true, a, b, c ,
d, 2016-06-22T19:10:25, 2015-01-01, 00:51:03, 500.000000000000000000]]");
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/internal/connection/SimpleJdbcConnectionProviderTest.java:
##########
@@ -71,49 +61,49 @@ private static JdbcConnectionProvider
newFakeConnectionProvider() {
@Test
public void testEstablishConnection() throws Exception {
JdbcConnectionProvider provider = newFakeConnectionProvider();
- assertNull(provider.getConnection());
- assertFalse(provider.isConnectionValid());
+ assertThat(provider.getConnection()).isNull();
+ assertThat(provider.isConnectionValid()).isFalse();
Connection connection = provider.getOrEstablishConnection();
- assertNotNull(connection);
- assertFalse(connection.isClosed());
- assertTrue(provider.isConnectionValid());
- assertThat(connection, instanceOf(FakeConnection.class));
-
- assertNotNull(provider.getConnection());
- assertSame(connection, provider.getConnection());
- assertSame(connection, provider.getOrEstablishConnection());
+ assertThat(connection).isNotNull();
+ assertThat(connection.isClosed()).isFalse();
+ assertThat(provider.isConnectionValid()).isTrue();
+ assertThat(connection).isInstanceOf(FakeConnection.class);
+
+ assertThat(provider.getConnection()).isNotNull();
+ assertThat(provider.getConnection()).isSameAs(connection);
Review Comment:
could be joined as
```suggestion
assertThat(provider.getConnection()).isNotNull()
.isSameAs(connection);
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/catalog/PostgresCatalogITCase.java:
##########
@@ -183,14 +183,14 @@ public void testSerialTypes() {
.execute()
.collect());
- assertEquals(
- "[+I["
- + "32767, "
- + "2147483647, "
- + "32767, "
- + "2147483647, "
- + "9223372036854775807, "
- + "9223372036854775807]]",
- results.toString());
+ assertThat(results.toString())
+ .isEqualTo(
+ "[+I["
+ + "32767, "
+ + "2147483647, "
+ + "32767, "
+ + "2147483647, "
+ + "9223372036854775807, "
+ + "9223372036854775807]]");
Review Comment:
hasToString
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/xa/XidImplTest.java:
##########
@@ -35,24 +34,26 @@ public void testXidsEqual() {
XidImpl other =
new XidImpl(
XID.getFormatId(), XID.getGlobalTransactionId(),
XID.getBranchQualifier());
- assertEquals(XID, other);
- assertEquals(XID.hashCode(), other.hashCode());
+ assertThat(other).isEqualTo(XID);
+ assertThat(other.hashCode()).isEqualTo(XID.hashCode());
Review Comment:
```suggestion
assertThat(other).isEqualTo(XID)
.hasSameHashCodeAs(XID);
```
##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/table/JdbcRowDataInputFormatTest.java:
##########
@@ -311,7 +311,7 @@ public void
testJdbcInputFormatWithParallelismAndGenericSplitting() throws IOExc
inputFormat.openInputFormat();
InputSplit[] splits = inputFormat.createInputSplits(1);
// this query exploit parallelism (1 split for every queryParameters
row)
- Assert.assertEquals(queryParameters.length, splits.length);
+ assertThat(splits).hasSize(queryParameters.length);
Review Comment:
```suggestion
assertThat(splits).hasSameSizeAs(queryParameters);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]