Search in sources :

Example 6 with BriefcasePreferences

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());
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) NoOpAnalytics(org.opendatakit.briefcase.ui.reused.NoOpAnalytics) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) FormStatus(org.opendatakit.briefcase.model.FormStatus) ExportConfiguration(org.opendatakit.briefcase.export.ExportConfiguration) ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) Test(org.junit.Test)

Example 7 with BriefcasePreferences

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));
}
Also used : ServerConnectionInfo(org.opendatakit.briefcase.model.ServerConnectionInfo) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusBuilder.buildFormStatus(org.opendatakit.briefcase.model.FormStatusBuilder.buildFormStatus) Test(org.junit.Test)

Example 8 with BriefcasePreferences

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());
}
Also used : LocalDateTime(java.time.LocalDateTime) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusBuilder.buildFormStatus(org.opendatakit.briefcase.model.FormStatusBuilder.buildFormStatus) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 9 with BriefcasePreferences

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));
}
Also used : BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) Test(org.junit.Test)

Aggregations

BriefcasePreferences (org.opendatakit.briefcase.model.BriefcasePreferences)9 Test (org.junit.Test)8 FormStatus (org.opendatakit.briefcase.model.FormStatus)4 TerminationFuture (org.opendatakit.briefcase.model.TerminationFuture)4 NoOpAnalytics (org.opendatakit.briefcase.ui.reused.NoOpAnalytics)4 ExportForms (org.opendatakit.briefcase.export.ExportForms)3 ConfigurationPanel (org.opendatakit.briefcase.ui.export.components.ConfigurationPanel)3 FormStatusBuilder.buildFormStatus (org.opendatakit.briefcase.model.FormStatusBuilder.buildFormStatus)2 Path (java.nio.file.Path)1 LocalDateTime (java.time.LocalDateTime)1 JFrame (javax.swing.JFrame)1 FrameFixture (org.assertj.swing.fixture.FrameFixture)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ExportConfiguration (org.opendatakit.briefcase.export.ExportConfiguration)1 ServerConnectionInfo (org.opendatakit.briefcase.model.ServerConnectionInfo)1