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));
}
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));
}
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"));
}
Aggregations