StateRequestHandlers { public static StateRequestHandler delegateBasedUponType( EnumMap<StateKey.TypeCase, StateRequestHandler> handlers) { return new StateKeyTypeDelegatingStateRequestHandler(handlers); }  static StateRequestHandler delegateBasedUponType(
      EnumMap<StateKey.TypeCase, StateRequestHandler> handlers); static StateRequestHandler forSideInputHandlerFactory(
      Map<String, Map<String, SideInputSpec>> sideInputSpecs,
      SideInputHandlerFactory sideInputHandlerFactory); static StateRequestHandler forBagUserStateHandlerFactory(
      ExecutableProcessBundleDescriptor processBundleDescriptor,
      BagUserStateHandlerFactory bagUserStateHandlerFactory);  }
@Test public void testDelegatingStateHandlerDelegates() throws Exception { StateRequestHandler mockHandler = Mockito.mock(StateRequestHandler.class); StateRequestHandler mockHandler2 = Mockito.mock(StateRequestHandler.class); EnumMap<StateKey.TypeCase, StateRequestHandler> handlers = new EnumMap<>(StateKey.TypeCase.class); handlers.put(StateKey.TypeCase.TYPE_NOT_SET, mockHandler); handlers.put(TypeCase.MULTIMAP_SIDE_INPUT, mockHandler2); StateRequest request = StateRequest.getDefaultInstance(); StateRequest request2 = StateRequest.newBuilder() .setStateKey( StateKey.newBuilder().setMultimapSideInput(MultimapSideInput.getDefaultInstance())) .build(); StateRequestHandlers.delegateBasedUponType(handlers).handle(request); StateRequestHandlers.delegateBasedUponType(handlers).handle(request2); verify(mockHandler).handle(request); verify(mockHandler2).handle(request2); verifyNoMoreInteractions(mockHandler, mockHandler2); }
@Test public void testDelegatingStateHandlerThrowsWhenNotFound() throws Exception { StateRequestHandlers.delegateBasedUponType(new EnumMap<>(StateKey.TypeCase.class)) .handle(StateRequest.getDefaultInstance()); }