Search in sources :

Example 36 with BeanRepository

use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.

the class TestPropertyValue method testWithAllPrimitiveDataTypesModel.

@Test
public void testWithAllPrimitiveDataTypesModel(@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);
    PrimitiveDataTypesModel model = manager.create(PrimitiveDataTypesModel.class);
    PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(PrimitiveDataTypesModel.class.getName()).get(0);
    Attribute textAttribute = dolphinModel.getAttribute("textProperty");
    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"));
    Attribute intAttribute = dolphinModel.getAttribute("integerProperty");
    assertThat(intAttribute.getValue(), nullValue());
    model.getIntegerProperty().set(1);
    assertThat(intAttribute.getValue(), is((Object) 1));
    assertThat(model.getIntegerProperty().get(), is(1));
    intAttribute.setValue(2);
    assertThat(intAttribute.getValue(), is((Object) 2));
    assertThat(model.getIntegerProperty().get(), is(2));
    Attribute booleanAttribute = dolphinModel.getAttribute("booleanProperty");
    assertThat(booleanAttribute.getValue(), nullValue());
    model.getBooleanProperty().set(true);
    assertThat(booleanAttribute.getValue(), is((Object) true));
    assertThat(model.getBooleanProperty().get(), is(true));
    model.getBooleanProperty().set(false);
    assertThat(booleanAttribute.getValue(), is((Object) false));
    assertThat(model.getBooleanProperty().get(), is(false));
}
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) PrimitiveDataTypesModel(com.canoo.dolphin.client.util.PrimitiveDataTypesModel) 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 37 with BeanRepository

use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.

the class TestPropertyValue method testWithAnnotatedSimpleModel.

@Test
public void testWithAnnotatedSimpleModel(@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);
    SimpleAnnotatedTestModel model = manager.create(SimpleAnnotatedTestModel.class);
    PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(SimpleAnnotatedTestModel.class.getName()).get(0);
    Attribute textAttribute = dolphinModel.getAttribute("myProperty");
    assertThat(textAttribute.getValue(), nullValue());
    model.myProperty().set("Hallo Platform");
    assertThat(textAttribute.getValue(), is((Object) "Hallo Platform"));
    assertThat(model.myProperty().get(), is("Hallo Platform"));
    textAttribute.setValue("Hallo Dolphin");
    assertThat(textAttribute.getValue(), is((Object) "Hallo Dolphin"));
    assertThat(model.myProperty().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) SimpleAnnotatedTestModel(com.canoo.dolphin.client.util.SimpleAnnotatedTestModel) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) 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 38 with BeanRepository

use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.

the class TestPropertyValue method testWithComplexDataTypesModel.

@Test
public void testWithComplexDataTypesModel(@Mocked AbstractClientConnector connector) {
    final Calendar date1 = new GregorianCalendar(2016, Calendar.MARCH, 1, 0, 1, 2);
    date1.set(Calendar.MILLISECOND, 3);
    date1.setTimeZone(TimeZone.getTimeZone("GMT+2:00"));
    final Calendar date2 = new GregorianCalendar(2016, Calendar.FEBRUARY, 29, 0, 1, 2);
    date2.set(Calendar.MILLISECOND, 3);
    date2.setTimeZone(TimeZone.getTimeZone("UTC"));
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final EventDispatcher dispatcher = createEventDispatcher(clientModelStore);
    final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher);
    final BeanManager manager = createBeanManager(clientModelStore, repository, dispatcher);
    ComplexDataTypesModel model = manager.create(ComplexDataTypesModel.class);
    PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(ComplexDataTypesModel.class.getName()).get(0);
    Attribute dateAttribute = dolphinModel.getAttribute("dateProperty");
    assertThat(dateAttribute.getValue(), nullValue());
    model.getDateProperty().set(date1.getTime());
    assertThat(dateAttribute.getValue().toString(), is("2016-02-29T22:01:02.003Z"));
    assertThat(model.getDateProperty().get(), is(date1.getTime()));
    dateAttribute.setValue("2016-02-29T00:01:02.003Z");
    assertThat(dateAttribute.getValue().toString(), is("2016-02-29T00:01:02.003Z"));
    assertThat(model.getDateProperty().get(), is(date2.getTime()));
    Attribute calendarAttribute = dolphinModel.getAttribute("calendarProperty");
    assertThat(calendarAttribute.getValue(), nullValue());
    model.getCalendarProperty().set(date1);
    assertThat(calendarAttribute.getValue().toString(), is("2016-02-29T22:01:02.003Z"));
    assertThat(model.getCalendarProperty().get().getTimeInMillis(), is(date1.getTimeInMillis()));
    calendarAttribute.setValue("2016-02-29T00:01:02.003Z");
    assertThat(calendarAttribute.getValue().toString(), is("2016-02-29T00:01:02.003Z"));
    assertThat(model.getCalendarProperty().get(), is(date2));
    Attribute enumAttribute = dolphinModel.getAttribute("enumProperty");
    assertThat(enumAttribute.getValue(), nullValue());
    model.getEnumProperty().set(VALUE_1);
    assertThat(enumAttribute.getValue().toString(), is("VALUE_1"));
    assertThat(model.getEnumProperty().get(), is(VALUE_1));
    enumAttribute.setValue("VALUE_2");
    assertThat(enumAttribute.getValue().toString(), is("VALUE_2"));
    assertThat(model.getEnumProperty().get(), is(VALUE_2));
}
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) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) ComplexDataTypesModel(com.canoo.dolphin.client.util.ComplexDataTypesModel) 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 39 with BeanRepository

use of com.canoo.dp.impl.remoting.BeanRepository 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 40 with BeanRepository

use of com.canoo.dp.impl.remoting.BeanRepository 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

BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)40 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)40 BeanManager (com.canoo.platform.remoting.BeanManager)39 Test (org.testng.annotations.Test)39 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)25 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)25 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)19 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)15 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)15 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)14 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)14 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)12 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)7 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)6 SimpleAnnotatedTestModel (com.canoo.dolphin.client.util.SimpleAnnotatedTestModel)5 ChildModel (com.canoo.dolphin.client.util.ChildModel)4 SingleReferenceModel (com.canoo.dolphin.client.util.SingleReferenceModel)4 ValueChangeEvent (com.canoo.platform.remoting.ValueChangeEvent)4 ValueChangeListener (com.canoo.platform.remoting.ValueChangeListener)4 SimpleAnnotatedTestModel (com.canoo.impl.server.util.SimpleAnnotatedTestModel)3