Search in sources :

Example 1 with ServerPresentationModel

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

the class TestObservableListSync method addingObjectNullAsUser_shouldAddElement.

@Test
public void addingObjectNullAsUser_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);
    // when :
    model.getObjectList().add(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) "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(), 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 2 with ServerPresentationModel

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

the class TestObservableListSync method replacingSingleElementAtEndAsUser_shouldReplaceElement.

@Test
public void replacingSingleElementAtEndAsUser_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);
    final String newValue = "42";
    model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getPrimitiveList().set(2, newValue);
    // 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) 1)));
    assertThat(change.getAttribute("0").getValue(), allOf(instanceOf(String.class), is((Object) newValue)));
}
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 3 with ServerPresentationModel

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

the class TestObservableListSync method addingPrimitiveNullAsUser_shouldAddElement.

@Test
public void addingPrimitiveNullAsUser_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);
    // when :
    model.getPrimitiveList().add(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) 0)));
    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 4 with ServerPresentationModel

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

the class TestObservableListSync method replacePrimitiveElementAsUser_shouldReplaceElement.

@Test
public void replacePrimitiveElementAsUser_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);
    final String newValue = "Goodbye World";
    model.getPrimitiveList().add("Hello World");
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getPrimitiveList().set(0, newValue);
    // 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(), allOf(instanceOf(String.class), is((Object) newValue)));
}
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 5 with ServerPresentationModel

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

the class TestObservableListSync method deletingMultipleElementInBeginningAsUser_shouldRemoveElements.

// TODO: Enable once ObservableArrayList.sublist() was implemented completely
@Test(enabled = false)
public void deletingMultipleElementInBeginningAsUser_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 :
    model.getPrimitiveList().subList(0, 3).clear();
    // 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) 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)

Aggregations

ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)57 Test (org.testng.annotations.Test)56 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)55 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)55 BeanManager (com.canoo.platform.remoting.BeanManager)49 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)33 ListReferenceModel (com.canoo.impl.server.util.ListReferenceModel)33 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)12 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)12 SimpleTestModel (com.canoo.impl.server.util.SimpleTestModel)11 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)9 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)7 ServerPresentationModelBuilder (com.canoo.dp.impl.server.model.ServerPresentationModelBuilder)5 SimpleAnnotatedTestModel (com.canoo.impl.server.util.SimpleAnnotatedTestModel)4 ChildModel (com.canoo.impl.server.util.ChildModel)3 SingleReferenceModel (com.canoo.impl.server.util.SingleReferenceModel)3 PrimitiveDataTypesModel (com.canoo.impl.server.util.PrimitiveDataTypesModel)2 ChangeAttributeMetadataCommand (com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand)1 ServerPresentationModelBuilderFactory (com.canoo.dp.impl.server.model.ServerPresentationModelBuilderFactory)1 ComplexDataTypesModel (com.canoo.impl.server.util.ComplexDataTypesModel)1