use of org.odk.collect.forms.instances.Instance in project collect by opendatakit.
the class FormMapActivityTest method tappingOnEditableInstance_showsSubmissionSummaryWithAppropriateMessage.
@Test
public void tappingOnEditableInstance_showsSubmissionSummaryWithAppropriateMessage() {
Pair<Instance, MapPoint> editableAndFinalized = new Pair<>(testInstances[1], new MapPoint(10.1, 125.6));
Pair<Instance, MapPoint> unfinalized = new Pair<>(testInstances[2], new MapPoint(10.1, 126.6));
Pair<Instance, MapPoint> failedToSend = new Pair<>(testInstances[4], new MapPoint(10.3, 125.6));
activity.onFeatureClicked(map.getFeatureIdFor(editableAndFinalized.second));
assertSubmissionSummaryContent(editableAndFinalized.first.getDisplayName(), editableAndFinalized.first.getStatus(), new Date(editableAndFinalized.first.getLastStatusChangeDate()), OPEN_EDIT);
activity.onFeatureClicked(map.getFeatureIdFor(unfinalized.second));
assertSubmissionSummaryContent(unfinalized.first.getDisplayName(), unfinalized.first.getStatus(), new Date(unfinalized.first.getLastStatusChangeDate()), OPEN_EDIT);
activity.onFeatureClicked(map.getFeatureIdFor(failedToSend.second));
assertSubmissionSummaryContent(failedToSend.first.getDisplayName(), failedToSend.first.getStatus(), new Date(failedToSend.first.getLastStatusChangeDate()), OPEN_READ_ONLY);
}
use of org.odk.collect.forms.instances.Instance in project collect by opendatakit.
the class FormMapActivityTest method tappingOnFailedSubmission_showsSubmissionSummaryWithAppropriateMessage.
@Test
public void tappingOnFailedSubmission_showsSubmissionSummaryWithAppropriateMessage() {
Pair<Instance, MapPoint> submissionFailedCantEditWhenFinalized = new Pair<>(testInstances[6], new MapPoint(10.4, 125.6));
int featureId = map.getFeatureIdFor(submissionFailedCantEditWhenFinalized.second);
activity.onFeatureClicked(featureId);
assertSubmissionSummaryContent(submissionFailedCantEditWhenFinalized.first.getDisplayName(), submissionFailedCantEditWhenFinalized.first.getStatus(), new Date(submissionFailedCantEditWhenFinalized.first.getLastStatusChangeDate()), NOT_VIEWABLE_TOAST);
}
use of org.odk.collect.forms.instances.Instance in project collect by opendatakit.
the class InstanceDeleterTest method whenFormForInstanceIsNotSoftDeleted_andThereAreNoOtherInstances_doesNotDeleteForm.
@Test
public void whenFormForInstanceIsNotSoftDeleted_andThereAreNoOtherInstances_doesNotDeleteForm() {
formsRepository.save(new Form.Builder().formId("1").version("version").deleted(false).formFilePath(FormUtils.createXFormFile("1", "version").getAbsolutePath()).build());
Instance instanceToDelete = instancesRepository.save(new Instance.Builder().formId("1").formVersion("version").instanceFilePath(TempFiles.createTempDir().getAbsolutePath()).build());
instanceDeleter.delete(instanceToDelete.getDbId());
assertThat(formsRepository.getAll().size(), is(1));
}
use of org.odk.collect.forms.instances.Instance in project collect by opendatakit.
the class InstanceDeleterTest method whenFormVersionForInstanceIsNotSoftDeleted_andThereAreNoOtherInstances_doesNotDeleteForm.
@Test
public void whenFormVersionForInstanceIsNotSoftDeleted_andThereAreNoOtherInstances_doesNotDeleteForm() {
formsRepository.save(new Form.Builder().formId("1").version("1").deleted(true).formFilePath(FormUtils.createXFormFile("1", "1").getAbsolutePath()).build());
formsRepository.save(new Form.Builder().formId("1").version("2").deleted(false).formFilePath(FormUtils.createXFormFile("1", "2").getAbsolutePath()).build());
Instance instanceToDelete = instancesRepository.save(new Instance.Builder().formId("1").formVersion("2").instanceFilePath(TempFiles.createTempDir().getAbsolutePath()).build());
instanceDeleter.delete(instanceToDelete.getDbId());
assertThat(formsRepository.getAll().size(), is(2));
}
use of org.odk.collect.forms.instances.Instance in project collect by opendatakit.
the class InstanceDeleterTest method whenFormForInstanceIsSoftDeleted_andThereAreNoOtherInstancesForThisVersion_deletesForm.
@Test
public void whenFormForInstanceIsSoftDeleted_andThereAreNoOtherInstancesForThisVersion_deletesForm() {
formsRepository.save(new Form.Builder().formId("1").version("1").deleted(true).formFilePath(FormUtils.createXFormFile("1", "1").getAbsolutePath()).build());
formsRepository.save(new Form.Builder().formId("1").version("2").formFilePath(FormUtils.createXFormFile("1", "2").getAbsolutePath()).deleted(true).build());
Instance instanceToDelete = instancesRepository.save(new Instance.Builder().formId("1").formVersion("1").instanceFilePath(TempFiles.createTempDir().getAbsolutePath()).build());
instancesRepository.save(new Instance.Builder().formId("1").formVersion("2").instanceFilePath(TempFiles.createTempDir().getAbsolutePath()).build());
instanceDeleter.delete(instanceToDelete.getDbId());
assertThat(formsRepository.getAll().size(), is(1));
assertThat(formsRepository.getAll().get(0).getVersion(), is("2"));
}
Aggregations