[ 
https://issues.apache.org/jira/browse/BEAM-8374?focusedWorklogId=401709&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-401709
 ]

ASF GitHub Bot logged work on BEAM-8374:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Mar/20 19:23
            Start Date: 11/Mar/20 19:23
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on pull request #9758: [BEAM-8374] 
Enable returning missing PublishResult fields in SnsIO.Write
URL: https://github.com/apache/beam/pull/9758#discussion_r391207323
 
 

 ##########
 File path: 
sdks/java/io/amazon-web-services/src/test/java/org/apache/beam/sdk/io/aws/sns/SnsIOTest.java
 ##########
 @@ -131,6 +139,52 @@ public void testRetries() throws Throwable {
     fail("Pipeline is expected to fail because we were unable to write to 
SNS.");
   }
 
+  @Test
+  public void testCustomCoder() throws Exception {
+    final PublishRequest request1 = createSampleMessage("my_first_message");
+
+    final TupleTag<PublishResult> results = new TupleTag<>();
+    final AmazonSNS amazonSnsSuccess = getAmazonSnsMockSuccess();
+    final MockCoder mockCoder = new MockCoder();
+
+    final PCollectionTuple snsWrites =
+        p.apply(Create.of(request1))
+            .apply(
+                SnsIO.write()
+                    .withTopicName(topicName)
+                    .withAWSClientsProvider(new Provider(amazonSnsSuccess))
+                    .withResultOutputTag(results)
+                    .withCoder(mockCoder));
+
+    final PCollection<Long> publishedResultsSize =
+        snsWrites
+            .get(results)
+            .apply(MapElements.into(TypeDescriptors.strings()).via(result -> 
result.getMessageId()))
+            .apply(Count.globally());
+    
PAssert.that(publishedResultsSize).containsInAnyOrder(ImmutableList.of(1L));
+    p.run().waitUntilFinish();
+    assertThat(mockCoder.captured).isNotNull();
+  }
+
+  // Hand-code mock because Mockito mocks cause NotSerializableException even 
with
+  // withSettings().serializable().
+  private static class MockCoder extends AtomicCoder<PublishResult> implements 
Serializable {
 
 Review comment:
   All Coders implement Serializable already.
   ```suggestion
     private static class MockCoder extends AtomicCoder<PublishResult> {
   ```
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 401709)
    Time Spent: 8h 10m  (was: 8h)

> PublishResult returned by SnsIO is missing sdkResponseMetadata and 
> sdkHttpMetadata
> ----------------------------------------------------------------------------------
>
>                 Key: BEAM-8374
>                 URL: https://issues.apache.org/jira/browse/BEAM-8374
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-aws
>    Affects Versions: 2.13.0, 2.14.0, 2.15.0
>            Reporter: Jonothan Farr
>            Assignee: Jonothan Farr
>            Priority: Minor
>          Time Spent: 8h 10m
>  Remaining Estimate: 0h
>
> Currently the PublishResultCoder in SnsIO only serializes the messageId field 
> so the PublishResult returned by Beam returns null for 
> getSdkResponseMetadata() and getSdkHttpMetadata(). This makes it impossible 
> to check the HTTP status for errors, which is necessary since this is not 
> handled in SnsIO.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to