use of org.activityinfo.ui.client.store.TestingFormStore in project activityinfo by bedatadriven.
the class AnalysisViewModelTest method testEmptyModel.
@Test
public void testEmptyModel() {
TestingFormStore formStore = new TestingFormStore();
AnalysisViewModel model = new AnalysisViewModel(formStore);
AnalysisResult result = assertLoads(model.getResultTable());
PivotTable pivotTable = assertLoads(model.getPivotTable());
assertTrue(pivotTable.isEmpty());
}
use of org.activityinfo.ui.client.store.TestingFormStore in project activityinfo by bedatadriven.
the class FormInputViewModelTest method testSurveyEdit.
@Test
public void testSurveyEdit() {
TestingFormStore store = new TestingFormStore();
Survey survey = store.getCatalog().getSurvey();
RecordRef recordRef = survey.getRecordRef(5);
FormStructure stucture = fetchStructure(recordRef);
FormInputViewModelBuilder builder = new FormInputViewModelBuilder(store, stucture.getFormTree(), new TestingActivePeriodMemory());
FormInputModel inputModel = new FormInputModel(new RecordRef(survey.getFormId(), ResourceId.generateId()));
FormInputViewModel viewModel = builder.build(inputModel, stucture.getExistingRecord());
assertTrue(viewModel.isValid());
}
use of org.activityinfo.ui.client.store.TestingFormStore in project activityinfo by bedatadriven.
the class FormInputViewModelTest method testNewlyIrrelvantFieldSetToEmpty.
@Test
public void testNewlyIrrelvantFieldSetToEmpty() {
TestingFormStore store = new TestingFormStore();
Survey survey = store.getCatalog().getSurvey();
RecordRef recordRef = survey.getRecordRef(8);
FormStructure structure = fetchStructure(recordRef);
FormInputViewModelBuilder builder = new FormInputViewModelBuilder(store, structure.getFormTree(), new TestingActivePeriodMemory());
FormInputModel inputModel = new FormInputModel(new RecordRef(survey.getFormId(), ResourceId.generateId()));
// The record was saved as GENDER=Female, and PREGNANT=No
FormInputViewModel viewModel = builder.build(inputModel, structure.getExistingRecord());
assertThat(viewModel.getField(survey.getGenderFieldId()), equalTo(new EnumValue(survey.getFemaleId())));
assertThat(viewModel.isRelevant(survey.getPregnantFieldId()), equalTo(true));
assertThat(viewModel.getField(survey.getPregnantFieldId()), equalTo(new EnumValue(survey.getPregnantNo())));
// When we change the Gender to Male, then PREGNANT should be set to empty
inputModel = inputModel.update(survey.getGenderFieldId(), new EnumValue(survey.getMaleId()));
viewModel = builder.build(inputModel, structure.getExistingRecord());
assertThat(viewModel.isRelevant(survey.getPregnantFieldId()), equalTo(false));
RecordTransaction tx = viewModel.buildTransaction();
assertThat(tx.getChangeArray(), arrayWithSize(1));
RecordUpdate update = tx.getChanges().iterator().next();
assertTrue(update.getFields().get(survey.getPregnantFieldId().asString()).isJsonNull());
}
use of org.activityinfo.ui.client.store.TestingFormStore in project activityinfo by bedatadriven.
the class MeasureListItemStoreTest method setup.
@Before
public void setup() {
LocaleProxy.initialize();
formStore = new TestingFormStore();
}
use of org.activityinfo.ui.client.store.TestingFormStore in project activityinfo by bedatadriven.
the class AnalysisViewModelTest method setup.
@Before
public void setup() {
LocaleProxy.initialize();
formStore = new TestingFormStore();
survey = formStore.getCatalog().getSurvey();
intakeForm = formStore.getCatalog().getIntakeForm();
}
Aggregations