use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestModelDeletion method testWithWrongModelType.
@Test(expectedExceptions = BeanDefinitionException.class)
public void testWithWrongModelType() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
beanRepository.delete("I'm a String");
}
use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method replacingMultipleElementsAtEndFromDolphin_shouldReplaceElements.
@Test
public void replacingMultipleElementsAtEndFromDolphin_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", 2).withAttribute("to", 4).withAttribute("count", 3).withAttribute("0", "42").withAttribute("1", "4711").withAttribute("2", "Hello World").create();
assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "2", "42", "4711", "Hello World")));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method addingSingleElementAtEndFromDolphin_shouldAddElement.
@Test
public void addingSingleElementAtEndFromDolphin_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 newElement = "42";
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 3).withAttribute("to", 3).withAttribute("count", 1).withAttribute("0", newElement).create();
assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "2", "3", newElement)));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method replacingSingleElementInMiddleFromDolphin_shouldReplaceElement.
@Test
public void replacingSingleElementInMiddleFromDolphin_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 :
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 1).withAttribute("to", 2).withAttribute("count", 1).withAttribute("0", newValue).create();
// then :
assertThat(model.getPrimitiveList(), is(Arrays.asList("1", "42", "3")));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.platform.remoting.BeanManager in project dolphin-platform by canoo.
the class TestObservableListSync method deletingSingleElementInBeginningFromDolphin_shouldRemoveElement.
// ////////////////////////////////////////////////////////////
// Removing elements from different positions from dolphin
// ////////////////////////////////////////////////////////////
@Test
public void deletingSingleElementInBeginningFromDolphin_shouldRemoveElement() {
// 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", 0).withAttribute("to", 1).withAttribute("count", 0).create();
// then :
assertThat(model.getPrimitiveList(), is(Arrays.asList("2", "3")));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Aggregations