Search in sources :

Example 81 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestObservableListSync method addingMultipleElementsInBeginningFromDolphin_shouldAddElements.

@Test
public void addingMultipleElementsInBeginningFromDolphin_shouldAddElements() {
    // given :
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    new PresentationModelBuilder(serverModelStore, 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", "1", "2", "3")));
    assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ListReferenceModel(com.canoo.impl.server.util.ListReferenceModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 82 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestObservableListSync method addingMultipleElementInEmptyListAsUser_shouldAddElements.

// ////////////////////////////////////////////////////////////
// Adding elements at different positions as user
// ////////////////////////////////////////////////////////////
@Test
public void addingMultipleElementInEmptyListAsUser_shouldAddElements() {
    // given :
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    final String[] newElement = new String[] { "42", "4711", "Hello World" };
    // when :
    model.getPrimitiveList().addAll(0, Arrays.asList(newElement));
    // then :
    final List<ServerPresentationModel> changes = serverModelStore.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) 3)));
    assertThat(change.getAttribute("0").getValue(), is((Object) "42"));
    assertThat(change.getAttribute("1").getValue(), is((Object) "4711"));
    assertThat(change.getAttribute("2").getValue(), is((Object) "Hello World"));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ListReferenceModel(com.canoo.impl.server.util.ListReferenceModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 83 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestObservableListSync method deletingSingleElementInBeginningAsUser_shouldRemoveElement.

// ////////////////////////////////////////////////////////////
// Removing elements from different positions as user
// ////////////////////////////////////////////////////////////
@Test
public void deletingSingleElementInBeginningAsUser_shouldRemoveElement() {
    // given :
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getPrimitiveList().remove(0);
    // then :
    final List<ServerPresentationModel> changes = serverModelStore.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) 1)));
    assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ListReferenceModel(com.canoo.impl.server.util.ListReferenceModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 84 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestObservableListSync method addingMultipleElementInMiddleAsUser_shouldAddElements.

@Test
public void addingMultipleElementInMiddleAsUser_shouldAddElements() {
    // given :
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    final String[] newElement = new String[] { "42", "4711", "Hello World" };
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getPrimitiveList().addAll(1, Arrays.asList(newElement));
    // then :
    final List<ServerPresentationModel> changes = serverModelStore.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) 1)));
    assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 3)));
    assertThat(change.getAttribute("0").getValue(), is((Object) "42"));
    assertThat(change.getAttribute("1").getValue(), is((Object) "4711"));
    assertThat(change.getAttribute("2").getValue(), is((Object) "Hello World"));
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ListReferenceModel(com.canoo.impl.server.util.ListReferenceModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 85 with ServerModelStore

use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.

the class TestObservableListSync method deletingMultipleElementAtEndFromDolphin_shouldRemoveElements.

@Test
public void deletingMultipleElementAtEndFromDolphin_shouldRemoveElements() {
    // given :
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    final ListReferenceModel model = manager.create(ListReferenceModel.class);
    final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3", "4", "5", "6"));
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 4).withAttribute("to", 6).withAttribute("count", 0).create();
    // then :
    assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "2", "3", "4")));
    assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Also used : PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ListReferenceModel(com.canoo.impl.server.util.ListReferenceModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Aggregations

ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)103 Test (org.testng.annotations.Test)100 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)97 BeanManager (com.canoo.platform.remoting.BeanManager)91 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)88 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)66 ListReferenceModel (com.canoo.impl.server.util.ListReferenceModel)65 SimpleTestModel (com.canoo.impl.server.util.SimpleTestModel)18 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)14 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)14 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)8 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)7 ServerPresentationModelBuilder (com.canoo.dp.impl.server.model.ServerPresentationModelBuilder)5 SimpleAnnotatedTestModel (com.canoo.impl.server.util.SimpleAnnotatedTestModel)5 Command (com.canoo.dp.impl.remoting.legacy.communication.Command)4 ChildModel (com.canoo.impl.server.util.ChildModel)4 SingleReferenceModel (com.canoo.impl.server.util.SingleReferenceModel)4 ValueChangeEvent (com.canoo.platform.remoting.ValueChangeEvent)4 ValueChangeListener (com.canoo.platform.remoting.ValueChangeListener)4 Subscription (com.canoo.platform.core.functional.Subscription)3