Search in sources :

Example 11 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.

the class TestPropertyValue method testWithInheritedModel.

@Test
public void testWithInheritedModel(@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);
    ChildModel model = manager.create(ChildModel.class);
    PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(ChildModel.class.getName()).get(0);
    Attribute childAttribute = dolphinModel.getAttribute("childProperty");
    assertThat(childAttribute.getValue(), nullValue());
    Attribute parentAttribute = dolphinModel.getAttribute("parentProperty");
    assertThat(parentAttribute.getValue(), nullValue());
    model.getChildProperty().set("Hallo Platform");
    assertThat(childAttribute.getValue(), is((Object) "Hallo Platform"));
    assertThat(model.getChildProperty().get(), is("Hallo Platform"));
    assertThat(parentAttribute.getValue(), nullValue());
    assertThat(model.getParentProperty().get(), nullValue());
    parentAttribute.setValue("Hallo Dolphin");
    assertThat(childAttribute.getValue(), is((Object) "Hallo Platform"));
    assertThat(model.getChildProperty().get(), is("Hallo Platform"));
    assertThat(parentAttribute.getValue(), is((Object) "Hallo Dolphin"));
    assertThat(model.getParentProperty().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) ChildModel(com.canoo.dolphin.client.util.ChildModel) 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 12 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.

the class TestPropertyValue method testWithAllPrimitiveDataTypesModel.

@Test
public void testWithAllPrimitiveDataTypesModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    PrimitiveDataTypesModel model = manager.create(PrimitiveDataTypesModel.class);
    ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(PrimitiveDataTypesModel.class.getName()).get(0);
    Attribute textAttribute = dolphinModel.getAttribute("textProperty");
    assertThat(textAttribute.getValue(), nullValue());
    model.getTextProperty().set("Hallo Platform");
    assertThat((String) textAttribute.getValue(), is("Hallo Platform"));
    assertThat(model.getTextProperty().get(), is("Hallo Platform"));
    textAttribute.setValue("Hallo Dolphin");
    assertThat((String) textAttribute.getValue(), is("Hallo Dolphin"));
    assertThat(model.getTextProperty().get(), is("Hallo Dolphin"));
    Attribute intAttribute = dolphinModel.getAttribute("integerProperty");
    assertThat(intAttribute.getValue(), nullValue());
    model.getIntegerProperty().set(1);
    assertThat((Integer) intAttribute.getValue(), is(1));
    assertThat(model.getIntegerProperty().get(), is(1));
    intAttribute.setValue(2);
    assertThat((Integer) intAttribute.getValue(), is(2));
    assertThat(model.getIntegerProperty().get(), is(2));
    Attribute booleanAttribute = dolphinModel.getAttribute("booleanProperty");
    assertThat(booleanAttribute.getValue(), nullValue());
    model.getBooleanProperty().set(true);
    assertThat((Boolean) booleanAttribute.getValue(), is(true));
    assertThat(model.getBooleanProperty().get(), is(true));
    model.getBooleanProperty().set(false);
    assertThat((Boolean) booleanAttribute.getValue(), is(false));
    assertThat(model.getBooleanProperty().get(), is(false));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) PrimitiveDataTypesModel(com.canoo.impl.server.util.PrimitiveDataTypesModel) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 13 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() {
    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)

Example 14 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() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    SimpleTestModel model = manager.create(SimpleTestModel.class);
    ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
    Attribute textAttribute = dolphinModel.getAttribute("text");
    assertThat(textAttribute.getValue(), nullValue());
    model.getTextProperty().set("Hallo Platform");
    assertThat((String) textAttribute.getValue(), is("Hallo Platform"));
    assertThat(model.getTextProperty().get(), is("Hallo Platform"));
    textAttribute.setValue("Hallo Dolphin");
    assertThat((String) textAttribute.getValue(), is("Hallo Dolphin"));
    assertThat(model.getTextProperty().get(), is("Hallo Dolphin"));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) SimpleTestModel(com.canoo.impl.server.util.SimpleTestModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 15 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.

the class TestModelCreation method testWithAllPrimitiveDatatypes.

@Test
public void testWithAllPrimitiveDatatypes() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
    final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
    final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
    PrimitiveDataTypesModel model = manager.create(PrimitiveDataTypesModel.class);
    assertThat(model, notNullValue());
    assertThat(model.getTextProperty(), notNullValue());
    assertThat(model.getTextProperty().get(), nullValue());
    assertThat(beanRepository.isManaged(model), is(true));
    List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(PrimitiveDataTypesModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    ServerPresentationModel dolphinModel = dolphinModels.get(0);
    List<ServerAttribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, hasSize(9));
    for (Attribute attribute : attributes) {
        if (RemotingConstants.SOURCE_SYSTEM.equals(attribute.getPropertyName())) {
            assertThat(attribute.getValue(), Matchers.<Object>is(RemotingConstants.SOURCE_SYSTEM_SERVER));
        } else {
            assertThat(attribute.getValue(), nullValue());
        }
        assertThat(attribute.getQualifier(), nullValue());
    }
    final List<ServerPresentationModel> classModels = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN);
    assertThat(classModels, hasSize(1));
    final PresentationModel classModel = classModels.get(0);
    final List<Attribute> classAttributes = classModel.getAttributes();
    assertThat(classAttributes, hasSize(10));
    for (Attribute attribute : classAttributes) {
        if (PlatformRemotingConstants.JAVA_CLASS.equals(attribute.getPropertyName())) {
            assertThat(attribute.getValue(), Matchers.<Object>is(PrimitiveDataTypesModel.class.getName()));
        } else if (RemotingConstants.SOURCE_SYSTEM.equals(attribute.getPropertyName())) {
            assertThat(attribute.getValue(), Matchers.<Object>is(RemotingConstants.SOURCE_SYSTEM_SERVER));
        } else {
            switch(attribute.getPropertyName()) {
                case "byteProperty":
                    assertThat(attribute.getValue(), Matchers.<Object>is(ByteConverterFactory.FIELD_TYPE_BYTE));
                    break;
                case "shortProperty":
                    assertThat(attribute.getValue(), Matchers.<Object>is(ShortConverterFactory.FIELD_TYPE_SHORT));
                    break;
                case "integerProperty":
                    assertThat(attribute.getValue(), Matchers.<Object>is(IntegerConverterFactory.FIELD_TYPE_INT));
                    break;
                case "longProperty":
                    assertThat(attribute.getValue(), Matchers.<Object>is(LongConverterFactory.FIELD_TYPE_LONG));
                    break;
                case "floatProperty":
                    assertThat(attribute.getValue(), Matchers.<Object>is(FloatConverterFactory.FIELD_TYPE_FLOAT));
                    break;
                case "doubleProperty":
                    assertThat(attribute.getValue(), Matchers.<Object>is(DoubleConverterFactory.FIELD_TYPE_DOUBLE));
                    break;
                case "booleanProperty":
                    assertThat(attribute.getValue(), Matchers.<Object>is(BooleanConverterFactory.FIELD_TYPE_BOOLEAN));
                    break;
                case "textProperty":
                    assertThat(attribute.getValue(), Matchers.<Object>is(StringConverterFactory.FIELD_TYPE_STRING));
                    break;
                default:
                    fail("Unknown attribute found: " + attribute);
                    break;
            }
        }
        assertThat(attribute.getQualifier(), 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) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) PrimitiveDataTypesModel(com.canoo.impl.server.util.PrimitiveDataTypesModel) BeanManager(com.canoo.platform.remoting.BeanManager) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.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