use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestObservableListSync method deletingObjectNullFromserverModelStore_shouldDeleteElement.
@Test
public void deletingObjectNullFromserverModelStore_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);
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(), hasSize(1));
// when :
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 1).withAttribute("count", 0).create();
// then :
assertThat(model.getObjectList(), empty());
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestObservableListSync method deletingMultipleElementInMiddleFromDolphin_shouldRemoveElements.
@Test
public void deletingMultipleElementInMiddleFromDolphin_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", 2).withAttribute("to", 4).withAttribute("count", 0).create();
// then :
assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "2", "5", "6")));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore 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)));
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestObservableListSync method addingObjectElementFromserverModelStore_shouldAddElement.
// /////////////////////////////////////////////////////////////////
// Adding, removing, and replacing all element types from dolphin
// /////////////////////////////////////////////////////////////////
@Test
public void addingObjectElementFromserverModelStore_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 PresentationModel classDescription = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN).get(0);
classDescription.getAttribute("objectList").setValue(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN);
final SimpleTestModel object = manager.create(SimpleTestModel.class);
final PresentationModel objectModel = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
// when :
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", objectModel.getId()).create();
// then :
assertThat(model.getObjectList(), is(Collections.singletonList(object)));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestObservableListSync method addingPrimitiveElementFromDolphin_shouldAddElement.
@Test
public void addingPrimitiveElementFromDolphin_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 value = "Hello";
// when :
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", value).create();
// then :
assertThat(model.getPrimitiveList(), is(Collections.singletonList(value)));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Aggregations