rahul8383 commented on a change in pull request #11609:
URL: https://github.com/apache/beam/pull/11609#discussion_r420487951
##########
File path:
sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/logicaltypes/LogicalTypesTest.java
##########
@@ -97,4 +99,19 @@ public void testNanosDuration() {
assertEquals(duration, row.getLogicalTypeValue(0, NanosDuration.class));
assertEquals(durationAsRow, row.getBaseValue(0, Row.class));
}
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testFixedBytesIllegalArgument() {
+ Schema schema = Schema.builder().addLogicalTypeField("char",
FixedBytes.of(10)).build();
+ byte[] byteArrayWithLengthFive = {1, 2, 3, 4, 5};
+ Row row = Row.withSchema(schema).withFieldValue("char",
byteArrayWithLengthFive).build();
+ }
+
+ @Test
+ public void testFixedBytes() {
+ Schema schema = Schema.builder().addLogicalTypeField("char",
FixedBytes.of(10)).build();
+ byte[] byteArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ Row row = Row.withSchema(schema).withFieldValue("char", byteArray).build();
+ assertTrue(Arrays.equals(byteArray, row.getLogicalTypeValue("char",
byte[].class)));
+ }
Review comment:
Moved the tests to RowTest.java
case in point!
How can I write `FixedBytes` test which tests the behaviour of appending
zeros? To test this behaviour, the input value should have length <
expectedLength. But, if the input value's length is less than expected length,
an `IllegalArgumentException` is thrown while building the Row.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]