use of com.canoo.dolphin.client.util.SimpleTestModel in project dolphin-platform by canoo.
the class TestPropertyValue method testWithSingleReferenceModel.
@Test
public void testWithSingleReferenceModel(@Mocked AbstractClientConnector connector) {
final ClientModelStore clientModelStore = createClientModelStore(connector);
final EventDispatcher dispatcher = createEventDispatcher(clientModelStore);
final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher);
final BeanManager manager = createBeanManager(clientModelStore, repository, dispatcher);
final SimpleTestModel ref1 = manager.create(SimpleTestModel.class);
ref1.getTextProperty().set("ref1_text");
final SimpleTestModel ref2 = manager.create(SimpleTestModel.class);
ref2.getTextProperty().set("ref2_text");
final List<ClientPresentationModel> refPMs = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
final PresentationModel ref1PM = "ref1_text".equals(refPMs.get(0).getAttribute("text").getValue()) ? refPMs.get(0) : refPMs.get(1);
final PresentationModel ref2PM = "ref2_text".equals(refPMs.get(0).getAttribute("text").getValue()) ? refPMs.get(0) : refPMs.get(1);
final SingleReferenceModel model = manager.create(SingleReferenceModel.class);
final PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName()).get(0);
final Attribute referenceAttribute = dolphinModel.getAttribute("referenceProperty");
assertThat(referenceAttribute.getValue(), nullValue());
model.getReferenceProperty().set(ref1);
assertThat(referenceAttribute.getValue(), is((Object) ref1PM.getId()));
assertThat(model.getReferenceProperty().get(), is(ref1));
referenceAttribute.setValue(ref2PM.getId());
assertThat(referenceAttribute.getValue(), is((Object) ref2PM.getId()));
assertThat(model.getReferenceProperty().get(), is(ref2));
}
use of com.canoo.dolphin.client.util.SimpleTestModel in project dolphin-platform by canoo.
the class TestPropertyValue method testWithSimpleModel.
@Test
public void testWithSimpleModel(@Mocked AbstractClientConnector connector) {
final ClientModelStore clientModelStore = createClientModelStore(connector);
final EventDispatcher dispatcher = createEventDispatcher(clientModelStore);
final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher);
final BeanManager manager = createBeanManager(clientModelStore, repository, dispatcher);
SimpleTestModel model = manager.create(SimpleTestModel.class);
PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
Attribute textAttribute = dolphinModel.getAttribute("text");
assertThat(textAttribute.getValue(), nullValue());
model.getTextProperty().set("Hallo Platform");
assertThat(textAttribute.getValue(), is((Object) "Hallo Platform"));
assertThat(model.getTextProperty().get(), is("Hallo Platform"));
textAttribute.setValue("Hallo Dolphin");
assertThat(textAttribute.getValue(), is((Object) "Hallo Dolphin"));
assertThat(model.getTextProperty().get(), is("Hallo Dolphin"));
}
Aggregations