@Test public void dataModelCanRegisterActionsAndObservableValues() throws Exception { ServiceContext context = new ServiceContext(); { final IntValueProperty count = new IntValueProperty(); Runnable incCount = new Runnable() { @Override public void run() { count.increment(); } }; final StringValueProperty title = new StringValueProperty("Title"); final BoolValueProperty enabled = new BoolValueProperty(true); Runnable toggleEnabled = new Runnable() { @Override public void run() { enabled.invert(); } }; context.putValue("count", count); context.putValue("title", title); context.putValue("enabled", enabled); context.putAction("incCount", incCount); context.putAction("toggleEnabled", toggleEnabled); } IntValueProperty count = (IntValueProperty) context.getValue("count"); StringValueProperty title = (StringValueProperty) context.getValue("title"); BoolValueProperty enabled = (BoolValueProperty) context.getValue("enabled"); assertThat(title.get()).isEqualTo("Title"); assertThat(count.get()).isEqualTo(0); context.getAction("incCount").run(); assertThat(count.get()).isEqualTo(1); assertThat(enabled.get()).isTrue(); context.getAction("toggleEnabled").run(); assertThat(enabled.get()).isFalse(); }