Search in sources :

Example 1 with BriefcasePreferences

use of org.opendatakit.briefcase.model.BriefcasePreferences in project briefcase by opendatakit.

the class ExportConfigurationTest method the_factory_can_load_prefixed_keys_on_saved_preferences.

@Test
public void the_factory_can_load_prefixed_keys_on_saved_preferences() {
    BriefcasePreferences prefs = new BriefcasePreferences(InMemoryPreferences.empty());
    prefs.putAll(validConfig.asMap("some_prefix"));
    ExportConfiguration load = load(prefs, "some_prefix");
    assertThat(load, is(validConfig));
}
Also used : BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) Test(org.junit.Test)

Example 2 with BriefcasePreferences

use of org.opendatakit.briefcase.model.BriefcasePreferences in project briefcase by opendatakit.

the class ExportPanelUnitTest method saves_to_user_preferences_changes_on_the_default_configuration.

@Test
public void saves_to_user_preferences_changes_on_the_default_configuration() throws IOException {
    BriefcasePreferences exportPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
    BriefcasePreferences appPreferences = new BriefcasePreferences(InMemoryPreferences.empty());
    initialDefaultConf = ExportConfiguration.empty();
    ExportForms forms = load(initialDefaultConf, new ArrayList<>(), exportPreferences, appPreferences);
    ConfigurationPanel confPanel = ConfigurationPanel.defaultPanel(initialDefaultConf, false, true);
    new ExportPanel(new TerminationFuture(), forms, ExportPanelForm.from(forms, confPanel), exportPreferences, Runnable::run, new NoOpAnalytics());
    assertThat(ExportConfiguration.load(exportPreferences).getExportDir(), isEmpty());
    confPanel.getForm().setExportDir(Paths.get(Files.createTempDirectory("briefcase_test").toUri()));
    assertThat(ExportConfiguration.load(exportPreferences).getExportDir(), isPresent());
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) NoOpAnalytics(org.opendatakit.briefcase.ui.reused.NoOpAnalytics) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) Test(org.junit.Test)

Example 3 with BriefcasePreferences

use of org.opendatakit.briefcase.model.BriefcasePreferences in project briefcase by opendatakit.

the class StorageLocationTest method canEstablishStorageLocation.

@Test
public void canEstablishStorageLocation() throws IOException {
    BriefcasePreferences bp = mock(BriefcasePreferences.class);
    final Path tempPath = Files.createTempDirectory("xxxx");
    when(bp.getBriefcaseDirectoryOrNull()).thenReturn(tempPath.toString());
    UiStateChangeListener uscl = mock(UiStateChangeListener.class);
    StorageLocation sl = new StorageLocation(bp);
    sl.establishBriefcaseStorageLocation(null, uscl);
    verify(uscl, times(1)).setFullUIEnabled(true);
}
Also used : Path(java.nio.file.Path) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) Test(org.junit.Test)

Example 4 with BriefcasePreferences

use of org.opendatakit.briefcase.model.BriefcasePreferences in project briefcase by opendatakit.

the class ExportPanelPageObject method setUp.

static ExportPanelPageObject setUp(Robot robot) {
    ExportPanel exportPanel = GuiActionRunner.execute(() -> {
        ExportPanel ep = ExportPanel.from(new TerminationFuture(), new BriefcasePreferences(InMemoryPreferences.empty()), new BriefcasePreferences(InMemoryPreferences.empty()), Runnable::run, new NoOpAnalytics());
        ep.updateForms();
        return ep;
    });
    JFrame testFrame = GuiActionRunner.execute(() -> {
        JFrame f = new JFrame();
        f.add(exportPanel.getForm().getContainer());
        return f;
    });
    FrameFixture window = new FrameFixture(robot, testFrame);
    return new ExportPanelPageObject(exportPanel, window);
}
Also used : NoOpAnalytics(org.opendatakit.briefcase.ui.reused.NoOpAnalytics) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) JFrame(javax.swing.JFrame) FrameFixture(org.assertj.swing.fixture.FrameFixture) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture)

Example 5 with BriefcasePreferences

use of org.opendatakit.briefcase.model.BriefcasePreferences in project briefcase by opendatakit.

the class ExportPanelUnitTest method saves_to_user_preferences_the_last_successful_export_date_for_a_form.

@Test
public void saves_to_user_preferences_the_last_successful_export_date_for_a_form() {
    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);
    new ExportPanel(new TerminationFuture(), forms, ExportPanelForm.from(forms, confPanel), exportPreferences, Runnable::run, new NoOpAnalytics());
    FormStatus form = formsList.get(0);
    String formId = form.getFormDefinition().getFormId();
    assertThat(exportPreferences.nullSafeGet(buildExportDateTimePrefix(formId)), isEmpty());
    forms.appendStatus(form.getFormDefinition(), "some status update", true);
    assertThat(exportPreferences.nullSafeGet(buildExportDateTimePrefix(formId)), 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) ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel) TerminationFuture(org.opendatakit.briefcase.model.TerminationFuture) 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