Search in sources :

Example 21 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute 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 22 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute 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 23 with Attribute

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

Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)23 BeanManager (com.canoo.platform.remoting.BeanManager)21 Test (org.testng.annotations.Test)21 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)16 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)15 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)15 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)13 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)13 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)13 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)8 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)8 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)8 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)3 ChildModel (com.canoo.dolphin.client.util.ChildModel)2 ComplexDataTypesModel (com.canoo.dolphin.client.util.ComplexDataTypesModel)2 PrimitiveDataTypesModel (com.canoo.dolphin.client.util.PrimitiveDataTypesModel)2 SimpleAnnotatedTestModel (com.canoo.dolphin.client.util.SimpleAnnotatedTestModel)2 SingleReferenceModel (com.canoo.dolphin.client.util.SingleReferenceModel)2 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)2 ComplexDataTypesModel (com.canoo.impl.server.util.ComplexDataTypesModel)2