use of org.odk.collect.forms.FormsRepository in project collect by opendatakit.
the class FormsRepositoryTest method getAllByFormIdAndVersion_whenFormHasNullVersion_returnsAllMatchingForms.
@Test
public void getAllByFormIdAndVersion_whenFormHasNullVersion_returnsAllMatchingForms() {
FormsRepository formsRepository = buildSubject();
formsRepository.save(FormUtils.buildForm("1", null, getFormFilesPath()).build());
formsRepository.save(FormUtils.buildForm("1", null, getFormFilesPath()).build());
formsRepository.save(FormUtils.buildForm("1", "7", getFormFilesPath()).build());
List<Form> forms = formsRepository.getAllByFormIdAndVersion("1", null);
assertThat(forms.size(), is(2));
assertThat(forms.get(0).getVersion(), is(nullValue()));
assertThat(forms.get(1).getVersion(), is(nullValue()));
}
use of org.odk.collect.forms.FormsRepository in project collect by opendatakit.
the class FormsRepositoryTest method deleteByMd5Hash_deletesFormsWithMatchingHash.
@Test
public void deleteByMd5Hash_deletesFormsWithMatchingHash() {
FormsRepository formsRepository = buildSubject();
formsRepository.save(FormUtils.buildForm("id1", "version", getFormFilesPath()).build());
formsRepository.save(FormUtils.buildForm("id1", "version", getFormFilesPath()).build());
formsRepository.save(FormUtils.buildForm("id2", "version", getFormFilesPath()).build());
List<Form> id1Forms = formsRepository.getAllByFormIdAndVersion("id1", "version");
assertThat(id1Forms.size(), is(2));
assertThat(id1Forms.get(0).getMD5Hash(), is(id1Forms.get(1).getMD5Hash()));
formsRepository.deleteByMd5Hash(id1Forms.get(0).getMD5Hash());
assertThat(formsRepository.getAll().size(), is(1));
assertThat(formsRepository.getAll().get(0).getFormId(), is("id2"));
}
use of org.odk.collect.forms.FormsRepository in project collect by opendatakit.
the class FormsRepositoryTest method restore_marksDeletedAsFalse.
@Test
public void restore_marksDeletedAsFalse() {
FormsRepository formsRepository = buildSubject();
formsRepository.save(FormUtils.buildForm("1", null, getFormFilesPath()).deleted(true).build());
formsRepository.restore(1L);
assertThat(formsRepository.get(1L).isDeleted(), is(false));
}
use of org.odk.collect.forms.FormsRepository in project collect by opendatakit.
the class FormsRepositoryTest method getAllNotDeletedByFormId_doesNotReturnDeletedForms.
@Test
public void getAllNotDeletedByFormId_doesNotReturnDeletedForms() {
FormsRepository formsRepository = buildSubject();
formsRepository.save(FormUtils.buildForm("1", "deleted", getFormFilesPath()).deleted(true).build());
formsRepository.save(FormUtils.buildForm("1", "not-deleted", getFormFilesPath()).deleted(false).build());
List<Form> forms = formsRepository.getAllNotDeletedByFormId("1");
assertThat(forms.size(), is(1));
assertThat(forms.get(0).getVersion(), equalTo("not-deleted"));
}
use of org.odk.collect.forms.FormsRepository in project collect by opendatakit.
the class FormsRepositoryTest method save_addsId.
@Test
public void save_addsId() {
FormsRepository formsRepository = buildSubject();
Form form = FormUtils.buildForm("id", "version", getFormFilesPath()).build();
formsRepository.save(form);
assertThat(formsRepository.getAll().get(0).getDbId(), notNullValue());
}
Aggregations