use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestModelCreation method testWithAnnotatedSimpleModel.
@Test
public void testWithAnnotatedSimpleModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
SimpleAnnotatedTestModel model = manager.create(SimpleAnnotatedTestModel.class);
assertThat(model, notNullValue());
assertThat(model.getMyProperty(), notNullValue());
assertThat(model.getMyProperty().get(), nullValue());
assertThat(beanRepository.isManaged(model), is(true));
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(SimpleAnnotatedTestModel.class.getName());
assertThat(dolphinModels, hasSize(1));
ServerPresentationModel dolphinModel = dolphinModels.get(0);
List<ServerAttribute> attributes = dolphinModel.getAttributes();
assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("myProperty")), 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(SimpleAnnotatedTestModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("myProperty")), 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.BeanRepository in project dolphin-platform by canoo.
the class TestModelCreation method testWithComplexDataTypesModel.
@Test
public void testWithComplexDataTypesModel(@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);
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(repository.isManaged(model), is(true));
List<ClientPresentationModel> dolphinModels = clientModelStore.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_CLIENT)), hasProperty("qualifier", nullValue()))));
List<ClientPresentationModel> classModels = clientModelStore.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_CLIENT)), hasProperty("qualifier", nullValue()))))));
}
use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestModelCreation 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);
assertThat(model, notNullValue());
assertThat(model.getTextProperty(), notNullValue());
assertThat(model.getTextProperty().get(), nullValue());
assertThat(repository.isManaged(model), is(true));
List<ClientPresentationModel> dolphinModels = clientModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
assertThat(dolphinModels, hasSize(1));
PresentationModel dolphinModel = dolphinModels.get(0);
List<Attribute> 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_CLIENT)), hasProperty("qualifier", nullValue()))));
List<ClientPresentationModel> classModels = clientModelStore.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_CLIENT)), hasProperty("qualifier", nullValue()))))));
}
use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestModelDeletion method testWithNull.
@Test(expectedExceptions = NullPointerException.class)
public void testWithNull(@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);
repository.delete(null);
}
use of com.canoo.dp.impl.remoting.BeanRepository in project dolphin-platform by canoo.
the class TestModelDeletion method testWithWrongModelType.
@Test(expectedExceptions = BeanDefinitionException.class)
public void testWithWrongModelType(@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);
repository.delete("I'm a String");
}
Aggregations