use of com.canoo.dolphin.client.util.ChildModel in project dolphin-platform by canoo.
the class TestModelCreation 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);
assertThat(model, notNullValue());
assertThat(model.getParentProperty(), notNullValue());
assertThat(model.getParentProperty().get(), nullValue());
assertThat(model.getChildProperty(), notNullValue());
assertThat(model.getChildProperty().get(), nullValue());
assertThat(repository.isManaged(model), is(true));
List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(ChildModel.class.getName());
assertThat(dolphinModels, hasSize(1));
PresentationModel dolphinModel = dolphinModels.get(0);
List<Attribute> attributes = dolphinModel.getAttributes();
assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("childProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("parentProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_CLIENT)), hasProperty("qualifier", nullValue()))));
List<ClientPresentationModel> classModels = clientModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN);
assertThat(classModels, hasSize(1));
assertThat(classModels, contains(hasProperty("attributes", containsInAnyOrder(allOf(hasProperty("propertyName", is(PlatformRemotingConstants.JAVA_CLASS)), hasProperty("value", is(ChildModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("childProperty")), hasProperty("value", is(StringConverterFactory.FIELD_TYPE_STRING)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("parentProperty")), hasProperty("value", is(StringConverterFactory.FIELD_TYPE_STRING)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_CLIENT)), hasProperty("qualifier", nullValue()))))));
}
use of com.canoo.dolphin.client.util.ChildModel in project dolphin-platform by canoo.
the class TestModelDeletion 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);
repository.delete(model);
List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(ChildModel.class.getName());
assertThat(dolphinModels, empty());
Collection<ClientPresentationModel> allDolphinModels = clientModelStore.listPresentationModels();
assertThat(allDolphinModels, hasSize(1));
assertThat(repository.isManaged(model), is(false));
}
use of com.canoo.dolphin.client.util.ChildModel 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.dolphin.client.util.ChildModel in project dolphin-platform by canoo.
the class TestPropertyChange 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);
final ChildModel model = manager.create(ChildModel.class);
final ListerResults<String> childResults = new ListerResults<>();
ValueChangeListener<String> childListener = new ValueChangeListener<String>() {
@Override
public void valueChanged(ValueChangeEvent<? extends String> evt) {
Assert.assertEquals(evt.getSource(), model.getChildProperty());
childResults.newValue = evt.getNewValue();
childResults.oldValue = evt.getOldValue();
childResults.listenerCalls++;
}
};
final ListerResults<String> parentResults = new ListerResults<>();
ValueChangeListener<String> parentListener = new ValueChangeListener<String>() {
@Override
public void valueChanged(ValueChangeEvent<? extends String> evt) {
Assert.assertEquals(evt.getSource(), model.getParentProperty());
parentResults.newValue = evt.getNewValue();
parentResults.oldValue = evt.getOldValue();
parentResults.listenerCalls++;
}
};
model.getChildProperty().onChanged(childListener);
model.getParentProperty().onChanged(parentListener);
assertThat(childResults.listenerCalls, is(0));
assertThat(childResults.newValue, nullValue());
assertThat(childResults.oldValue, nullValue());
assertThat(parentResults.listenerCalls, is(0));
assertThat(parentResults.newValue, nullValue());
assertThat(parentResults.oldValue, nullValue());
model.getChildProperty().set("Hallo Property");
assertThat(childResults.listenerCalls, is(1));
assertThat(childResults.newValue, is("Hallo Property"));
assertThat(childResults.oldValue, nullValue());
assertThat(parentResults.listenerCalls, is(0));
assertThat(parentResults.newValue, nullValue());
assertThat(parentResults.oldValue, nullValue());
childResults.listenerCalls = 0;
childResults.newValue = null;
childResults.oldValue = null;
model.getParentProperty().set("Hallo Property2");
assertThat(childResults.listenerCalls, is(0));
assertThat(childResults.newValue, nullValue());
assertThat(childResults.oldValue, nullValue());
assertThat(parentResults.listenerCalls, is(1));
assertThat(parentResults.newValue, is("Hallo Property2"));
assertThat(parentResults.oldValue, nullValue());
}
Aggregations