use of com.canoo.impl.server.util.SimpleTestModel in project dolphin-platform by canoo.
the class TestPropertyValue method testWithSimpleModel.
@Test
public void testWithSimpleModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
SimpleTestModel model = manager.create(SimpleTestModel.class);
ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
Attribute textAttribute = dolphinModel.getAttribute("text");
assertThat(textAttribute.getValue(), nullValue());
model.getTextProperty().set("Hallo Platform");
assertThat((String) textAttribute.getValue(), is("Hallo Platform"));
assertThat(model.getTextProperty().get(), is("Hallo Platform"));
textAttribute.setValue("Hallo Dolphin");
assertThat((String) textAttribute.getValue(), is("Hallo Dolphin"));
assertThat(model.getTextProperty().get(), is("Hallo Dolphin"));
}
use of com.canoo.impl.server.util.SimpleTestModel in project dolphin-platform by canoo.
the class TestModelCreation 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 model = manager.create(SimpleTestModel.class);
assertThat(model, notNullValue());
assertThat(model.getTextProperty(), notNullValue());
assertThat(model.getTextProperty().get(), nullValue());
assertThat(beanRepository.isManaged(model), is(true));
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
assertThat(dolphinModels, hasSize(1));
ServerPresentationModel dolphinModel = dolphinModels.get(0);
List<ServerAttribute> attributes = dolphinModel.getAttributes();
assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("text")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_SERVER)), hasProperty("qualifier", nullValue()))));
List<ServerPresentationModel> classModels = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN);
assertThat(classModels, contains(hasProperty("attributes", containsInAnyOrder(allOf(hasProperty("propertyName", is(PlatformRemotingConstants.JAVA_CLASS)), hasProperty("value", is(SimpleTestModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("text")), hasProperty("value", is(StringConverterFactory.FIELD_TYPE_STRING)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_SERVER)), hasProperty("qualifier", nullValue()))))));
}
use of com.canoo.impl.server.util.SimpleTestModel in project dolphin-platform by canoo.
the class TestModelDeletion 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 model = manager.create(SimpleTestModel.class);
beanRepository.delete(model);
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
assertThat(dolphinModels, empty());
Collection<ServerPresentationModel> allDolphinModels = serverModelStore.listPresentationModels();
assertThat(allDolphinModels, hasSize(1));
assertThat(beanRepository.isManaged(model), is(false));
}
use of com.canoo.impl.server.util.SimpleTestModel in project dolphin-platform by canoo.
the class TestObservableListSync method addingObjectNullFromDolphin_shouldAddElement.
@Test
public void addingObjectNullFromDolphin_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 PresentationModel classDescription = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN).get(0);
classDescription.getAttribute("objectList").setValue(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN);
// when :
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", null).create();
// then :
assertThat(model.getObjectList(), is(Collections.<SimpleTestModel>singletonList(null)));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.impl.server.util.SimpleTestModel in project dolphin-platform by canoo.
the class TestObservableListSync method replacingObjectElementWithNullFromDolphin_shouldReplaceElement.
@Test
public void replacingObjectElementWithNullFromDolphin_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 PresentationModel classDescription = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN).get(0);
classDescription.getAttribute("objectList").setValue(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN);
final SimpleTestModel oldObject = manager.create(SimpleTestModel.class);
final PresentationModel oldObjectModel = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName()).get(0);
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 0).withAttribute("count", 1).withAttribute("0", oldObjectModel.getId()).create();
assertThat(model.getObjectList(), is(Collections.singletonList(oldObject)));
// when :
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "objectList").withAttribute("from", 0).withAttribute("to", 1).withAttribute("count", 1).withAttribute("0", null).create();
// then :
assertThat(model.getObjectList(), is(Collections.<SimpleTestModel>singletonList(null)));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
Aggregations