mxm commented on a change in pull request #12062:
URL: https://github.com/apache/beam/pull/12062#discussion_r445147652



##########
File path: 
runners/java-fn-execution/src/test/java/org/apache/beam/runners/fnexecution/state/StateRequestHandlersTest.java
##########
@@ -59,4 +68,46 @@ public void testDelegatingStateHandlerThrowsWhenNotFound() 
throws Exception {
     StateRequestHandlers.delegateBasedUponType(new 
EnumMap<>(StateKey.TypeCase.class))
         .handle(StateRequest.getDefaultInstance());
   }
+
+  @Test
+  public void testUserStateCacheTokenGeneration() {
+    ProcessBundleDescriptors.ExecutableProcessBundleDescriptor 
processBundleDescriptor =
+        
Mockito.mock(ProcessBundleDescriptors.ExecutableProcessBundleDescriptor.class);
+    InMemoryBagUserStateFactory inMemoryBagUserStateFactory = new 
InMemoryBagUserStateFactory<>();
+    StateRequestHandler stateRequestHandler =
+        StateRequestHandlers.forBagUserStateHandlerFactory(
+            processBundleDescriptor, inMemoryBagUserStateFactory);
+
+    Iterable<BeamFnApi.ProcessBundleRequest.CacheToken> cacheTokens =
+        stateRequestHandler.getCacheTokens();
+    assertThat(Iterables.size(cacheTokens), is(1));
+
+    BeamFnApi.ProcessBundleRequest.CacheToken cacheToken = 
Iterables.getOnlyElement(cacheTokens);
+    assertThat(
+        cacheToken.getUserState(),
+        
is(BeamFnApi.ProcessBundleRequest.CacheToken.UserState.getDefaultInstance()));
+    assertThat(cacheToken.getToken(), is(notNullValue()));
+
+    inMemoryBagUserStateFactory.forUserState(

Review comment:
       Looks like this should be using the StateRequestHandler instead, will 
update.




----------------------------------------------------------------
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:
[email protected]


Reply via email to