use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method replacingMultipleElementsInMiddleFromDolphin_shouldReplaceElements.
@Test
public void replacingMultipleElementsInMiddleFromDolphin_shouldReplaceElements(@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"));
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 1).withAttribute("to", 3).withAttribute("count", 3).withAttribute("0", "42").withAttribute("1", "4711").withAttribute("2", "Hello World").create();
assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "42", "4711", "Hello World", "4")));
assertThat(clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method addingObjectNullFromDolphin_shouldAddElement.
@Test
public void addingObjectNullFromDolphin_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 PresentationModel classDescription = clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN).get(0);
classDescription.getAttribute("objectList").setValue(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN);
// when :
new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", null).create();
// then :
assertThat(model.getObjectList(), is(Collections.singletonList((SimpleTestModel) null)));
assertThat(clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method deletingPrimitiveNullFromDolphin_shouldDeleteElement.
@Test
public void deletingPrimitiveNullFromDolphin_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);
new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", null).create();
assertThat(model.getPrimitiveList(), hasSize(1));
// when :
new PresentationModelBuilder(clientModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 0).withAttribute("to", 1).withAttribute("count", 0).create();
// then :
assertThat(model.getPrimitiveList(), empty());
assertThat(clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method deletingSingleElementInMiddleFromDolphin_shouldDeleteElement.
@Test
public void deletingSingleElementInMiddleFromDolphin_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 :
new PresentationModelBuilder(clientModelStore, 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(clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method addingMultipleElementsInMiddleAsUser_shouldAddElements.
@Test
public void addingMultipleElementsInMiddleAsUser_shouldAddElements(@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 = new String[] { "42", "4711", "Hello World" };
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().addAll(1, Arrays.asList(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) 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"));
}
Aggregations