use of com.canoo.dp.impl.remoting.EventDispatcher 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.remoting.EventDispatcher 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()))))));
}
use of com.canoo.dp.impl.remoting.EventDispatcher in project dolphin-platform by canoo.
the class TestModelCreation method testWithComplexDataTypesModel.
@Test
public void testWithComplexDataTypesModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
ComplexDataTypesModel model = manager.create(ComplexDataTypesModel.class);
assertThat(model, notNullValue());
assertThat(model.getDateProperty(), notNullValue());
assertThat(model.getDateProperty().get(), nullValue());
assertThat(model.getCalendarProperty(), notNullValue());
assertThat(model.getCalendarProperty().get(), nullValue());
assertThat(model.getEnumProperty(), notNullValue());
assertThat(model.getEnumProperty().get(), nullValue());
assertThat(beanRepository.isManaged(model), is(true));
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(ComplexDataTypesModel.class.getName());
assertThat(dolphinModels, hasSize(1));
PresentationModel dolphinModel = dolphinModels.get(0);
List<Attribute> attributes = dolphinModel.getAttributes();
assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("dateProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("calendarProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("enumProperty")), 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(ComplexDataTypesModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("dateProperty")), hasProperty("value", is(DateConverterFactory.FIELD_TYPE_DATE)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("calendarProperty")), hasProperty("value", is(CalendarConverterFactory.FIELD_TYPE_CALENDAR)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("enumProperty")), hasProperty("value", is(EnumConverterFactory.FIELD_TYPE_ENUM)), 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.remoting.EventDispatcher in project dolphin-platform by canoo.
the class TestModelDeletion 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);
beanRepository.delete(model);
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName());
assertThat(dolphinModels, empty());
Collection<ServerPresentationModel> allDolphinModels = serverModelStore.listPresentationModels();
assertThat(allDolphinModels, hasSize(1));
assertThat(beanRepository.isManaged(model), is(false));
}
use of com.canoo.dp.impl.remoting.EventDispatcher in project dolphin-platform by canoo.
the class TestModelDeletion 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);
beanRepository.delete(model);
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(ChildModel.class.getName());
assertThat(dolphinModels, empty());
Collection<ServerPresentationModel> allDolphinModels = serverModelStore.listPresentationModels();
assertThat(allDolphinModels, hasSize(1));
assertThat(beanRepository.isManaged(model), is(false));
}
Aggregations