use of com.google.appengine.api.datastore.EmbeddedEntity in project activityinfo by bedatadriven.
the class FormConverterTest method deserializationEnumTypeNoChoices.
@Test
public void deserializationEnumTypeNoChoices() {
EnumType type = new EnumType(Cardinality.SINGLE, EnumType.Presentation.AUTOMATIC, Collections.<EnumItem>emptyList());
JsonValue jsonObject = type.getParametersAsJson();
EmbeddedEntity entity = FormConverter.toEmbeddedEntity(jsonObject);
JsonValue fromEntity = FormConverter.fromEmbeddedEntity(entity);
EnumType reType = EnumType.TYPE_CLASS.deserializeType(fromEntity);
assertThat(reType.getCardinality(), equalTo(Cardinality.SINGLE));
assertThat(reType.getPresentation(), equalTo(EnumType.Presentation.AUTOMATIC));
assertThat(reType.getValues(), hasSize(0));
}
use of com.google.appengine.api.datastore.EmbeddedEntity in project activityinfo by bedatadriven.
the class FormRecordEntity method setFieldValues.
public void setFieldValues(FormClass formClass, Map<ResourceId, FieldValue> values) {
if (fieldValues == null) {
fieldValues = new EmbeddedEntity();
}
for (FormField field : formClass.getFields()) {
if (values.containsKey(field.getId())) {
FieldValue value = values.get(field.getId());
if (value == null) {
fieldValues.removeProperty(field.getName());
} else {
FieldConverter converter = FieldConverters.forType(field.getType());
fieldValues.setUnindexedProperty(field.getName(), converter.toHrdProperty(value));
}
}
}
}
Aggregations