StateBinder { public BoundState bind(FunctionType functionType, @Nullable Object instance) { List<PersistedValue<Object>> values = PersistedValues.findReflectively(instance); for (PersistedValue<Object> persistedValue : values) { Accessor<Object> accessor = state.createFlinkStateAccessor(functionType, persistedValue); ApiExtension.setPersistedValueAccessor(persistedValue, accessor); } return new BoundState(values); } @Inject  StateBinder(@Label("state") State state); BoundState bind(FunctionType functionType, @Nullable Object instance);  }
@Test public void nonAnnotatedClass() { binderUnderTest.bind(TestUtils.FUNCTION_TYPE, new IgnoreNonAnnotated()); assertTrue(state.boundNames.isEmpty()); }
@Test public void extendedClass() { binderUnderTest.bind(TestUtils.FUNCTION_TYPE, new ChildClass()); assertThat(state.boundNames, hasItems("parent", "child")); }
@Test(expected = IllegalArgumentException.class) public void staticPersistedFieldsAreNotAllowed() { binderUnderTest.bind(TestUtils.FUNCTION_TYPE, new StaticPersistedValue()); }
@Test public void exampleUsage() { binderUnderTest.bind(TestUtils.FUNCTION_TYPE, new SanityClass()); assertThat(state.boundNames, hasItems("name", "last")); }
@Test(expected = IllegalArgumentException.class) public void nonPersistedFieldAnnotated() { binderUnderTest.bind(TestUtils.FUNCTION_TYPE, new WrongAnnotationClass()); }
@Test(expected = IllegalStateException.class) public void nullValueField() { binderUnderTest.bind(TestUtils.FUNCTION_TYPE, new NullValueClass()); }