Search in sources :

Example 56 with BeanManager

use of com.canoo.platform.remoting.BeanManager 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 57 with BeanManager

use of com.canoo.platform.remoting.BeanManager 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 58 with BeanManager

use of com.canoo.platform.remoting.BeanManager 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 59 with BeanManager

use of com.canoo.platform.remoting.BeanManager 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)

Example 60 with BeanManager

use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.

the class TestObservableListSync method replacingSingleElementAtEndFromDolphin_shouldReplaceElement.

@Test
public void replacingSingleElementAtEndFromDolphin_shouldReplaceElement(@Mocked AbstractClientConnector connector) {
    // given :
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final BeanManager manager = createBeanManager(clientModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    final String newValue = "42";
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
    deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 2).withAttribute("to", 3).withAttribute("count", 1).withAttribute("0", newValue).create();
    // then :
    assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "2", "42")));
    assertThat(clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) 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)

Aggregations

BeanManager (com.canoo.platform.remoting.BeanManager)182 Test (org.testng.annotations.Test)182 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)142 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)91 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)91 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)91 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)91 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)82 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)82 ListReferenceModel (com.canoo.dolphin.client.util.ListReferenceModel)65 ListReferenceModel (com.canoo.impl.server.util.ListReferenceModel)65 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)39 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)39 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)21 SimpleTestModel (com.canoo.impl.server.util.SimpleTestModel)18 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)17 ValueChangeEvent (com.canoo.platform.remoting.ValueChangeEvent)8 ValueChangeListener (com.canoo.platform.remoting.ValueChangeListener)8 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)7 Subscription (com.canoo.platform.core.functional.Subscription)6