use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class ExportFormsTest method the_factory_tries_to_load_any_transfer_settings_found_in_preferences.
@Test
public void the_factory_tries_to_load_any_transfer_settings_found_in_preferences() {
ServerConnectionInfo expectedTransferSettings = new ServerConnectionInfo("http://some/url", "some username", "some password".toCharArray());
FormStatus formWithTransferSettings = buildFormStatus(1);
FormStatus formWithoutTransferSettings = buildFormStatus(2);
List<FormStatus> formsList = Arrays.asList(formWithTransferSettings, formWithoutTransferSettings);
BriefcasePreferences exportPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
BriefcasePreferences appPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
appPreferences.put(String.format("%s_pull_settings_url", formWithTransferSettings.getFormDefinition().getFormId()), expectedTransferSettings.getUrl());
appPreferences.put(String.format("%s_pull_settings_username", formWithTransferSettings.getFormDefinition().getFormId()), expectedTransferSettings.getUsername());
appPreferences.put(String.format("%s_pull_settings_password", formWithTransferSettings.getFormDefinition().getFormId()), String.valueOf(expectedTransferSettings.getPassword()));
ExportForms forms = ExportForms.load(ExportConfiguration.empty(), formsList, exportPreferences, appPreferences);
assertThat(forms.getTransferSettings(formWithoutTransferSettings.getFormDefinition().getFormId()), isEmpty());
assertThat(forms.getTransferSettings(formWithTransferSettings.getFormDefinition().getFormId()), isPresentAndIs(expectedTransferSettings));
}
use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class ExportFormsTest method when_there_is_a_status_history_update_thats_been_successful_it_registers_an_export_date.
@Test
public void when_there_is_a_status_history_update_thats_been_successful_it_registers_an_export_date() {
ExportForms forms = new ExportForms(buildFormStatusList(10), ExportConfiguration.empty(), new HashMap<>(), new HashMap<>(), new HashMap<>());
FormStatus form = forms.get(0);
assertThat(forms.getLastExportDateTime(form), isEmpty());
forms.appendStatus(form.getFormDefinition(), "some status update", true);
assertThat(forms.getLastExportDateTime(form), isPresent());
}
use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class ExportFormsTest method knows_if_all_selected_forms_have_a_valid_configuration.
@Test
public void knows_if_all_selected_forms_have_a_valid_configuration() {
ExportForms forms = new ExportForms(buildFormStatusList(10), ExportConfiguration.empty(), new HashMap<>(), new HashMap<>(), new HashMap<>());
FormStatus form = forms.get(0);
form.setSelected(true);
assertThat(forms.allSelectedFormsHaveConfiguration(), is(false));
forms.putConfiguration(form, VALID_CONFIGURATION);
assertThat(forms.allSelectedFormsHaveConfiguration(), is(true));
}
use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class ExportFormsTest method it_has_a_factory_that_creates_a_new_instance_from_saved_preferences.
@Test
public void it_has_a_factory_that_creates_a_new_instance_from_saved_preferences() {
LocalDateTime exportDateTime = LocalDateTime.now();
List<FormStatus> formsList = buildFormStatusList(10);
FormStatus form = formsList.get(0);
String formId = form.getFormDefinition().getFormId();
BriefcasePreferences exportPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
exportPreferences.putAll(VALID_CONFIGURATION.asMap(buildCustomConfPrefix(formId)));
exportPreferences.put(ExportForms.buildExportDateTimePrefix(formId), exportDateTime.format(ISO_DATE_TIME));
BriefcasePreferences appPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
ExportForms forms = ExportForms.load(ExportConfiguration.empty(), formsList, exportPreferences, appPreferences);
assertThat(forms.size(), is(10));
assertThat(forms.hasConfiguration(form), is(true));
assertThat(forms.getLastExportDateTime(form), isPresent());
}
use of org.opendatakit.briefcase.model.FormStatus in project briefcase by opendatakit.
the class PushTransferPanel method updateFormStatuses.
public void updateFormStatuses() {
List<FormStatus> statuses = new ArrayList<>();
List<BriefcaseFormDefinition> forms = FileSystemUtils.getBriefcaseFormList();
for (BriefcaseFormDefinition f : forms) {
statuses.add(new FormStatus(FormStatus.TransferType.UPLOAD, f));
}
formTransferTable.setFormStatusList(statuses);
}
Aggregations