Search in sources :

Example 16 with SimpleTestModel

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));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) SingleReferenceModel(com.canoo.dolphin.client.util.SingleReferenceModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) SimpleTestModel(com.canoo.dolphin.client.util.SimpleTestModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Example 17 with SimpleTestModel

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"));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) SimpleTestModel(com.canoo.dolphin.client.util.SimpleTestModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Aggregations

AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)17 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)17 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)17 BeanManager (com.canoo.platform.remoting.BeanManager)17 Test (org.testng.annotations.Test)17 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)14 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)12 ListReferenceModel (com.canoo.dolphin.client.util.ListReferenceModel)9 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)7 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)7 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)3 SingleReferenceModel (com.canoo.dolphin.client.util.SingleReferenceModel)2 Subscription (com.canoo.platform.core.functional.Subscription)2 ValueChangeEvent (com.canoo.platform.remoting.ValueChangeEvent)2 ValueChangeListener (com.canoo.platform.remoting.ValueChangeListener)2 SimpleAnnotatedTestModel (com.canoo.dolphin.client.util.SimpleAnnotatedTestModel)1