use of com.canoo.impl.server.util.PrimitiveDataTypesModel in project dolphin-platform by canoo.
the class TestPropertyValue method testWithAllPrimitiveDataTypesModel.
@Test
public void testWithAllPrimitiveDataTypesModel() {
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
PrimitiveDataTypesModel model = manager.create(PrimitiveDataTypesModel.class);
ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(PrimitiveDataTypesModel.class.getName()).get(0);
Attribute textAttribute = dolphinModel.getAttribute("textProperty");
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"));
Attribute intAttribute = dolphinModel.getAttribute("integerProperty");
assertThat(intAttribute.getValue(), nullValue());
model.getIntegerProperty().set(1);
assertThat((Integer) intAttribute.getValue(), is(1));
assertThat(model.getIntegerProperty().get(), is(1));
intAttribute.setValue(2);
assertThat((Integer) intAttribute.getValue(), is(2));
assertThat(model.getIntegerProperty().get(), is(2));
Attribute booleanAttribute = dolphinModel.getAttribute("booleanProperty");
assertThat(booleanAttribute.getValue(), nullValue());
model.getBooleanProperty().set(true);
assertThat((Boolean) booleanAttribute.getValue(), is(true));
assertThat(model.getBooleanProperty().get(), is(true));
model.getBooleanProperty().set(false);
assertThat((Boolean) booleanAttribute.getValue(), is(false));
assertThat(model.getBooleanProperty().get(), is(false));
}
use of com.canoo.impl.server.util.PrimitiveDataTypesModel in project dolphin-platform by canoo.
the class TestModelCreation method testWithAllPrimitiveDatatypes.
@Test
public void testWithAllPrimitiveDatatypes() {
final ServerModelStore serverModelStore = createServerModelStore();
final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
PrimitiveDataTypesModel model = manager.create(PrimitiveDataTypesModel.class);
assertThat(model, notNullValue());
assertThat(model.getTextProperty(), notNullValue());
assertThat(model.getTextProperty().get(), nullValue());
assertThat(beanRepository.isManaged(model), is(true));
List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(PrimitiveDataTypesModel.class.getName());
assertThat(dolphinModels, hasSize(1));
ServerPresentationModel dolphinModel = dolphinModels.get(0);
List<ServerAttribute> attributes = dolphinModel.getAttributes();
assertThat(attributes, hasSize(9));
for (Attribute attribute : attributes) {
if (RemotingConstants.SOURCE_SYSTEM.equals(attribute.getPropertyName())) {
assertThat(attribute.getValue(), Matchers.<Object>is(RemotingConstants.SOURCE_SYSTEM_SERVER));
} else {
assertThat(attribute.getValue(), nullValue());
}
assertThat(attribute.getQualifier(), nullValue());
}
final List<ServerPresentationModel> classModels = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN);
assertThat(classModels, hasSize(1));
final PresentationModel classModel = classModels.get(0);
final List<Attribute> classAttributes = classModel.getAttributes();
assertThat(classAttributes, hasSize(10));
for (Attribute attribute : classAttributes) {
if (PlatformRemotingConstants.JAVA_CLASS.equals(attribute.getPropertyName())) {
assertThat(attribute.getValue(), Matchers.<Object>is(PrimitiveDataTypesModel.class.getName()));
} else if (RemotingConstants.SOURCE_SYSTEM.equals(attribute.getPropertyName())) {
assertThat(attribute.getValue(), Matchers.<Object>is(RemotingConstants.SOURCE_SYSTEM_SERVER));
} else {
switch(attribute.getPropertyName()) {
case "byteProperty":
assertThat(attribute.getValue(), Matchers.<Object>is(ByteConverterFactory.FIELD_TYPE_BYTE));
break;
case "shortProperty":
assertThat(attribute.getValue(), Matchers.<Object>is(ShortConverterFactory.FIELD_TYPE_SHORT));
break;
case "integerProperty":
assertThat(attribute.getValue(), Matchers.<Object>is(IntegerConverterFactory.FIELD_TYPE_INT));
break;
case "longProperty":
assertThat(attribute.getValue(), Matchers.<Object>is(LongConverterFactory.FIELD_TYPE_LONG));
break;
case "floatProperty":
assertThat(attribute.getValue(), Matchers.<Object>is(FloatConverterFactory.FIELD_TYPE_FLOAT));
break;
case "doubleProperty":
assertThat(attribute.getValue(), Matchers.<Object>is(DoubleConverterFactory.FIELD_TYPE_DOUBLE));
break;
case "booleanProperty":
assertThat(attribute.getValue(), Matchers.<Object>is(BooleanConverterFactory.FIELD_TYPE_BOOLEAN));
break;
case "textProperty":
assertThat(attribute.getValue(), Matchers.<Object>is(StringConverterFactory.FIELD_TYPE_STRING));
break;
default:
fail("Unknown attribute found: " + attribute);
break;
}
}
assertThat(attribute.getQualifier(), nullValue());
}
}
Aggregations