From e4414cc2686923ada325dfc85e1fcac641dad1ed Mon Sep 17 00:00:00 2001 From: Stefan Miklosovic Date: Thu, 27 Jul 2023 13:30:31 +0200 Subject: [PATCH] Upgrade AssertJ to version 3.24.2 patch by Shylaja Kokoori; reviewed by Stefan Miklosovic and Brandon Williams for CASSANDRA-17951 --- .build/parent-pom-template.xml | 6 ++++-- .../distributed/test/SSTableIdGenerationTest.java | 2 +- .../cassandra/distributed/util/QueryResultUtil.java | 11 ++++++----- .../org/apache/cassandra/repair/RepairJobTest.java | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.build/parent-pom-template.xml b/.build/parent-pom-template.xml index 11073d5b18..b675cc153f 100644 --- a/.build/parent-pom-template.xml +++ b/.build/parent-pom-template.xml @@ -1047,17 +1047,19 @@ j2objc-annotations 1.3 + org.junit junit-bom - 5.6.0 + 5.9.1 pom test org.assertj assertj-core - 3.15.0 + 3.24.2 test diff --git a/test/distributed/org/apache/cassandra/distributed/test/SSTableIdGenerationTest.java b/test/distributed/org/apache/cassandra/distributed/test/SSTableIdGenerationTest.java index db2244bc76..62f6139b34 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/SSTableIdGenerationTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/SSTableIdGenerationTest.java @@ -532,6 +532,6 @@ public class SSTableIdGenerationTest extends TestBaseImpl SimpleQueryResult result = instance.executeInternalWithResult(format("SELECT * FROM %s.%s", ks, tableName)); Object[][] rows = result.toObjectArrays(); assertThat(rows).withFailMessage("Invalid results for %s.%s - should have %d rows but has %d: \n%s", ks, tableName, expectedNumber, - rows.length, result.toString()).hasSize(expectedNumber); + rows.length, result.toString()).hasNumberOfRows(expectedNumber); } } diff --git a/test/distributed/org/apache/cassandra/distributed/util/QueryResultUtil.java b/test/distributed/org/apache/cassandra/distributed/util/QueryResultUtil.java index 23d88e6ac5..6ac7c60fb0 100644 --- a/test/distributed/org/apache/cassandra/distributed/util/QueryResultUtil.java +++ b/test/distributed/org/apache/cassandra/distributed/util/QueryResultUtil.java @@ -29,6 +29,7 @@ import org.apache.cassandra.distributed.api.Row; import org.apache.cassandra.distributed.api.SimpleQueryResult; import org.apache.cassandra.tools.nodetool.formatter.TableBuilder; import org.assertj.core.api.Assertions; +import org.assertj.core.data.Index; public class QueryResultUtil { @@ -201,27 +202,27 @@ public class QueryResultUtil public SimpleQueryResultAssertHelper isEqualTo(Object... values) { Assertions.assertThat(qr.toObjectArrays()) - .hasSize(1) - .contains(values); + .hasNumberOfRows(1) + .contains(values, Index.atIndex(0)); return this; } public SimpleQueryResultAssertHelper hasSize(int size) { - Assertions.assertThat(qr.toObjectArrays()).hasSize(size); + Assertions.assertThat(qr.toObjectArrays()).hasNumberOfRows(size); return this; } public SimpleQueryResultAssertHelper hasSizeGreaterThan(int size) { - Assertions.assertThat(qr.toObjectArrays()).hasSizeGreaterThan(size); + Assertions.assertThat((qr.toObjectArrays()).length).isGreaterThan(size); return this; } public void isEmpty() { int size = Iterators.size(qr); - Assertions.assertThat(size).describedAs("QueryResult is not empty").isEqualTo(0); + Assertions.assertThat(size).describedAs("QueryResult is not empty").isZero(); } } diff --git a/test/unit/org/apache/cassandra/repair/RepairJobTest.java b/test/unit/org/apache/cassandra/repair/RepairJobTest.java index 03ac2edc60..db7255f2f5 100644 --- a/test/unit/org/apache/cassandra/repair/RepairJobTest.java +++ b/test/unit/org/apache/cassandra/repair/RepairJobTest.java @@ -712,7 +712,7 @@ public class RepairJobTest false, PreviewKind.ALL)); - assertThat(tasks.values()).areAllInstanceOf(AsymmetricRemoteSyncTask.class); + SyncTaskListAssert.assertThat(tasks.values()).areAllInstanceOf(AsymmetricRemoteSyncTask.class); // addr1 streams range1 from addr3: assertThat(tasks.get(pair(addr1, addr3)).rangesToSync).contains(RANGE_1);