Search in sources :

Example 1 with ExportForms

use of org.opendatakit.briefcase.export.ExportForms in project briefcase by opendatakit.

the class FormsTableUnitTest method appends_to_a_forms_status_history_when_export_events_are_sent.

@Test
@Ignore
public void appends_to_a_forms_status_history_when_export_events_are_sent() {
    FormStatus theForm = buildFormStatus(1);
    ExportForms forms = new ExportForms(Collections.singletonList(theForm), ExportConfiguration.empty(), new HashMap<>(), new HashMap<>(), new HashMap<>());
    TestFormsTableViewModel viewModel = new TestFormsTableViewModel(forms);
    new FormsTable(forms, new TestFormsTableView(viewModel), viewModel);
    // TODO Event publishing happens asynchronously. We have to work this test a little more to stop ignoring it
    EventBus.publish(new ExportProgressEvent("some progress", (BriefcaseFormDefinition) theForm.getFormDefinition()));
    EventBus.publish(new ExportFailedEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
    EventBus.publish(new ExportSucceededEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
    EventBus.publish(new ExportSucceededWithErrorsEvent((BriefcaseFormDefinition) theForm.getFormDefinition()));
    assertThat(theForm.getStatusHistory(), Matchers.containsString("some progress"));
    assertThat(theForm.getStatusHistory(), Matchers.containsString("Failed."));
    assertThat(theForm.getStatusHistory(), Matchers.containsString("Succeeded."));
    assertThat(theForm.getStatusHistory(), Matchers.containsString("Succeeded, but with errors."));
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormStatusBuilder.buildFormStatus(org.opendatakit.briefcase.model.FormStatusBuilder.buildFormStatus) BriefcaseFormDefinition(org.opendatakit.briefcase.model.BriefcaseFormDefinition) ExportSucceededWithErrorsEvent(org.opendatakit.briefcase.model.ExportSucceededWithErrorsEvent) ExportProgressEvent(org.opendatakit.briefcase.model.ExportProgressEvent) ExportFailedEvent(org.opendatakit.briefcase.model.ExportFailedEvent) ExportSucceededEvent(org.opendatakit.briefcase.model.ExportSucceededEvent) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with ExportForms

use of org.opendatakit.briefcase.export.ExportForms in project briefcase by opendatakit.

the class ExportPanel method from.

public static ExportPanel from(TerminationFuture terminationFuture, BriefcasePreferences exportPreferences, BriefcasePreferences appPreferences, Executor backgroundExecutor, Analytics analytics) {
    ExportConfiguration defaultConfiguration = ExportConfiguration.load(exportPreferences);
    ConfigurationPanel confPanel = ConfigurationPanel.defaultPanel(defaultConfiguration, BriefcasePreferences.getStorePasswordsConsentProperty(), true);
    ExportForms forms = ExportForms.load(defaultConfiguration, getFormsFromStorage(), exportPreferences, appPreferences);
    ExportPanelForm form = ExportPanelForm.from(forms, confPanel);
    return new ExportPanel(terminationFuture, forms, form, exportPreferences, backgroundExecutor, analytics);
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) ExportConfiguration(org.opendatakit.briefcase.export.ExportConfiguration) ConfigurationPanel(org.opendatakit.briefcase.ui.export.components.ConfigurationPanel)

Example 3 with ExportForms

use of org.opendatakit.briefcase.export.ExportForms 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 4 with ExportForms

use of org.opendatakit.briefcase.export.ExportForms 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)

Example 5 with ExportForms

use of org.opendatakit.briefcase.export.ExportForms 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)

Aggregations

ExportForms (org.opendatakit.briefcase.export.ExportForms)7 Test (org.junit.Test)6 ConfigurationPanel (org.opendatakit.briefcase.ui.export.components.ConfigurationPanel)4 BriefcasePreferences (org.opendatakit.briefcase.model.BriefcasePreferences)3 FormStatus (org.opendatakit.briefcase.model.FormStatus)3 TerminationFuture (org.opendatakit.briefcase.model.TerminationFuture)3 NoOpAnalytics (org.opendatakit.briefcase.ui.reused.NoOpAnalytics)3 ExportConfiguration (org.opendatakit.briefcase.export.ExportConfiguration)2 Ignore (org.junit.Ignore)1 BriefcaseFormDefinition (org.opendatakit.briefcase.model.BriefcaseFormDefinition)1 ExportFailedEvent (org.opendatakit.briefcase.model.ExportFailedEvent)1 ExportProgressEvent (org.opendatakit.briefcase.model.ExportProgressEvent)1 ExportSucceededEvent (org.opendatakit.briefcase.model.ExportSucceededEvent)1 ExportSucceededWithErrorsEvent (org.opendatakit.briefcase.model.ExportSucceededWithErrorsEvent)1 FormStatusBuilder.buildFormStatus (org.opendatakit.briefcase.model.FormStatusBuilder.buildFormStatus)1