Search in sources :

Example 1 with ComplexDataTypesModel

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

the class TestModelCreation method testWithComplexDataTypesModel.

@Test
public void testWithComplexDataTypesModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
    final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
    final BeanManager manager = createBeanManager(serverModelStore, beanRepository, 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(beanRepository.isManaged(model), is(true));
    List<ServerPresentationModel> dolphinModels = serverModelStore.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_SERVER)), hasProperty("qualifier", nullValue()))));
    List<ServerPresentationModel> classModels = serverModelStore.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_SERVER)), hasProperty("qualifier", nullValue()))))));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ComplexDataTypesModel(com.canoo.impl.server.util.ComplexDataTypesModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 2 with ComplexDataTypesModel

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

the class TestPropertyValue method testWithComplexDataTypesModel.

@Test
public void testWithComplexDataTypesModel() {
    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 ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    ComplexDataTypesModel model = manager.create(ComplexDataTypesModel.class);
    PresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(ComplexDataTypesModel.class.getName()).get(0);
    Attribute dateAttribute = dolphinModel.getAttribute("dateProperty");
    assertThat(dateAttribute.getValue(), nullValue());
    model.getDateProperty().set(date1.getTime());
    assertThat((String) dateAttribute.getValue(), is("2016-02-29T22:01:02.003Z"));
    assertThat(model.getDateProperty().get(), is(date1.getTime()));
    dateAttribute.setValue("2016-02-29T00:01:02.003Z");
    assertThat((String) dateAttribute.getValue(), 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((String) calendarAttribute.getValue(), is("2016-02-29T22:01:02.003Z"));
    assertThat(model.getCalendarProperty().get().getTimeInMillis(), is(date1.getTimeInMillis()));
    calendarAttribute.setValue("2016-02-29T00:01:02.003Z");
    assertThat((String) calendarAttribute.getValue(), 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((String) enumAttribute.getValue(), is("VALUE_1"));
    assertThat(model.getEnumProperty().get(), is(VALUE_1));
    enumAttribute.setValue("VALUE_2");
    assertThat((String) enumAttribute.getValue(), is("VALUE_2"));
    assertThat(model.getEnumProperty().get(), is(VALUE_2));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ComplexDataTypesModel(com.canoo.impl.server.util.ComplexDataTypesModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Aggregations

Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)2 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)2 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)2 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)2 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)2 ComplexDataTypesModel (com.canoo.impl.server.util.ComplexDataTypesModel)2 BeanManager (com.canoo.platform.remoting.BeanManager)2 Test (org.testng.annotations.Test)2 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)1 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)1 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1