Search in sources :

Example 26 with EventDispatcher

use of com.canoo.dp.impl.remoting.EventDispatcher 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)

Example 27 with EventDispatcher

use of com.canoo.dp.impl.remoting.EventDispatcher in project dolphin-platform by canoo.

the class TestModelCreation method testWithAnnotatedSimpleModel.

@Test
public void testWithAnnotatedSimpleModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
    final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
    final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
    SimpleAnnotatedTestModel model = manager.create(SimpleAnnotatedTestModel.class);
    assertThat(model, notNullValue());
    assertThat(model.getMyProperty(), notNullValue());
    assertThat(model.getMyProperty().get(), nullValue());
    assertThat(beanRepository.isManaged(model), is(true));
    List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(SimpleAnnotatedTestModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    ServerPresentationModel dolphinModel = dolphinModels.get(0);
    List<ServerAttribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("myProperty")), 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(SimpleAnnotatedTestModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("myProperty")), hasProperty("value", is(StringConverterFactory.FIELD_TYPE_STRING)), 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) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) SimpleAnnotatedTestModel(com.canoo.impl.server.util.SimpleAnnotatedTestModel) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) 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)

Example 28 with EventDispatcher

use of com.canoo.dp.impl.remoting.EventDispatcher 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 29 with EventDispatcher

use of com.canoo.dp.impl.remoting.EventDispatcher in project dolphin-platform by canoo.

the class TestModelCreation 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);
    assertThat(model, notNullValue());
    assertThat(model.getTextProperty(), notNullValue());
    assertThat(model.getTextProperty().get(), nullValue());
    assertThat(repository.isManaged(model), is(true));
    List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    PresentationModel dolphinModel = dolphinModels.get(0);
    List<Attribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("text")), 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(SimpleTestModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("text")), hasProperty("value", is(StringConverterFactory.FIELD_TYPE_STRING)), 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) 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 30 with EventDispatcher

use of com.canoo.dp.impl.remoting.EventDispatcher in project dolphin-platform by canoo.

the class TestModelDeletion method testWithNull.

@Test(expectedExceptions = NullPointerException.class)
public void testWithNull(@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);
    repository.delete(null);
}
Also used : EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) 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

EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)41 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)40 BeanManager (com.canoo.platform.remoting.BeanManager)39 Test (org.testng.annotations.Test)39 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)25 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)25 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)19 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)15 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)15 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)14 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)14 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)12 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)7 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)6 SimpleAnnotatedTestModel (com.canoo.dolphin.client.util.SimpleAnnotatedTestModel)5 ChildModel (com.canoo.dolphin.client.util.ChildModel)4 SingleReferenceModel (com.canoo.dolphin.client.util.SingleReferenceModel)4 ValueChangeEvent (com.canoo.platform.remoting.ValueChangeEvent)4 ValueChangeListener (com.canoo.platform.remoting.ValueChangeListener)4 SimpleAnnotatedTestModel (com.canoo.impl.server.util.SimpleAnnotatedTestModel)3