use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method deletingPrimitiveElementAsUser_shouldDeleteElement.
@Test
public void deletingPrimitiveElementAsUser_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().add("Hello");
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().remove(0);
// 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) 1)));
assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
}
use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method addingSingleElementInMiddleAsUser_shouldAddElement.
@Test
public void addingSingleElementInMiddleAsUser_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);
// when :
model.getPrimitiveList().add(1, newElement);
// 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) 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.server.legacy.ServerPresentationModel 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())));
}
use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class ServerPresentationModelBuilderTest method testWithAttributeCreation.
@Test
public void testWithAttributeCreation() {
ServerModelStore serverModelStore = createServerModelStore();
ServerPresentationModelBuilder builder = new ServerPresentationModelBuilder(serverModelStore);
ServerPresentationModel model = builder.withAttribute("testName").create();
assertNotNull(model);
assertEquals(model.getAttributes().size(), 2);
assertNotNull(model.getAttribute(RemotingConstants.SOURCE_SYSTEM));
assertNotNull(model.getAttribute("testName"));
}
use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class ServerPresentationModelBuilderTest method testWithIdCreation.
@Test
public void testWithIdCreation() {
ServerModelStore serverModelStore = createServerModelStore();
ServerPresentationModelBuilder builder = new ServerPresentationModelBuilder(serverModelStore);
ServerPresentationModel model = builder.withId("testId").create();
assertNotNull(model);
assertEquals(model.getId(), "testId");
}
Aggregations