Search in sources :

Example 1 with ComplexDataTypesModel

use of com.canoo.dolphin.client.util.ComplexDataTypesModel in project dolphin-platform by canoo.

the class TestModelCreation method testWithComplexDataTypesModel.

@Test
public void testWithComplexDataTypesModel(@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);
    ComplexDataTypesModel model = manager.create(ComplexDataTypesModel.class);
    assertThat(model, notNullValue());
    assertThat(model.getDateProperty(), notNullValue());
    assertThat(model.getDateProperty().get(), nullValue());
    assertThat(model.getCalendarProperty(), notNullValue());
    assertThat(model.getCalendarProperty().get(), nullValue());
    assertThat(model.getEnumProperty(), notNullValue());
    assertThat(model.getEnumProperty().get(), nullValue());
    assertThat(repository.isManaged(model), is(true));
    List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(ComplexDataTypesModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    PresentationModel dolphinModel = dolphinModels.get(0);
    List<Attribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("dateProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("calendarProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("enumProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_CLIENT)), hasProperty("qualifier", nullValue()))));
    List<ClientPresentationModel> classModels = clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN);
    assertThat(classModels, contains(hasProperty("attributes", containsInAnyOrder(allOf(hasProperty("propertyName", is(PlatformRemotingConstants.JAVA_CLASS)), hasProperty("value", is(ComplexDataTypesModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("dateProperty")), hasProperty("value", is(DateConverterFactory.FIELD_TYPE_DATE)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("calendarProperty")), hasProperty("value", is(CalendarConverterFactory.FIELD_TYPE_CALENDAR)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("enumProperty")), hasProperty("value", is(EnumConverterFactory.FIELD_TYPE_ENUM)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_CLIENT)), hasProperty("qualifier", nullValue()))))));
}
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) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) 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 2 with ComplexDataTypesModel

use of com.canoo.dolphin.client.util.ComplexDataTypesModel 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)

Aggregations

AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)2 ComplexDataTypesModel (com.canoo.dolphin.client.util.ComplexDataTypesModel)2 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)2 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)2 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)2 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)2 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)2 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)2 BeanManager (com.canoo.platform.remoting.BeanManager)2 Test (org.testng.annotations.Test)2 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1