Skip to content

Commit a03b459

Browse files
dfa1claude
andcommitted
test: use dedicated AssertJ assertions (Sonar S5838)
Replace size/toString/hashCode/map/array equality checks with hasSize, hasToString, hasSameHashCodeAs, containsEntry, hasSameSizeAs, isNotEmpty. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 40a43d6 commit a03b459

6 files changed

Lines changed: 7 additions & 7 deletions

File tree

core/src/test/java/io/github/dfa1/vortex/encoding/EncodingIdTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void id_isNonBlankString(EncodingId id) {
4040
@EnumSource(EncodingId.class)
4141
void toString_equalsId(EncodingId id) {
4242
// Given / When / Then
43-
assertThat(id.toString()).isEqualTo(id.id());
43+
assertThat(id).hasToString(id.id());
4444
}
4545
}
4646
}

core/src/test/java/io/github/dfa1/vortex/proto/ProtoRuntimeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void recordsWithEqualByteArraysAreEqual() {
316316

317317
// When + Then
318318
assertThat(a).isEqualTo(b);
319-
assertThat(a.hashCode()).isEqualTo(b.hashCode());
319+
assertThat(a).hasSameHashCodeAs(b);
320320
}
321321

322322
@Test

integration/src/test/java/io/github/dfa1/vortex/integration/RustJavaReaderComparisonIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ void rust_vs_javaReader_statsMatch(String fixture, @TempDir Path tmp) throws Exc
428428
.as("string column names in %s", fixture)
429429
.containsAll(resultRust.strLenSums().keySet());
430430
for (Map.Entry<String, Long> entry : resultRust.strLenSums().entrySet()) {
431-
assertThat(resultJava.strLenSums().get(entry.getKey()))
431+
assertThat(resultJava.strLenSums())
432432
.describedAs("string column '%s' byte-length sum in %s", entry.getKey(), fixture)
433-
.isEqualTo(entry.getValue());
433+
.containsEntry(entry.getKey(), entry.getValue());
434434
}
435435
}
436436
}

integration/src/test/java/io/github/dfa1/vortex/integration/RustWritesJavaReadsIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ void jniWriter_javaReader_f16_primitiveRoundTrip(@TempDir Path tmp) throws IOExc
549549
assertThat(results).hasSize(1);
550550
// F16 column snapshots as a short[] (raw float16 bits)
551551
short[] decoded = (short[]) results.getFirst().columns().get("v");
552-
assertThat(decoded.length).isEqualTo(f16bits.length);
552+
assertThat(decoded).hasSameSizeAs(f16bits);
553553
for (int i = 0; i < f16bits.length; i++) {
554554
assertThat(Float.float16ToFloat(decoded[i]))
555555
.as("index %d", i)

reader/src/test/java/io/github/dfa1/vortex/reader/array/VarBinViewModeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void getStringFromReferencedDataBuffer() {
6060
try (Arena arena = Arena.ofConfined()) {
6161
// Given a 13-byte string (exceeds 12-byte inline limit) stored in a shared data buffer.
6262
String longStr = "thirteen-byte";
63-
assertThat(longStr.length()).isEqualTo(13);
63+
assertThat(longStr).hasSize(13);
6464
MemorySegment dataBuf = arena.allocate(longStr.length());
6565
MemorySegment.copy(MemorySegment.ofArray(longStr.getBytes(StandardCharsets.UTF_8)),
6666
0, dataBuf, 0, longStr.length());

writer/src/test/java/io/github/dfa1/vortex/writer/encode/ZstdEncodingEncoderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void encode_i32_metadata_framesCount_isNonZero() throws Exception {
283283
var metaSeg = java.lang.foreign.MemorySegment.ofBuffer(result.rootNode().metadata().duplicate());
284284
ZstdMetadata meta = ZstdMetadata.decode(metaSeg, 0, metaSeg.byteSize());
285285

286-
assertThat(meta.frames().size()).isGreaterThan(0);
286+
assertThat(meta.frames()).isNotEmpty();
287287
}
288288
}
289289
}

0 commit comments

Comments
 (0)