Search in sources :

Example 16 with FormStatus

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));
}
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 17 with FormStatus

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

Example 18 with FormStatus

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

Example 19 with FormStatus

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());
}
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 20 with FormStatus

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);
}
Also used : FormStatus(org.opendatakit.briefcase.model.FormStatus) ArrayList(java.util.ArrayList) BriefcaseFormDefinition(org.opendatakit.briefcase.model.BriefcaseFormDefinition)

Aggregations

FormStatus (org.opendatakit.briefcase.model.FormStatus)22 Test (org.junit.Test)9 FormStatusBuilder.buildFormStatus (org.opendatakit.briefcase.model.FormStatusBuilder.buildFormStatus)7 BriefcaseFormDefinition (org.opendatakit.briefcase.model.BriefcaseFormDefinition)6 File (java.io.File)4 ExportForms (org.opendatakit.briefcase.export.ExportForms)4 BriefcasePreferences (org.opendatakit.briefcase.model.BriefcasePreferences)4 TerminationFuture (org.opendatakit.briefcase.model.TerminationFuture)4 SQLException (java.sql.SQLException)3 LocalDateTime (java.time.LocalDateTime)3 FileSystemException (org.opendatakit.briefcase.model.FileSystemException)3 FormStatusEvent (org.opendatakit.briefcase.model.FormStatusEvent)3 ServerConnectionInfo (org.opendatakit.briefcase.model.ServerConnectionInfo)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors.toList (java.util.stream.Collectors.toList)2 ExportConfiguration (org.opendatakit.briefcase.export.ExportConfiguration)2