n-oden commented on a change in pull request #15858:
URL: https://github.com/apache/beam/pull/15858#discussion_r767981731



##########
File path: 
sdks/java/io/redis/src/test/java/org/apache/beam/sdk/io/redis/RedisIOTest.java
##########
@@ -250,6 +260,102 @@ public void testWriteUsingDECRBY() {
     assertEquals(-1, count);
   }
 
+  @Test
+  public void testWriteStreams() {
+    ArrayList<String> streams = new ArrayList<String>();
+    for (int i = 0; i <= 10; i++) {
+      UUID uuid = UUID.randomUUID();
+      /* stream keys are uuids to ensure that test runs are idempotent */
+      streams.add(uuid.toString());
+    }
+    Map<String, String> fooValues = ImmutableMap.of("sensor-id", "1234", 
"temperature", "19.8");
+    Map<String, String> barValues = ImmutableMap.of("sensor-id", "9999", 
"temperature", "18.2");
+
+    List<KV<String, Map<String, String>>> fooData =
+        streams.stream().map(key -> KV.of(key, 
fooValues)).collect(Collectors.toList());
+
+    List<KV<String, Map<String, String>>> barData =
+        streams.stream().map(key -> KV.of(key, 
barValues)).collect(Collectors.toList());
+
+    List<KV<String, Map<String, String>>> allData =
+        Stream.of(fooData, 
barData).flatMap(Collection::stream).collect(Collectors.toList());
+
+    PCollection<KV<String, Map<String, String>>> write =
+        p.apply(
+            Create.of(allData)
+                .withCoder(
+                    KvCoder.of(
+                        StringUtf8Coder.of(),
+                        MapCoder.of(StringUtf8Coder.of(), 
StringUtf8Coder.of()))));
+    write.apply(RedisIO.writeStreams().withEndpoint(REDIS_HOST, port));
+    p.run();
+
+    for (String stream : streams) {

Review comment:
       Woof, yes, that's much more concise, thank you.




-- 
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]


Reply via email to