@SuppressWarnings("unchecked") @Test public void testCreateUiUpdater() { when(propertyDispatcher.pull(any(Aspect.class))).thenReturn(true); Handler handler = aspectDefinition.createUiUpdater(propertyDispatcher, componentWrapper); assertThat(componentWrapper.getComponent().isEnabled(), is(false)); handler.apply(); verify(propertyDispatcher, times(1)).pull(any(Aspect.class)); assertThat(componentWrapper.getComponent().isEnabled(), is(true)); handler.apply(); verify(propertyDispatcher, times(2)).pull(any(Aspect.class)); }
@Override public Handler createUiUpdater(PropertyDispatcher propertyDispatcher, ComponentWrapper componentWrapper) { Consumer<V> setter = createComponentValueSetter(componentWrapper); Aspect<V> aspect = createAspect(); return () -> { try { setter.accept(propertyDispatcher.pull(aspect)); } catch (RuntimeException e) { handleUiUpdateException(e, propertyDispatcher, aspect); } }; }
ModelToUiAspectDefinition implements LinkkiAspectDefinition { @Override public Handler createUiUpdater(PropertyDispatcher propertyDispatcher, ComponentWrapper componentWrapper) { Consumer<V> setter = createComponentValueSetter(componentWrapper); Aspect<V> aspect = createAspect(); return () -> { try { setter.accept(propertyDispatcher.pull(aspect)); } catch (RuntimeException e) { handleUiUpdateException(e, propertyDispatcher, aspect); } }; } }
ModelToUiAspectDefinition implements LinkkiAspectDefinition { @Override public Handler createUiUpdater(PropertyDispatcher propertyDispatcher, ComponentWrapper componentWrapper) { Consumer<V> setter = createComponentValueSetter(componentWrapper); Aspect<V> aspect = createAspect(); return () -> { try { setter.accept(propertyDispatcher.pull(aspect)); } catch (RuntimeException e) { handleUiUpdateException(e, propertyDispatcher, aspect); } }; }  }
ModelToUiAspectDefinition implements LinkkiAspectDefinition { @Override public Handler createUiUpdater(PropertyDispatcher propertyDispatcher, ComponentWrapper componentWrapper) { Consumer<V> setter = createComponentValueSetter(componentWrapper); Aspect<V> aspect = createAspect(); return () -> { try { setter.accept(propertyDispatcher.pull(aspect)); } catch (RuntimeException e) { handleUiUpdateException(e, propertyDispatcher, aspect); } }; }  @Override Handler createUiUpdater(PropertyDispatcher propertyDispatcher, ComponentWrapper componentWrapper); abstract Aspect<V> createAspect(); abstract Consumer<V> createComponentValueSetter(ComponentWrapper componentWrapper); }
ModelToUiAspectDefinition implements LinkkiAspectDefinition { @Override public Handler createUiUpdater(PropertyDispatcher propertyDispatcher, ComponentWrapper componentWrapper) { Consumer<V> setter = createComponentValueSetter(componentWrapper); Aspect<V> aspect = createAspect(); return () -> { try { setter.accept(propertyDispatcher.pull(aspect)); } catch (RuntimeException e) { handleUiUpdateException(e, propertyDispatcher, aspect); } }; }  @Override Handler createUiUpdater(PropertyDispatcher propertyDispatcher, ComponentWrapper componentWrapper); abstract Aspect<V> createAspect(); abstract Consumer<V> createComponentValueSetter(ComponentWrapper componentWrapper);  }