Search in sources :

Example 6 with ClientPresentationModel

use of com.canoo.dp.impl.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.

the class TestModelCreation method testWithListReferenceModel.

@Test
public void testWithListReferenceModel(@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);
    ListReferenceModel model = manager.create(ListReferenceModel.class);
    assertThat(model, notNullValue());
    assertThat(model.getObjectList(), empty());
    assertThat(model.getPrimitiveList(), empty());
    List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    PresentationModel dolphinModel = dolphinModels.get(0);
    List<Attribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, contains(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(ListReferenceModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("objectList")), hasProperty("value", is(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("primitiveList")), 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) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) ListReferenceModel(com.canoo.dolphin.client.util.ListReferenceModel) 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 7 with ClientPresentationModel

use of com.canoo.dp.impl.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.

the class TestModelCreation 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);
    assertThat(model, notNullValue());
    assertThat(model.getParentProperty(), notNullValue());
    assertThat(model.getParentProperty().get(), nullValue());
    assertThat(model.getChildProperty(), notNullValue());
    assertThat(model.getChildProperty().get(), nullValue());
    assertThat(repository.isManaged(model), is(true));
    List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(ChildModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    PresentationModel dolphinModel = dolphinModels.get(0);
    List<Attribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("childProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("parentProperty")), 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, hasSize(1));
    assertThat(classModels, contains(hasProperty("attributes", containsInAnyOrder(allOf(hasProperty("propertyName", is(PlatformRemotingConstants.JAVA_CLASS)), hasProperty("value", is(ChildModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("childProperty")), hasProperty("value", is(StringConverterFactory.FIELD_TYPE_STRING)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("parentProperty")), 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) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) 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 8 with ClientPresentationModel

use of com.canoo.dp.impl.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.

the class TestModelDeletion 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);
    repository.delete(model);
    List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(ChildModel.class.getName());
    assertThat(dolphinModels, empty());
    Collection<ClientPresentationModel> allDolphinModels = clientModelStore.listPresentationModels();
    assertThat(allDolphinModels, hasSize(1));
    assertThat(repository.isManaged(model), is(false));
}
Also used : EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) 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 9 with ClientPresentationModel

use of com.canoo.dp.impl.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.

the class TestModelDeletion 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);
    SingleReferenceModel model = manager.create(SingleReferenceModel.class);
    repository.delete(model);
    List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName());
    assertThat(dolphinModels, empty());
    Collection<ClientPresentationModel> allDolphinModels = clientModelStore.listPresentationModels();
    assertThat(allDolphinModels, hasSize(1));
    assertThat(repository.isManaged(model), is(false));
}
Also used : SingleReferenceModel(com.canoo.dolphin.client.util.SingleReferenceModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) 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 10 with ClientPresentationModel

use of com.canoo.dp.impl.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.

the class TestModelDeletion 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);
    repository.delete(model);
    List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
    assertThat(dolphinModels, empty());
    Collection<ClientPresentationModel> allDolphinModels = clientModelStore.listPresentationModels();
    assertThat(allDolphinModels, hasSize(1));
    assertThat(repository.isManaged(model), is(false));
}
Also used : EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) 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)

Aggregations

ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)50 Test (org.testng.annotations.Test)48 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)45 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)45 BeanManager (com.canoo.platform.remoting.BeanManager)45 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)39 ListReferenceModel (com.canoo.dolphin.client.util.ListReferenceModel)33 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)14 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)14 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)10 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)8 SimpleAnnotatedTestModel (com.canoo.dolphin.client.util.SimpleAnnotatedTestModel)3 SingleReferenceModel (com.canoo.dolphin.client.util.SingleReferenceModel)3 ChildModel (com.canoo.dolphin.client.util.ChildModel)2 ComplexDataTypesModel (com.canoo.dolphin.client.util.ComplexDataTypesModel)1 PrimitiveDataTypesModel (com.canoo.dolphin.client.util.PrimitiveDataTypesModel)1 ClientAttribute (com.canoo.dp.impl.client.legacy.ClientAttribute)1 InterruptLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand)1 StartLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand)1 AttributeMetadataChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand)1