use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestModelDeletion method testWithSimpleModel.
@Test
public void testWithSimpleModel(@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);
SimpleTestModel model = manager.create(SimpleTestModel.class);
repository.delete(model);
List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
assertThat(dolphinModels, empty());
Collection<ClientPresentationModel> allDolphinModels = clientModelStore.listPresentationModels();
assertThat(allDolphinModels, hasSize(1));
assertThat(repository.isManaged(model), is(false));
}
use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestPropertyChange method testWithAnnotatedSimpleModel.
@Test
public void testWithAnnotatedSimpleModel(@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);
final SimpleAnnotatedTestModel model = manager.create(SimpleAnnotatedTestModel.class);
final ListerResults<String> results = new ListerResults<>();
ValueChangeListener<String> myListener = new ValueChangeListener<String>() {
@Override
public void valueChanged(ValueChangeEvent<? extends String> evt) {
Assert.assertEquals(evt.getSource(), model.myProperty());
results.newValue = evt.getNewValue();
results.oldValue = evt.getOldValue();
results.listenerCalls++;
}
};
final Subscription subscription = model.myProperty().onChanged(myListener);
assertThat(results.listenerCalls, is(0));
assertThat(results.newValue, nullValue());
assertThat(results.oldValue, nullValue());
model.myProperty().set("Hallo Property");
assertThat(results.listenerCalls, is(1));
assertThat(results.newValue, is("Hallo Property"));
assertThat(results.oldValue, nullValue());
results.listenerCalls = 0;
model.myProperty().set("Hallo Property2");
assertThat(results.listenerCalls, is(1));
assertThat(results.newValue, is("Hallo Property2"));
assertThat(results.oldValue, is("Hallo Property"));
results.listenerCalls = 0;
model.myProperty().set(null);
assertThat(results.listenerCalls, is(1));
assertThat(results.newValue, nullValue());
assertThat(results.oldValue, is("Hallo Property2"));
results.listenerCalls = 0;
subscription.unsubscribe();
model.myProperty().set("Hallo Property3");
assertThat(results.listenerCalls, is(0));
assertThat(results.newValue, nullValue());
assertThat(results.oldValue, is("Hallo Property2"));
}
use of com.canoo.dp.impl.remoting.BeanRepository 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.BeanRepository in project dolphin-platform by canoo.
the class TestDeleteAll method testWithSimpleModel.
@Test
public void testWithSimpleModel(@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);
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 (Object bean : manager.findAll(SimpleTestModel.class)) {
repository.delete(bean);
}
assertThat(repository.isManaged(model1), is(false));
assertThat(repository.isManaged(model2), is(false));
assertThat(repository.isManaged(model3), is(false));
assertThat(repository.isManaged(wrongModel), is(true));
List<ClientPresentationModel> testModels = clientModelStore.findAllPresentationModelsByType("com.canoo.dolphin.client.util.SimpleTestModel");
assertThat(testModels, hasSize(0));
}
use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class AbstractDolphinBasedTest method createBeanManager.
protected BeanManager createBeanManager(final ClientModelStore clientModelStore) {
final EventDispatcher dispatcher = createEventDispatcher(clientModelStore);
final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher);
return createBeanManager(clientModelStore, repository, dispatcher);
}
Aggregations