Search in sources :

Example 11 with PresentationModel

use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.

the class TestObservableListSync method deletingSingleElementAtEndAsUser_shouldDeleteElement.

@Test
public void deletingSingleElementAtEndAsUser_shouldDeleteElement() {
    // 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(2);
    // 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) 2)));
    assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 3)));
    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 12 with PresentationModel

use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.

the class TestObservableListSync method addingMultipleElementAtEndAsUser_shouldAddElements.

@Test
public void addingMultipleElementAtEndAsUser_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(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) 3)));
    assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 3)));
    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 13 with PresentationModel

use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.

the class TestObservableListSync method replacePrimitiveElementWithNullAsUser_shouldReplaceElement.

@Test
public void replacePrimitiveElementWithNullAsUser_shouldReplaceElement() {
    // 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().add("Hello World");
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getPrimitiveList().set(0, null);
    // 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) 1)));
    assertThat(change.getAttribute("0").getValue(), nullValue());
}
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 14 with PresentationModel

use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.

the class TestObservableListSync method addingSingleElementAtEndAsUser_shouldAddElement.

@Test
public void addingSingleElementAtEndAsUser_shouldAddElement() {
    // 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 = "42";
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getPrimitiveList().add(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) 3)));
    assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 3)));
    assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
    assertThat(change.getAttribute("0").getValue(), is((Object) newElement));
}
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 15 with PresentationModel

use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.

the class TestObservableListSync method addingMultipleElementsInEmptyListFromDolphin_shouldAddElements.

// ////////////////////////////////////////////////////////////
// Adding elements at different positions from dolphin
// ////////////////////////////////////////////////////////////
@Test
public void addingMultipleElementsInEmptyListFromDolphin_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);
    // 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")));
    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

PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)147 Test (org.testng.annotations.Test)143 BeanManager (com.canoo.platform.remoting.BeanManager)142 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)76 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)76 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)76 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)66 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)66 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)66 ListReferenceModel (com.canoo.dolphin.client.util.ListReferenceModel)64 ListReferenceModel (com.canoo.impl.server.util.ListReferenceModel)63 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)16 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)15 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)15 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)12 SimpleTestModel (com.canoo.impl.server.util.SimpleTestModel)10 ChildModel (com.canoo.dolphin.client.util.ChildModel)2 ComplexDataTypesModel (com.canoo.dolphin.client.util.ComplexDataTypesModel)2 PrimitiveDataTypesModel (com.canoo.dolphin.client.util.PrimitiveDataTypesModel)2 SimpleAnnotatedTestModel (com.canoo.dolphin.client.util.SimpleAnnotatedTestModel)2