use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method replacePrimitiveNullWithElementAsUser_shouldReplaceElement.
@Test
public void replacePrimitiveNullWithElementAsUser_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 String newValue = "Goodbye World";
model.getPrimitiveList().add(null);
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().set(0, newValue);
// 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) 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.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method replacingSingleElementInMiddleAsUser_shouldReplaceElement.
@Test
public void replacingSingleElementInMiddleAsUser_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 String newValue = "42";
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
deleteAllPresentationModelsOfType(clientModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().set(1, newValue);
// 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) 1)));
assertThat(change.getAttribute("0").getValue(), allOf(instanceOf(String.class), is((Object) newValue)));
}
use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class TestPropertyValue method testWithInheritedModel.
@Test
public void testWithInheritedModel(@Mocked AbstractClientConnector connector) {
final ClientModelStore clientModelStore = createClientModelStore(connector);
final EventDispatcher dispatcher = createEventDispatcher(clientModelStore);
final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher);
final BeanManager manager = createBeanManager(clientModelStore, repository, dispatcher);
ChildModel model = manager.create(ChildModel.class);
PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(ChildModel.class.getName()).get(0);
Attribute childAttribute = dolphinModel.getAttribute("childProperty");
assertThat(childAttribute.getValue(), nullValue());
Attribute parentAttribute = dolphinModel.getAttribute("parentProperty");
assertThat(parentAttribute.getValue(), nullValue());
model.getChildProperty().set("Hallo Platform");
assertThat(childAttribute.getValue(), is((Object) "Hallo Platform"));
assertThat(model.getChildProperty().get(), is("Hallo Platform"));
assertThat(parentAttribute.getValue(), nullValue());
assertThat(model.getParentProperty().get(), nullValue());
parentAttribute.setValue("Hallo Dolphin");
assertThat(childAttribute.getValue(), is((Object) "Hallo Platform"));
assertThat(model.getChildProperty().get(), is("Hallo Platform"));
assertThat(parentAttribute.getValue(), is((Object) "Hallo Dolphin"));
assertThat(model.getParentProperty().get(), is("Hallo Dolphin"));
}
use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class EventDispatcherImpl method modelStoreChanged.
@Override
public void modelStoreChanged(ModelStoreEvent event) {
Assert.requireNonNull(event, "event");
final PresentationModel model = event.getPresentationModel();
if (!isLocalChange(model)) {
if (ModelStoreEvent.Type.ADDED == event.getType()) {
onAddedHandler(model);
} else if (ModelStoreEvent.Type.REMOVED == event.getType()) {
onRemovedHandler(model);
}
}
}
use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class BeanRepositoryImpl method findAll.
@Override
@SuppressWarnings("unchecked")
public <T> List<T> findAll(Class<T> beanClass) {
DolphinUtils.assertIsDolphinBean(beanClass);
final List<T> result = new ArrayList<>();
final List<PresentationModel> presentationModels = modelStore.findAllPresentationModelsByType(DolphinUtils.getDolphinPresentationModelTypeForClass(beanClass));
for (PresentationModel model : presentationModels) {
result.add((T) dolphinIdToObjectPm.get(model.getId()));
}
return result;
}
Aggregations