use of org.activityinfo.model.analysis.ImmutableTableModel in project activityinfo by bedatadriven.
the class TableViewModelTest method serializeModel.
@Test
public void serializeModel() {
ImmutableTableModel model = ImmutableTableModel.builder().formId(ResourceId.valueOf("MY_FORM")).addColumns(ImmutableTableColumn.builder().id("c1").label("Foo Squared").formula("foo*foo").build()).addColumns(ImmutableTableColumn.builder().id("c2").formula("foo").build()).build();
JsonValue object = model.toJson();
TableModel remodel = TableModel.fromJson(object);
assertThat(remodel.getFormId(), equalTo(model.getFormId()));
assertThat(remodel.getColumns(), hasSize(2));
assertThat(remodel.getColumns().get(0), equalTo(model.getColumns().get(0)));
assertThat(remodel.getColumns().get(1), equalTo(model.getColumns().get(1)));
}
Aggregations