Search in sources :

Example 1 with FakeHttp

use of org.opendatakit.briefcase.reused.http.FakeHttp in project briefcase by opendatakit.

the class PushToCentralTest method setUp.

@Before
public void setUp() throws IOException {
    http = new FakeHttp();
    briefcaseDir = createTempDirectory("briefcase-test-");
    pushOp = new PushToCentral(http, server, briefcaseDir, token, this::onEvent);
    events = new ArrayList<>();
    runnerStatus = new TestRunnerStatus(false);
    tracker = new PushToCentralTracker(formStatus, this::onEvent);
    form = installForm(formStatus, getResourcePath("/org/opendatakit/briefcase/push/aggregate/push-form-test.xml"), briefcaseDir);
    formAttachment = installFormAttachment(formStatus, getResourcePath("/org/opendatakit/briefcase/push/aggregate/sparrow.png"), briefcaseDir);
    submission = installSubmission(formStatus, getResourcePath("/org/opendatakit/briefcase/push/aggregate/submission.xml"), briefcaseDir);
    submissionAttachment = installSubmissionAttachment(formStatus, getResourcePath("/org/opendatakit/briefcase/push/aggregate/1556532531101.jpg"), briefcaseDir, instanceId);
    formMetadataPort = new InMemoryFormMetadataAdapter();
    FormKey key = FormKey.from(formStatus);
    FormMetadata metadata = FormMetadata.of(key, formStatus.getFormDir(briefcaseDir), briefcaseDir);
    formMetadataPort.persist(metadata);
}
Also used : TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) FakeHttp(org.opendatakit.briefcase.reused.http.FakeHttp) FormKey(org.opendatakit.briefcase.model.form.FormKey) FormMetadata(org.opendatakit.briefcase.model.form.FormMetadata) Before(org.junit.Before)

Example 2 with FakeHttp

use of org.opendatakit.briefcase.reused.http.FakeHttp 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 {
    List<FormStatus> formsList = new ArrayList<>();
    BriefcasePreferences inMemoryPrefs = new BriefcasePreferences(InMemoryPreferences.empty());
    initialDefaultConf = empty().build();
    ExportForms forms = load(initialDefaultConf, formsList, inMemoryPrefs);
    ExportPanelForm exportPanelForm = ExportPanelForm.from(forms, inMemoryPrefs, inMemoryPrefs, initialDefaultConf);
    new ExportPanel(forms, exportPanelForm, inMemoryPrefs, inMemoryPrefs, inMemoryPrefs, new NoOpAnalytics(), FormCache.empty(), new FakeHttp(), new InMemoryFormMetadataAdapter());
    exportPanelForm.setDefaultConf(empty().setExportDir(Paths.get(Files.createTempDirectory("briefcase_test").toUri())).build());
    assertThat(load(inMemoryPrefs).getExportDir(), notNullValue());
}
Also used : ExportForms(org.opendatakit.briefcase.export.ExportForms) NoOpAnalytics(org.opendatakit.briefcase.ui.reused.NoOpAnalytics) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) FormStatus(org.opendatakit.briefcase.model.FormStatus) ArrayList(java.util.ArrayList) FakeHttp(org.opendatakit.briefcase.reused.http.FakeHttp) Test(org.junit.Test)

Example 3 with FakeHttp

use of org.opendatakit.briefcase.reused.http.FakeHttp in project briefcase by opendatakit.

the class BriefcaseVersionManagerTest method knows_if_we_are_up_to_date.

@Test
public void knows_if_we_are_up_to_date() {
    FakeHttp http = new FakeHttp();
    http.stub(get(url("https://api.github.com/repos/getodk/briefcase/releases/latest")).build(), ResponseHelpers.ok("{\"tag_name\":\"v2.0.0\"}"));
    BriefcaseVersionManager versionManager = new BriefcaseVersionManager(http, "v2.0.0");
    assertThat(versionManager.isUpToDate(), is(true));
}
Also used : FakeHttp(org.opendatakit.briefcase.reused.http.FakeHttp) Test(org.junit.Test)

Example 4 with FakeHttp

use of org.opendatakit.briefcase.reused.http.FakeHttp in project briefcase by opendatakit.

the class BriefcaseVersionManagerTest method knows_if_we_are_not_up_to_date.

@Test
public void knows_if_we_are_not_up_to_date() {
    FakeHttp http = new FakeHttp();
    http.stub(get(url("https://api.github.com/repos/getodk/briefcase/releases/latest")).build(), ResponseHelpers.ok("{\"tag_name\":\"v2.0.0\"}"));
    BriefcaseVersionManager versionManager = new BriefcaseVersionManager(http, "v1.6.0");
    assertThat(versionManager.isUpToDate(), is(false));
}
Also used : FakeHttp(org.opendatakit.briefcase.reused.http.FakeHttp) Test(org.junit.Test)

Example 5 with FakeHttp

use of org.opendatakit.briefcase.reused.http.FakeHttp in project briefcase by opendatakit.

the class PullFromAggregateTest method init.

@Before
public void init() throws IOException {
    Files.createDirectories(briefcaseDir);
    prefs = new BriefcasePreferences(InMemoryPreferences.empty());
    prefs.setStorageDir(tmpDir);
    http = new FakeHttp();
    events = new ArrayList<>();
    tracker = new PullFromAggregateTracker(form, e -> events.add(e.getStatusString()));
    pullOp = new PullFromAggregate(http, server, briefcaseDir, includeIncomplete, e -> {
    }, new InMemoryFormMetadataAdapter());
    runnerStatus = new TestRunnerStatus(false);
}
Also used : InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) UncheckedFiles.deleteRecursive(org.opendatakit.briefcase.reused.UncheckedFiles.deleteRecursive) FakeHttp(org.opendatakit.briefcase.reused.http.FakeHttp) RequestBuilder.url(org.opendatakit.briefcase.reused.http.RequestBuilder.url) Matchers.not(org.hamcrest.Matchers.not) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) TransferTestHelpers.buildFormStatus(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildFormStatus) InMemoryPreferences(org.opendatakit.briefcase.model.InMemoryPreferences) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) PathMatchers(org.opendatakit.briefcase.matchers.PathMatchers) Files.readAllBytes(java.nio.file.Files.readAllBytes) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) After(org.junit.After) AggregateServer(org.opendatakit.briefcase.reused.transfer.AggregateServer) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Pair(org.opendatakit.briefcase.reused.Pair) TransferTestHelpers.buildAggregateSubmissionDownloadXml(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildAggregateSubmissionDownloadXml) Path(java.nio.file.Path) RequestSpyMatchers.hasBeenCalled(org.opendatakit.briefcase.reused.http.RequestSpyMatchers.hasBeenCalled) Before(org.junit.Before) TransferTestHelpers.buildMediaFiles(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildMediaFiles) FormStatus(org.opendatakit.briefcase.model.FormStatus) TransferTestHelpers.buildManifestXml(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildManifestXml) Files(java.nio.file.Files) ResponseHelpers.ok(org.opendatakit.briefcase.reused.http.response.ResponseHelpers.ok) TransferTestHelpers.buildBlankFormXml(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildBlankFormXml) IOException(java.io.IOException) Test(org.junit.Test) TransferTestHelpers.generatePages(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.generatePages) UncheckedFiles.createTempDirectory(org.opendatakit.briefcase.reused.UncheckedFiles.createTempDirectory) RequestSpy(org.opendatakit.briefcase.reused.http.RequestSpy) List(java.util.List) Matchers.hasItem(org.hamcrest.Matchers.hasItem) Matchers.contains(org.hamcrest.Matchers.contains) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) RequestBuilder.get(org.opendatakit.briefcase.reused.http.RequestBuilder.get) XmlElement(org.opendatakit.briefcase.export.XmlElement) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) FakeHttp(org.opendatakit.briefcase.reused.http.FakeHttp) Before(org.junit.Before)

Aggregations

FakeHttp (org.opendatakit.briefcase.reused.http.FakeHttp)11 Test (org.junit.Test)8 InMemoryFormMetadataAdapter (org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter)7 BriefcasePreferences (org.opendatakit.briefcase.model.BriefcasePreferences)5 FormStatus (org.opendatakit.briefcase.model.FormStatus)5 Before (org.junit.Before)4 TestRunnerStatus (org.opendatakit.briefcase.reused.job.TestRunnerStatus)4 NoOpAnalytics (org.opendatakit.briefcase.ui.reused.NoOpAnalytics)4 ArrayList (java.util.ArrayList)3 ExportForms (org.opendatakit.briefcase.export.ExportForms)3 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 List (java.util.List)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Matchers.contains (org.hamcrest.Matchers.contains)2 Matchers.hasItem (org.hamcrest.Matchers.hasItem)2 Matchers.hasSize (org.hamcrest.Matchers.hasSize)2 Matchers.is (org.hamcrest.Matchers.is)2 After (org.junit.After)2 Assert.assertThat (org.junit.Assert.assertThat)2