Search in sources :

Example 1 with ImmutableTableModel

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)));
}
Also used : JsonValue(org.activityinfo.json.JsonValue) ImmutableTableModel(org.activityinfo.model.analysis.ImmutableTableModel) TableModel(org.activityinfo.model.analysis.TableModel) ImmutableTableModel(org.activityinfo.model.analysis.ImmutableTableModel) Test(org.junit.Test)

Aggregations

JsonValue (org.activityinfo.json.JsonValue)1 ImmutableTableModel (org.activityinfo.model.analysis.ImmutableTableModel)1 TableModel (org.activityinfo.model.analysis.TableModel)1 Test (org.junit.Test)1