use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class TestDeleteAll method testWithSimpleModel.
@Test
public void testWithSimpleModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
SimpleTestModel model1 = manager.create(SimpleTestModel.class);
SimpleTestModel model2 = manager.create(SimpleTestModel.class);
SimpleTestModel model3 = manager.create(SimpleTestModel.class);
SimpleAnnotatedTestModel wrongModel = manager.create(SimpleAnnotatedTestModel.class);
for (final Object bean : manager.findAll(SimpleTestModel.class)) {
beanRepository.delete(bean);
}
assertThat(beanRepository.isManaged(model1), is(false));
assertThat(beanRepository.isManaged(model2), is(false));
assertThat(beanRepository.isManaged(model3), is(false));
assertThat(beanRepository.isManaged(wrongModel), is(true));
List<ServerPresentationModel> testModels = serverModelStore.findAllPresentationModelsByType("com.canoo.dolphin.server.util.SimpleTestModel");
assertThat(testModels, hasSize(0));
}
use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class CreatePresentationModelAction method createPresentationModel.
private static void createPresentationModel(final CreatePresentationModelCommand command, final ServerModelStore serverModelStore) {
if (serverModelStore.findPresentationModelById(command.getPmId()) != null) {
LOG.trace("Ignoring create PM '{}' since it is already in the model store.", command.getPmId());
return;
}
if (command.getPmId().endsWith(RemotingConstants.SERVER_PM_AUTO_ID_SUFFIX)) {
LOG.trace("Creating the PM '{}' with reserved server-auto-suffix.", command.getPmId());
}
List<ServerAttribute> attributes = new LinkedList();
for (Map<String, Object> attr : command.getAttributes()) {
ServerAttribute attribute = new ServerAttribute((String) attr.get("propertyName"), attr.get("value"), (String) attr.get("qualifier"));
attribute.setId((String) attr.get("id"));
attributes.add(attribute);
}
ServerPresentationModel model = new ServerPresentationModel(command.getPmId(), attributes, serverModelStore);
model.setPresentationModelType(command.getPmType());
serverModelStore.checkClientAdded(model);
}
use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method replacingSingleElementAtBeginningAsUser_shouldReplaceElement.
// ////////////////////////////////////////////////////////////
// Replacing elements from different positions as user
// ////////////////////////////////////////////////////////////
@Test
public void replacingSingleElementAtBeginningAsUser_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 :
model.getPrimitiveList().set(0, newValue);
// 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) 1)));
assertThat(change.getAttribute("0").getValue(), allOf(instanceOf(String.class), is((Object) newValue)));
}
use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method replaceObjectElementWithNullAsUser_shouldReplaceElement.
@Test
public void replaceObjectElementWithNullAsUser_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 oldObject = manager.create(SimpleTestModel.class);
model.getObjectList().add(oldObject);
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getObjectList().set(0, null);
// 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(), nullValue());
}
use of com.canoo.dp.impl.server.legacy.ServerPresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method addingMultipleElementInBeginningAsUser_shouldAddElements.
@Test
public void addingMultipleElementInBeginningAsUser_shouldAddElements() {
// 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 = new String[] { "42", "4711", "Hello World" };
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().addAll(0, Arrays.asList(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) 0)));
assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
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