nastra commented on code in PR #9341:
URL: https://github.com/apache/iceberg/pull/9341#discussion_r1432757273
##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/data/GenericsHelpers.java:
##########
@@ -264,86 +259,83 @@ private static void assertEqualsUnsafe(Type type, Object
expected, Object actual
case LONG:
case FLOAT:
case DOUBLE:
- Assert.assertEquals("Primitive value should be equal to expected",
expected, actual);
+ assertThat(actual).as("Primitive value should be equal to
expected").isEqualTo(expected);
break;
case DATE:
- Assertions.assertThat(expected)
- .as("Should expect a LocalDate")
- .isInstanceOf(LocalDate.class);
+ assertThat(expected).as("Should expect a
LocalDate").isInstanceOf(LocalDate.class);
int expectedDays = (int) ChronoUnit.DAYS.between(EPOCH_DAY,
(LocalDate) expected);
- Assert.assertEquals("Primitive value should be equal to expected",
expectedDays, actual);
+ assertThat(actual)
+ .as("Primitive value should be equal to expected")
+ .isEqualTo(expectedDays);
break;
case TIMESTAMP:
Types.TimestampType timestampType = (Types.TimestampType) type;
if (timestampType.shouldAdjustToUTC()) {
- Assertions.assertThat(expected)
+ assertThat(expected)
.as("Should expect an OffsetDateTime")
.isInstanceOf(OffsetDateTime.class);
long expectedMicros = ChronoUnit.MICROS.between(EPOCH,
(OffsetDateTime) expected);
- Assert.assertEquals(
- "Primitive value should be equal to expected", expectedMicros,
actual);
+ assertThat(actual)
+ .as("Primitive value should be equal to expected")
+ .isEqualTo(expectedMicros);
} else {
- Assertions.assertThat(expected)
+ assertThat(expected)
.as("Should expect an LocalDateTime")
.isInstanceOf(LocalDateTime.class);
long expectedMicros =
ChronoUnit.MICROS.between(EPOCH, ((LocalDateTime)
expected).atZone(ZoneId.of("UTC")));
- Assert.assertEquals(
- "Primitive value should be equal to expected", expectedMicros,
actual);
+ assertThat(actual)
+ .as("Primitive value should be equal to expected")
+ .isEqualTo(expectedMicros);
}
break;
case STRING:
- Assertions.assertThat(actual).as("Should be a
UTF8String").isInstanceOf(UTF8String.class);
- Assert.assertEquals("Strings should be equal", expected,
actual.toString());
+ assertThat(actual).as("Should be a
UTF8String").isInstanceOf(UTF8String.class);
+ assertThat(actual.toString())
+ .as("Strings should be equal")
+ .isEqualTo(String.valueOf(expected));
break;
case UUID:
- Assertions.assertThat(expected).as("Should expect a
UUID").isInstanceOf(UUID.class);
- Assertions.assertThat(actual).as("Should be a
UTF8String").isInstanceOf(UTF8String.class);
- Assert.assertEquals(
- "UUID string representation should match", expected.toString(),
actual.toString());
+ assertThat(expected).as("Should expect a
UUID").isInstanceOf(UUID.class);
+ assertThat(actual).as("Should be a
UTF8String").isInstanceOf(UTF8String.class);
+ assertThat(actual.toString())
+ .as("UUID string representation should match")
+ .isEqualTo(String.valueOf(expected));
break;
case FIXED:
- Assertions.assertThat(expected).as("Should expect a
byte[]").isInstanceOf(byte[].class);
- Assertions.assertThat(actual).as("Should be a
byte[]").isInstanceOf(byte[].class);
- Assert.assertArrayEquals("Bytes should match", (byte[]) expected,
(byte[]) actual);
+ assertThat(expected).as("Should expect a
byte[]").isInstanceOf(byte[].class);
+ assertThat(actual).as("Should be a byte[]").isInstanceOf(byte[].class);
+ assertThat(actual).as("Bytes should match").isEqualTo(expected);
break;
case BINARY:
- Assertions.assertThat(expected)
- .as("Should expect a ByteBuffer")
- .isInstanceOf(ByteBuffer.class);
- Assertions.assertThat(actual).as("Should be a
byte[]").isInstanceOf(byte[].class);
- Assert.assertArrayEquals(
- "Bytes should match", ((ByteBuffer) expected).array(), (byte[])
actual);
+ assertThat(expected).as("Should expect a
ByteBuffer").isInstanceOf(ByteBuffer.class);
+ assertThat(actual).as("Should be a byte[]").isInstanceOf(byte[].class);
+ assertThat((byte[]) actual)
Review Comment:
cast is probably not needed
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]