use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.
the class ServerControllerActionCallBean method getParam.
public Object getParam(String name, Class<?> type) {
final String internalName = PARAM_PREFIX + name;
final Attribute valueAttribute = pm.getAttribute(internalName);
if (valueAttribute == null) {
throw new IllegalArgumentException(String.format("Invoking RemotingAction requires parameter '%s', but it was not withContent", name));
}
try {
return converters.getConverter(type).convertFromDolphin(valueAttribute.getValue());
} catch (ValueConverterException e) {
throw new MappingException("Error in conversion", e);
}
}
use of com.canoo.dp.impl.remoting.legacy.core.Attribute 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.legacy.core.Attribute 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.legacy.core.Attribute in project dolphin-platform by canoo.
the class TestPropertyValue method testWithAllPrimitiveDataTypesModel.
@Test
public void testWithAllPrimitiveDataTypesModel(@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);
PrimitiveDataTypesModel model = manager.create(PrimitiveDataTypesModel.class);
PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(PrimitiveDataTypesModel.class.getName()).get(0);
Attribute textAttribute = dolphinModel.getAttribute("textProperty");
assertThat(textAttribute.getValue(), nullValue());
model.getTextProperty().set("Hallo Platform");
assertThat(textAttribute.getValue(), is((Object) "Hallo Platform"));
assertThat(model.getTextProperty().get(), is("Hallo Platform"));
textAttribute.setValue("Hallo Dolphin");
assertThat(textAttribute.getValue(), is((Object) "Hallo Dolphin"));
assertThat(model.getTextProperty().get(), is("Hallo Dolphin"));
Attribute intAttribute = dolphinModel.getAttribute("integerProperty");
assertThat(intAttribute.getValue(), nullValue());
model.getIntegerProperty().set(1);
assertThat(intAttribute.getValue(), is((Object) 1));
assertThat(model.getIntegerProperty().get(), is(1));
intAttribute.setValue(2);
assertThat(intAttribute.getValue(), is((Object) 2));
assertThat(model.getIntegerProperty().get(), is(2));
Attribute booleanAttribute = dolphinModel.getAttribute("booleanProperty");
assertThat(booleanAttribute.getValue(), nullValue());
model.getBooleanProperty().set(true);
assertThat(booleanAttribute.getValue(), is((Object) true));
assertThat(model.getBooleanProperty().get(), is(true));
model.getBooleanProperty().set(false);
assertThat(booleanAttribute.getValue(), is((Object) false));
assertThat(model.getBooleanProperty().get(), is(false));
}
use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.
the class TestPropertyValue method testWithAnnotatedSimpleModel.
@Test
public void testWithAnnotatedSimpleModel(@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);
SimpleAnnotatedTestModel model = manager.create(SimpleAnnotatedTestModel.class);
PresentationModel dolphinModel = clientModelStore.findAllPresentationModelsByType(SimpleAnnotatedTestModel.class.getName()).get(0);
Attribute textAttribute = dolphinModel.getAttribute("myProperty");
assertThat(textAttribute.getValue(), nullValue());
model.myProperty().set("Hallo Platform");
assertThat(textAttribute.getValue(), is((Object) "Hallo Platform"));
assertThat(model.myProperty().get(), is("Hallo Platform"));
textAttribute.setValue("Hallo Dolphin");
assertThat(textAttribute.getValue(), is((Object) "Hallo Dolphin"));
assertThat(model.myProperty().get(), is("Hallo Dolphin"));
}
Aggregations