use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestPropertyValue method testWithSingleReferenceModel.
@Test
public void testWithSingleReferenceModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
final SimpleTestModel ref1 = manager.create(SimpleTestModel.class);
ref1.getTextProperty().set("ref1_text");
final SimpleTestModel ref2 = manager.create(SimpleTestModel.class);
ref2.getTextProperty().set("ref2_text");
final List<ServerPresentationModel> refPMs = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
final ServerPresentationModel ref1PM = "ref1_text".equals(refPMs.get(0).getAttribute("text").getValue()) ? refPMs.get(0) : refPMs.get(1);
final ServerPresentationModel ref2PM = "ref2_text".equals(refPMs.get(0).getAttribute("text").getValue()) ? refPMs.get(0) : refPMs.get(1);
final SingleReferenceModel model = manager.create(SingleReferenceModel.class);
final ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName()).get(0);
final Attribute referenceAttribute = dolphinModel.getAttribute("referenceProperty");
assertThat(referenceAttribute.getValue(), nullValue());
model.getReferenceProperty().set(ref1);
assertThat((String) referenceAttribute.getValue(), is(ref1PM.getId()));
assertThat(model.getReferenceProperty().get(), is(ref1));
referenceAttribute.setValue(ref2PM.getId());
assertThat((String) referenceAttribute.getValue(), is(ref2PM.getId()));
assertThat(model.getReferenceProperty().get(), is(ref2));
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestPropertyValue method testWithAnnotatedSimpleModel.
@Test
public void testWithAnnotatedSimpleModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
SimpleAnnotatedTestModel model = manager.create(SimpleAnnotatedTestModel.class);
ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(SimpleAnnotatedTestModel.class.getName()).get(0);
Attribute textAttribute = dolphinModel.getAttribute("myProperty");
assertThat(textAttribute.getValue(), nullValue());
model.getMyProperty().set("Hallo Platform");
assertThat((String) textAttribute.getValue(), is("Hallo Platform"));
assertThat(model.getMyProperty().get(), is("Hallo Platform"));
textAttribute.setValue("Hallo Dolphin");
assertThat((String) textAttribute.getValue(), is("Hallo Dolphin"));
assertThat(model.getMyProperty().get(), is("Hallo Dolphin"));
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestPropertyValue method testWithInheritedModel.
@Test
public void testWithInheritedModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
ChildModel model = manager.create(ChildModel.class);
ServerPresentationModel dolphinModel = serverModelStore.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((String) childAttribute.getValue(), is("Hallo Platform"));
assertThat(model.getChildProperty().get(), is("Hallo Platform"));
assertThat(parentAttribute.getValue(), nullValue());
assertThat(model.getParentProperty().get(), nullValue());
parentAttribute.setValue("Hallo Dolphin");
assertThat((String) childAttribute.getValue(), is("Hallo Platform"));
assertThat(model.getChildProperty().get(), is("Hallo Platform"));
assertThat((String) parentAttribute.getValue(), is("Hallo Dolphin"));
assertThat(model.getParentProperty().get(), is("Hallo Dolphin"));
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestModelCreation method testWithSingleReferenceModel.
@Test
public void testWithSingleReferenceModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
SingleReferenceModel model = manager.create(SingleReferenceModel.class);
assertThat(model, notNullValue());
assertThat(model.getReferenceProperty(), notNullValue());
assertThat(model.getReferenceProperty().get(), nullValue());
assertThat(beanRepository.isManaged(model), is(true));
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName());
assertThat(dolphinModels, hasSize(1));
ServerPresentationModel dolphinModel = dolphinModels.get(0);
List<ServerAttribute> attributes = dolphinModel.getAttributes();
assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("referenceProperty")), 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(SingleReferenceModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("referenceProperty")), hasProperty("value", is(DolphinBeanConverterFactory.FIELD_TYPE_DOLPHIN_BEAN)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_SERVER)), hasProperty("qualifier", nullValue()))))));
}
use of com.canoo.dp.impl.server.legacy.ServerModelStore in project dolphin-platform by canoo.
the class TestModelCreation method testWithInheritedModel.
@Test
public void testWithInheritedModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, 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(beanRepository.isManaged(model), is(true));
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(ChildModel.class.getName());
assertThat(dolphinModels, hasSize(1));
ServerPresentationModel dolphinModel = dolphinModels.get(0);
List<ServerAttribute> 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_SERVER)), hasProperty("qualifier", nullValue()))));
List<ServerPresentationModel> classModels = serverModelStore.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_SERVER)), hasProperty("qualifier", nullValue()))))));
}
Aggregations