ahmedabu98 commented on code in PR #38490:
URL: https://github.com/apache/beam/pull/38490#discussion_r3276021675
##########
sdks/java/core/src/test/java/org/apache/beam/sdk/util/WindowedValueTest.java:
##########
@@ -128,6 +128,35 @@ public void testWindowedValueWithElementMetadataCoder()
throws CoderException {
Assert.assertEquals(CausedByDrain.CAUSED_BY_DRAIN, value.causedByDrain());
Assert.assertNotNull(value.getOpenTelemetryContext());
Assert.assertEquals(ValueKind.DELETE, value.getValueKind());
+ WindowedValues.WindowedValueCoder.setMetadataNotSupported();
+ }
+
+ @Test
+ public void testWindowedValueWithValueKindCoder() throws CoderException {
+ WindowedValues.WindowedValueCoder.setMetadataSupported();
+ Instant timestamp = new Instant(1234);
+ WindowedValue<String> value =
+ WindowedValues.<String>builder()
+ .setValue("abc")
+ .setTimestamp(timestamp)
+ .setWindows(
+ Arrays.asList(new IntervalWindow(timestamp,
timestamp.plus(Duration.millis(1000)))))
+ .setPaneInfo(PaneInfo.NO_FIRING)
+ .setValueKind(ValueKind.UPDATE_BEFORE)
+ .build();
+
+ Coder<WindowedValue<String>> windowedValueCoder =
+ WindowedValues.getFullCoder(StringUtf8Coder.of(),
IntervalWindow.getCoder());
+
+ byte[] encodedValue = CoderUtils.encodeToByteArray(windowedValueCoder,
value);
+ WindowedValue<String> decodedValue =
+ CoderUtils.decodeFromByteArray(windowedValueCoder, encodedValue);
+
+ Assert.assertEquals(value.getValue(), decodedValue.getValue());
+ Assert.assertEquals(value.getTimestamp(), decodedValue.getTimestamp());
+ Assert.assertArrayEquals(value.getWindows().toArray(),
decodedValue.getWindows().toArray());
+ Assert.assertEquals(value.getValueKind(), decodedValue.getValueKind());
+ WindowedValues.WindowedValueCoder.setMetadataNotSupported();
Review Comment:
Done
--
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]