use of org.opendatakit.briefcase.model.BriefcasePreferences in project briefcase by opendatakit.
the class ExportPanelUnitTest method saves_to_user_preferences_changes_on_a_custom_configuration.
@Test
public void saves_to_user_preferences_changes_on_a_custom_configuration() throws IOException {
BriefcasePreferences exportPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
BriefcasePreferences appPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
List<FormStatus> formsList = FormStatusBuilder.buildFormStatusList(10);
initialDefaultConf = ExportConfiguration.empty();
ExportForms forms = load(initialDefaultConf, formsList, exportPreferences, appPreferences);
ConfigurationPanel confPanel = ConfigurationPanel.defaultPanel(initialDefaultConf, true, true);
ExportPanelForm exportPanelForm = ExportPanelForm.from(forms, confPanel);
new ExportPanel(new TerminationFuture(), forms, exportPanelForm, exportPreferences, Runnable::run, new NoOpAnalytics());
FormStatus form = formsList.get(0);
String formId = form.getFormDefinition().getFormId();
ExportConfiguration conf = ExportConfiguration.empty();
conf.setExportDir(Paths.get(Files.createTempDirectory("briefcase_test").toUri()));
assertThat(ExportConfiguration.load(exportPreferences, buildCustomConfPrefix(formId)).getExportDir(), isEmpty());
forms.putConfiguration(form, conf);
exportPanelForm.getFormsTable().getViewModel().triggerChange();
assertThat(ExportConfiguration.load(exportPreferences, buildCustomConfPrefix(formId)).getExportDir(), isPresent());
}
use of org.opendatakit.briefcase.model.BriefcasePreferences 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.BriefcasePreferences 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.BriefcasePreferences in project briefcase by opendatakit.
the class ExportConfigurationTest 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() {
BriefcasePreferences prefs = new BriefcasePreferences(InMemoryPreferences.empty());
prefs.putAll(validConfig.asMap());
ExportConfiguration load = load(prefs);
assertThat(load, is(validConfig));
}
Aggregations