use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class EnumTypeTest method deserializationEnumTypeNoChoices.
@Test
public void deserializationEnumTypeNoChoices() {
EnumType type = new EnumType(Cardinality.SINGLE, EnumType.Presentation.AUTOMATIC, Collections.<EnumItem>emptyList());
JsonValue jsonObject = type.getParametersAsJson();
EnumType reType = EnumType.TYPE_CLASS.deserializeType(jsonObject);
assertThat(reType.getCardinality(), equalTo(Cardinality.SINGLE));
assertThat(reType.getPresentation(), equalTo(EnumType.Presentation.AUTOMATIC));
assertThat(reType.getValues(), hasSize(0));
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class CalculatedFieldTypeTest method emptySerialization.
@Test
public void emptySerialization() {
FormField field = new FormField(ResourceId.generateId());
field.setType(new CalculatedFieldType());
JsonValue record = field.toJsonObject();
System.out.println(record.toJson());
FormField read = FormField.fromJson(record);
assertThat(read.getType(), instanceOf(CalculatedFieldType.class));
CalculatedFieldType readType = (CalculatedFieldType) read.getType();
assertThat(readType.getExpression(), nullValue());
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class CalculatedFieldTypeTest method serialization.
@Test
public void serialization() {
FormField field = new FormField(ResourceId.generateId());
field.setType(new CalculatedFieldType("A+B"));
JsonValue record = field.toJsonObject();
System.out.println(record.toJson());
FormField read = FormField.fromJson(record);
assertThat(read.getType(), instanceOf(CalculatedFieldType.class));
CalculatedFieldType readType = (CalculatedFieldType) read.getType();
assertThat(readType.getExpression(), equalTo("A+B"));
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class QuantityTypeTest method parseResource.
private FormClass parseResource() throws IOException {
URL resource = Resources.getResource(FormClass.class, "OldFormClass2.json");
String json = Resources.toString(resource, Charsets.UTF_8);
JsonValue element = Json.parse(json);
return FormClass.fromJson(element);
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class SubFormReferenceType method getParametersAsJson.
@Override
public JsonValue getParametersAsJson() {
JsonValue object = createObject();
object.put("formId", classId == null ? Json.createNull() : Json.create(classId.asString()));
return object;
}
Aggregations