Search in sources :

Example 91 with ServerModelStore

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

the class TestObservableListSync method replacingObjectElementWithNullFromDolphin_shouldReplaceElement.

@Test
public void replacingObjectElementWithNullFromDolphin_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 PresentationModel classDescription = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN).get(0);
    classDescription.getAttribute("objectList").setValue(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN);
    final SimpleTestModel oldObject = manager.create(SimpleTestModel.class);
    final PresentationModel oldObjectModel = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
    new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", oldObjectModel.getId()).create();
    assertThat(model.getObjectList(), is(Collections.singletonList(oldObject)));
    // when :
    new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 1).withAttribute("count", 1).withAttribute("0", null).create();
    // then :
    assertThat(model.getObjectList(), is(Collections.<SimpleTestModel>singletonList(null)));
    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) SimpleTestModel(com.canoo.impl.server.util.SimpleTestModel) 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 92 with ServerModelStore

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

the class TestObservableListSync method replacingObjectNullWithElementFromDolphin_shouldReplaceElement.

@Test
public void replacingObjectNullWithElementFromDolphin_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 PresentationModel classDescription = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN).get(0);
    classDescription.getAttribute("objectList").setValue(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN);
    final SimpleTestModel newObject = manager.create(SimpleTestModel.class);
    final PresentationModel newObjectModel = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
    new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", null).create();
    assertThat(model.getObjectList(), is(Collections.<SimpleTestModel>singletonList(null)));
    // when :
    new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 1).withAttribute("count", 1).withAttribute("0", newObjectModel.getId()).create();
    // then :
    assertThat(model.getObjectList(), is(Collections.singletonList(newObject)));
    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) SimpleTestModel(com.canoo.impl.server.util.SimpleTestModel) 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 93 with ServerModelStore

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

the class TestObservableListSync method replaceObjectElementAsUser_shouldReplaceElement.

@Test
public void replaceObjectElementAsUser_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 SimpleTestModel newObject = manager.create(SimpleTestModel.class);
    final PresentationModel newObjectModel = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
    final SimpleTestModel oldObject = manager.create(SimpleTestModel.class);
    model.getObjectList().add(oldObject);
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    model.getObjectList().set(0, newObject);
    // 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) 1)));
    assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
    assertThat(change.getAttribute("0").getValue(), allOf(instanceOf(String.class), is((Object) newObjectModel.getId())));
}
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) SimpleTestModel(com.canoo.impl.server.util.SimpleTestModel) 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 94 with ServerModelStore

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

the class TestObservableListSync method deletingSingleElementInMiddleFromDolphin_shouldDeleteElement.

@Test
public void deletingSingleElementInMiddleFromDolphin_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 :
    new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 1).withAttribute("to", 2).withAttribute("count", 0).create();
    // then :
    assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "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 95 with ServerModelStore

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

the class TestObservableListSync method replacingMultipleElementsInBeginningFromDolphin_shouldReplaceElements.

@Test
public void replacingMultipleElementsInBeginningFromDolphin_shouldReplaceElements() {
    // 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"));
    removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
    // when :
    new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 0).withAttribute("to", 2).withAttribute("count", 3).withAttribute("0", "42").withAttribute("1", "4711").withAttribute("2", "Hello World").create();
    assertThat(model.getPrimitiveList(), is(Arrays.asList("42", "4711", "Hello World", "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