Search in sources :

Example 6 with ListReferenceModel

use of com.canoo.dolphin.client.util.ListReferenceModel in project dolphin-platform by canoo.

the class TestObservableListSync method deletingMultipleElementInMiddleAsUser_shouldDeleteElements.

// TODO: Enable once ObservableArrayList.sublist() was implemented completely
@Test(enabled = false)
public void deletingMultipleElementInMiddleAsUser_shouldDeleteElements(@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);
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3", "4", "5", "6"));
    deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getPrimitiveList().subList(1, 4).clear();
    // then :
    final List<ClientPresentationModel> changes = clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE);
    assertThat(changes, hasSize(1));
    final PresentationModel change = changes.get(0);
    assertThat(change.getAttribute("source").getValue(), allOf(instanceOf(String.class), is((Object) sourceModel.getId())));
    assertThat(change.getAttribute("attribute").getValue(), allOf(instanceOf(String.class), is((Object) "primitiveList")));
    assertThat(change.getAttribute("from").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
    assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 4)));
    assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) 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 ListReferenceModel

use of com.canoo.dolphin.client.util.ListReferenceModel in project dolphin-platform by canoo.

the class TestObservableListSync method deletingMultipleElementInMiddleFromDolphin_shouldRemoveElements.

@Test
public void deletingMultipleElementInMiddleFromDolphin_shouldRemoveElements(@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);
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3", "4", "5", "6"));
    deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 2).withAttribute("to", 4).withAttribute("count", 0).create();
    // then :
    assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "2", "5", "6")));
    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)

Example 8 with ListReferenceModel

use of com.canoo.dolphin.client.util.ListReferenceModel in project dolphin-platform by canoo.

the class TestObservableListSync method addingObjectElementAsUser_shouldAddElement.

// ////////////////////////////////////////////////////////////
// Adding, removing, and replacing all element types as user
// ////////////////////////////////////////////////////////////
@Test
public void addingObjectElementAsUser_shouldAddElement(@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 SimpleTestModel object = manager.create(SimpleTestModel.class);
    final PresentationModel objectModel = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
    // when :
    model.getObjectList().add(object);
    // then :
    final List<ClientPresentationModel> changes = clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE);
    assertThat(changes, hasSize(1));
    final PresentationModel change = changes.get(0);
    assertThat(change.getAttribute("source").getValue(), allOf(instanceOf(String.class), is((Object) sourceModel.getId())));
    assertThat(change.getAttribute("attribute").getValue(), allOf(instanceOf(String.class), is((Object) "objectList")));
    assertThat(change.getAttribute("from").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
    assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
    assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
    assertThat(change.getAttribute("0").getValue(), allOf(instanceOf(String.class), is((Object) objectModel.getId())));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) SimpleTestModel(com.canoo.dolphin.client.util.SimpleTestModel) 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 9 with ListReferenceModel

use of com.canoo.dolphin.client.util.ListReferenceModel in project dolphin-platform by canoo.

the class TestObservableListSync method addingMultipleElementsInEmptyListFromDolphin_shouldAddElements.

// ////////////////////////////////////////////////////////////
// Adding elements at different positions from dolphin
// ////////////////////////////////////////////////////////////
@Test
public void addingMultipleElementsInEmptyListFromDolphin_shouldAddElements(@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);
    // when :
    new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 3).withAttribute("0", "42").withAttribute("1", "4711").withAttribute("2", "Hello World").create();
    // then :
    assertThat(model.getPrimitiveList(), is(Arrays.asList("42", "4711", "Hello World")));
    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)

Example 10 with ListReferenceModel

use of com.canoo.dolphin.client.util.ListReferenceModel in project dolphin-platform by canoo.

the class TestObservableListSync method addingPrimitiveElementAsUser_shouldAddElement.

@Test
public void addingPrimitiveElementAsUser_shouldAddElement(@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 value = "Hello";
    // when :
    model.getPrimitiveList().add(value);
    // then :
    final List<ClientPresentationModel> changes = clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE);
    assertThat(changes, hasSize(1));
    final PresentationModel change = changes.get(0);
    assertThat(change.getAttribute("source").getValue(), allOf(instanceOf(String.class), is((Object) sourceModel.getId())));
    assertThat(change.getAttribute("attribute").getValue(), allOf(instanceOf(String.class), is((Object) "primitiveList")));
    assertThat(change.getAttribute("from").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
    assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
    assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
    assertThat(change.getAttribute("0").getValue(), allOf(instanceOf(String.class), is((Object) value)));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) 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

AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)65 ListReferenceModel (com.canoo.dolphin.client.util.ListReferenceModel)65 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)65 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)65 BeanManager (com.canoo.platform.remoting.BeanManager)65 Test (org.testng.annotations.Test)65 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)64 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)9 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)2 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)2 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)1