### Question:
StateBootstrapper { void apply(TaggedBootstrapData bootstrapData) { final Address target = bootstrapData.getTarget(); stateAccessor.setCurrentKey(target); stateBootstrapFunctionContext.setCurrentAddress(target); final StateBootstrapFunction bootstrapFunction = bootstrapFunctionRegistry.getBootstrapFunction(target.type()); if (bootstrapFunction == null) { throw new IllegalArgumentException( "A bootstrap input was targeted for function of type " + target.type() + ", but there was no StateBootstrapFunctionProvider registered for the type."); } bootstrapFunction.bootstrap(stateBootstrapFunctionContext, bootstrapData.getPayload()); } StateBootstrapper(StateBootstrapFunctionRegistry bootstrapFunctionRegistry, State stateAccessor);   }### Answer:
@Test public void bootstrapState() { final TestState testState = new TestState(); final StateBootstrapper stateBootstrapper = createBootstrapper( testState, Tuple2.of(IntegerStateBootstrapFunction.TYPE, new IntegerStateBootstrapFunction()), Tuple2.of(FloatStateBootstrapFunction.TYPE, new FloatStateBootstrapFunction())); stateBootstrapper.apply(taggedBootstrapData(IntegerStateBootstrapFunction.TYPE, "foo", 1991)); stateBootstrapper.apply(taggedBootstrapData(FloatStateBootstrapFunction.TYPE, "foo", 3.1415F)); stateBootstrapper.apply(taggedBootstrapData(IntegerStateBootstrapFunction.TYPE, "bar", 1108)); assertThat( testState.getState( IntegerStateBootstrapFunction.TYPE, IntegerStateBootstrapFunction.STATE_NAME, "foo"), is(1991)); assertThat( testState.getState( IntegerStateBootstrapFunction.TYPE, IntegerStateBootstrapFunction.STATE_NAME, "bar"), is(1108)); assertThat( testState.getState( FloatStateBootstrapFunction.TYPE, FloatStateBootstrapFunction.STATE_NAME, "foo"), is(3.1415F)); }
@Test public void bootstrapsWithCorrectContext() { final Address expectedSelfAddress = new Address(ContextVerifyingStateBootstrapFunction.TYPE, "test-id"); final StateBootstrapper stateBootstrapper = createBootstrapper( new TestState(), Tuple2.of( ContextVerifyingStateBootstrapFunction.TYPE, new ContextVerifyingStateBootstrapFunction(expectedSelfAddress))); stateBootstrapper.apply( taggedBootstrapData(ContextVerifyingStateBootstrapFunction.TYPE, "test-id", "foobar")); }