acrites commented on code in PR #36218:
URL: https://github.com/apache/beam/pull/36218#discussion_r2383617111
##########
sdks/java/harness/src/test/java/org/apache/beam/fn/harness/state/MultimapUserStateTest.java:
##########
@@ -179,6 +184,66 @@ public void testKeys() throws Exception {
assertThrows(IllegalStateException.class, () -> userState.keys());
}
+ @Test
+ public void testEntries() throws Exception {
+ FakeBeamFnStateClient fakeClient =
+ new FakeBeamFnStateClient(
+ ImmutableMap.of(
+ createMultimapEntriesStateKey(),
+ KV.of(
+ KvCoder.of(ByteArrayCoder.of(),
IterableCoder.of(StringUtf8Coder.of())),
+ asList(KV.of(A1, asList("V1", "V2")), KV.of(A2,
asList("V3"))))));
+ MultimapUserState<byte[], String> userState =
+ new MultimapUserState<>(
+ Caches.noop(),
+ fakeClient,
+ "instructionId",
+ createMultimapKeyStateKey(),
+ ByteArrayCoder.of(),
+ StringUtf8Coder.of());
+
+ assertArrayEquals(A1, userState.entries().iterator().next().getKey());
+ assertThat(
+ StreamSupport.stream(userState.entries().spliterator(), false)
+ .map(entry -> KV.of(ByteString.copyFrom(entry.getKey()),
entry.getValue()))
+ .collect(Collectors.toList()),
+ containsInAnyOrder(
+ KV.of(ByteString.copyFrom(A1), "V1"),
+ KV.of(ByteString.copyFrom(A1), "V2"),
+ KV.of(ByteString.copyFrom(A2), "V3")));
+
+ userState.put(A1, "V4");
+ assertThat(
Review Comment:
Good idea.
--
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]