llamallamaduck commented on code in PR #31206:
URL: https://github.com/apache/beam/pull/31206#discussion_r1603292736
##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubIOTest.java:
##########
@@ -780,6 +780,50 @@ public void testReadMessagesWithCoderAndParseFn() {
pipeline.run();
}
+ static class AppendSuffixAttributeToStringPayloadParseFn
+ extends SimpleFunction<PubsubMessage, String> {
+ @Override
+ public String apply(PubsubMessage input) {
+ String payload = new String(input.getPayload(), StandardCharsets.UTF_8);
+ String suffixAttribute = input.getAttributeMap().get("suffix");
+ return payload + suffixAttribute;
+ }
+ }
+
+ private IncomingMessage messageWithSuffixAttribute(String payload, String
suffix) {
+ return IncomingMessage.of(
+ com.google.pubsub.v1.PubsubMessage.newBuilder()
+ .setData(ByteString.copyFromUtf8(payload))
+ .putAttributes("suffix", suffix)
+ .build(),
+ 1234L,
+ 0,
+ UUID.randomUUID().toString(),
+ UUID.randomUUID().toString());
+ }
+
+ @Test
+ public void testReadMessagesWithAttributesWithCoderAndParseFn() {
+ ImmutableList<IncomingMessage> inputs =
+ ImmutableList.of(
+ messageWithSuffixAttribute("foo", "-some-suffix"),
+ messageWithSuffixAttribute("bar", "-some-suffix"));
Review Comment:
Yes, addressed now 👍
--
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]