use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.
the class FormMapViewModelTest method clearingInstanceGeometry_isReflectedInInstanceCountsAndList.
@Test
public void clearingInstanceGeometry_isReflectedInInstanceCountsAndList() {
FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
List<FormMapViewModel.MappableFormInstance> mappableInstances = viewModel.getMappableFormInstances();
assertThat(viewModel.getTotalInstanceCount(), is(7));
assertThat(mappableInstances.size(), is(6));
assertThat(mappableInstances.get(5).getClickAction(), is(FormMapViewModel.ClickAction.NOT_VIEWABLE_TOAST));
((InMemInstancesRepository) testInstancesRepository).removeInstanceById(6L);
((InMemInstancesRepository) testInstancesRepository).save(new Instance.Builder().dbId(6L).formId("formId1").formVersion("2019103101").geometryType("").geometry("").canEditWhenComplete(false).status(Instance.STATUS_SUBMISSION_FAILED).build());
mappableInstances = viewModel.getMappableFormInstances();
assertThat(viewModel.getTotalInstanceCount(), is(7));
assertThat(mappableInstances.size(), is(5));
assertThat(mappableInstances.get(4).getClickAction(), is(FormMapViewModel.ClickAction.OPEN_READ_ONLY));
}
use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.
the class FormMapViewModelTest method deletedInstance_hasDeletedClickAction.
// Should not actually be possible from UI because geometry is deleted on sent instance delete
@Test
public void deletedInstance_hasDeletedClickAction() {
FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
List<FormMapViewModel.MappableFormInstance> instances = viewModel.getMappableFormInstances();
assertThat(instances.get(0).getClickAction(), is(FormMapViewModel.ClickAction.DELETED_TOAST));
}
use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.
the class FormMapViewModelTest method addingAnInstance_isReflectedInInstanceCountsAndList.
@Test
public void addingAnInstance_isReflectedInInstanceCountsAndList() {
FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
List<FormMapViewModel.MappableFormInstance> instances = viewModel.getMappableFormInstances();
assertThat(viewModel.getTotalInstanceCount(), is(7));
assertThat(instances.size(), is(6));
Instance newInstance = new Instance.Builder().dbId(8L).formId("formId1").formVersion("2019103101").geometryType("Point").geometry("{\"type\":\"Point\",\"coordinates\":[127.6, 11.1]}").canEditWhenComplete(true).status(Instance.STATUS_COMPLETE).build();
((InMemInstancesRepository) testInstancesRepository).save(newInstance);
instances = viewModel.getMappableFormInstances();
assertThat(viewModel.getTotalInstanceCount(), is(8));
assertThat(instances.size(), is(7));
assertThat(instances.get(6).getClickAction(), is(FormMapViewModel.ClickAction.OPEN_EDIT));
}
use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.
the class FormMapViewModelTest method getDeletedDateOf_returnsDeletedDate.
@Test
public void getDeletedDateOf_returnsDeletedDate() {
FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
assertThat(viewModel.getDeletedDateOf(0L), is(testInstances[0].getDeletedDate()));
}
use of org.odk.collect.android.activities.viewmodels.FormMapViewModel in project collect by opendatakit.
the class FormMapViewModelTest method getTotalInstanceCount_returnsCountOfAllInstances.
@Test
public void getTotalInstanceCount_returnsCountOfAllInstances() {
FormMapViewModel viewModel = new FormMapViewModel(TEST_FORM_1, testInstancesRepository);
assertThat(viewModel.getTotalInstanceCount(), is(7));
}
Aggregations