use of org.odk.collect.forms.Form in project collect by opendatakit.
the class FormsRepositoryTest method getAllFormId_returnsMatchingForms.
@Test
public void getAllFormId_returnsMatchingForms() {
FormsRepository formsRepository = buildSubject();
Form form1 = formsRepository.save(FormUtils.buildForm("id1", "version", getFormFilesPath()).build());
Form form2 = formsRepository.save(FormUtils.buildForm("id1", "other_version", getFormFilesPath()).build());
formsRepository.save(FormUtils.buildForm("id2", "version", getFormFilesPath()).build());
List<Form> forms = formsRepository.getAllByFormId("id1");
assertThat(forms.size(), is(2));
assertThat(forms, contains(form1, form2));
}
use of org.odk.collect.forms.Form in project collect by opendatakit.
the class FormsRepositoryTest method getOneByPath_returnsMatchingForm.
@Test
public void getOneByPath_returnsMatchingForm() {
FormsRepository formsRepository = buildSubject();
formsRepository.save(FormUtils.buildForm("id1", "version", getFormFilesPath()).build());
Form form2 = FormUtils.buildForm("id2", "version", getFormFilesPath()).build();
formsRepository.save(form2);
assertThat(formsRepository.getOneByPath(form2.getFormFilePath()).getFormId(), is("id2"));
}
use of org.odk.collect.forms.Form in project collect by opendatakit.
the class FormsRepositoryTest method getLatestByFormIdAndVersion_whenFormHasNullVersion_returnsForm.
@Test
public void getLatestByFormIdAndVersion_whenFormHasNullVersion_returnsForm() {
FormsRepository formsRepository = buildSubject();
formsRepository.save(FormUtils.buildForm("1", null, getFormFilesPath()).build());
Form form = formsRepository.getLatestByFormIdAndVersion("1", null);
assertThat(form, notNullValue());
assertThat(form.getDbId(), is(1L));
}
use of org.odk.collect.forms.Form in project collect by opendatakit.
the class InMemFormsRepository method restore.
@Override
public void restore(Long id) {
Form form = forms.stream().filter(f -> f.getDbId().equals(id)).findFirst().orElse(null);
if (form != null) {
forms.remove(form);
forms.add(new Form.Builder(form).deleted(false).build());
}
}
use of org.odk.collect.forms.Form in project collect by opendatakit.
the class InMemFormsRepository method softDelete.
@Override
public void softDelete(Long id) {
Form form = forms.stream().filter(f -> f.getDbId().equals(id)).findFirst().orElse(null);
if (form != null) {
forms.remove(form);
forms.add(new Form.Builder(form).deleted(true).build());
}
}
Aggregations