use of com.canoo.dp.impl.client.legacy.ClientPresentationModel 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(@Mocked AbstractClientConnector connector) {
// given :
final ClientModelStore clientModelStore = createClientModelStore(connector);
final BeanManager manager = createBeanManager(clientModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3", "4", "5", "6"));
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().subList(0, 3).clear();
// then :
final List<ClientPresentationModel> changes = clientModelStore.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.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method addingSingleElementInMiddleAsUser_shouldAddElement.
@Test
public void addingSingleElementInMiddleAsUser_shouldAddElement(@Mocked AbstractClientConnector connector) {
// given :
final ClientModelStore clientModelStore = createClientModelStore(connector);
final BeanManager manager = createBeanManager(clientModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
final String newElement = "42";
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().add(1, newElement);
// then :
final List<ClientPresentationModel> changes = clientModelStore.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) 1)));
assertThat(change.getAttribute("0").getValue(), is((Object) newElement));
}
use of com.canoo.dp.impl.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method replaceObjectElementWithNullAsUser_shouldReplaceElement.
@Test
public void replaceObjectElementWithNullAsUser_shouldReplaceElement(@Mocked AbstractClientConnector connector) {
// given :
final ClientModelStore clientModelStore = createClientModelStore(connector);
final BeanManager manager = createBeanManager(clientModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
final SimpleTestModel oldObject = manager.create(SimpleTestModel.class);
model.getObjectList().add(oldObject);
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getObjectList().set(0, null);
// then :
final List<ClientPresentationModel> changes = clientModelStore.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(), nullValue());
}
use of com.canoo.dp.impl.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method addingSingleElementInBeginningAsUser_shouldAddElement.
@Test
public void addingSingleElementInBeginningAsUser_shouldAddElement(@Mocked AbstractClientConnector connector) {
// given :
final ClientModelStore clientModelStore = createClientModelStore(connector);
final BeanManager manager = createBeanManager(clientModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
final String newElement = "42";
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().add(0, newElement);
// then :
final List<ClientPresentationModel> changes = clientModelStore.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(), is((Object) newElement));
}
use of com.canoo.dp.impl.client.legacy.ClientPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method deletingSingleElementInMiddleAsUser_shouldDeleteElement.
@Test
public void deletingSingleElementInMiddleAsUser_shouldDeleteElement(@Mocked AbstractClientConnector connector) {
// given :
final ClientModelStore clientModelStore = createClientModelStore(connector);
final BeanManager manager = createBeanManager(clientModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = clientModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().remove(1);
// then :
final List<ClientPresentationModel> changes = clientModelStore.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) 2)));
assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
}
Aggregations