Search in sources :

Example 1 with InMemoryFormMetadataAdapter

use of org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter in project briefcase by opendatakit.

the class PullFromAggregateIntegrationTest method setUp.

@Before
public void setUp() throws IOException {
    Files.createDirectories(briefcaseDir);
    prefs = new BriefcasePreferences(InMemoryPreferences.empty());
    prefs.setStorageDir(tmpDir);
    server = httpServer(serverPort);
    tracker = new PullFromAggregateTracker(form, e -> {
    });
    formMetadataPort = new InMemoryFormMetadataAdapter();
    pullOp = new PullFromAggregate(CommonsHttp.of(1), aggregateServer, briefcaseDir, true, e -> {
    }, formMetadataPort);
    runnerStatus = new TestRunnerStatus(false);
}
Also used : UncheckedFiles.deleteRecursive(org.opendatakit.briefcase.reused.UncheckedFiles.deleteRecursive) RequestBuilder.url(org.opendatakit.briefcase.reused.http.RequestBuilder.url) URL(java.net.URL) JobsRunner.launchSync(org.opendatakit.briefcase.reused.job.JobsRunner.launchSync) Assert.assertThat(org.junit.Assert.assertThat) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UncheckedFiles.readAllBytes(org.opendatakit.briefcase.reused.UncheckedFiles.readAllBytes) After(org.junit.After) AggregateServer(org.opendatakit.briefcase.reused.transfer.AggregateServer) Pair(org.opendatakit.briefcase.reused.Pair) Path(java.nio.file.Path) FormKey(org.opendatakit.briefcase.model.form.FormKey) CommonsHttp(org.opendatakit.briefcase.reused.http.CommonsHttp) Moco.httpServer(com.github.dreamhead.moco.Moco.httpServer) TransferTestHelpers.buildMediaFiles(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildMediaFiles) FormStatus(org.opendatakit.briefcase.model.FormStatus) FormMetadataQueries.lastCursorOf(org.opendatakit.briefcase.model.form.FormMetadataQueries.lastCursorOf) Moco.method(com.github.dreamhead.moco.Moco.method) TransferTestHelpers.generatePages(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.generatePages) UncheckedFiles.createTempDirectory(org.opendatakit.briefcase.reused.UncheckedFiles.createTempDirectory) GET(com.github.dreamhead.moco.HttpMethod.GET) Collectors.joining(java.util.stream.Collectors.joining) TransferTestHelpers(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers) UncheckedFiles.toURI(org.opendatakit.briefcase.reused.UncheckedFiles.toURI) List(java.util.List) Moco.seq(com.github.dreamhead.moco.Moco.seq) OffsetDateTime(java.time.OffsetDateTime) Runner.running(com.github.dreamhead.moco.Runner.running) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Matchers.containsString(org.hamcrest.Matchers.containsString) HttpServer(com.github.dreamhead.moco.HttpServer) IntStream(java.util.stream.IntStream) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) Moco.uri(com.github.dreamhead.moco.Moco.uri) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) TransferTestHelpers.buildFormStatus(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildFormStatus) InMemoryPreferences(org.opendatakit.briefcase.model.InMemoryPreferences) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Before(org.junit.Before) TransferTestHelpers.buildManifestXml(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildManifestXml) Files(java.nio.file.Files) RunnerStatus(org.opendatakit.briefcase.reused.job.RunnerStatus) IOException(java.io.IOException) Test(org.junit.Test) Collectors.toList(java.util.stream.Collectors.toList) Paths(java.nio.file.Paths) DateTimeFormatter(java.time.format.DateTimeFormatter) TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) Moco.by(com.github.dreamhead.moco.Moco.by) BriefcasePreferences(org.opendatakit.briefcase.model.BriefcasePreferences) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) Before(org.junit.Before)

Example 2 with InMemoryFormMetadataAdapter

use of org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter in project briefcase by opendatakit.

the class PullFromCentralIntegrationTest method setUp.

@Before
public void setUp() {
    server = httpServer(serverPort);
    formMetadataPort = new InMemoryFormMetadataAdapter();
    pullOp = new PullFromCentral(CommonsHttp.of(1), centralServer, briefcaseDir, token, e -> {
    }, formMetadataPort);
}
Also used : IntStream(java.util.stream.IntStream) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) UncheckedFiles.deleteRecursive(org.opendatakit.briefcase.reused.UncheckedFiles.deleteRecursive) CentralAttachment(org.opendatakit.briefcase.reused.transfer.CentralAttachment) Credentials(org.opendatakit.briefcase.reused.http.Credentials) Moco.uri(com.github.dreamhead.moco.Moco.uri) RequestBuilder.url(org.opendatakit.briefcase.reused.http.RequestBuilder.url) URL(java.net.URL) OptionalMatchers.isPresent(com.github.npathai.hamcrestopt.OptionalMatchers.isPresent) TransferTestHelpers.buildFormStatus(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildFormStatus) JobsRunner.launchSync(org.opendatakit.briefcase.reused.job.JobsRunner.launchSync) Assert.assertThat(org.junit.Assert.assertThat) PullFromCentralTest.jsonOfAttachments(org.opendatakit.briefcase.pull.central.PullFromCentralTest.jsonOfAttachments) UncheckedFiles.readAllBytes(org.opendatakit.briefcase.reused.UncheckedFiles.readAllBytes) After(org.junit.After) Path(java.nio.file.Path) FormKey(org.opendatakit.briefcase.model.form.FormKey) CommonsHttp(org.opendatakit.briefcase.reused.http.CommonsHttp) Moco.httpServer(com.github.dreamhead.moco.Moco.httpServer) Before(org.junit.Before) FormStatus(org.opendatakit.briefcase.model.FormStatus) CentralServer(org.opendatakit.briefcase.reused.transfer.CentralServer) Files(java.nio.file.Files) TransferTestHelpers.buildMediaFileXml(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildMediaFileXml) Test(org.junit.Test) UncheckedFiles.createTempDirectory(org.opendatakit.briefcase.reused.UncheckedFiles.createTempDirectory) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) PullFromCentralTest.jsonOfSubmissions(org.opendatakit.briefcase.pull.central.PullFromCentralTest.jsonOfSubmissions) UncheckedFiles.toURI(org.opendatakit.briefcase.reused.UncheckedFiles.toURI) TransferTestHelpers.buildSubmissionXml(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildSubmissionXml) List(java.util.List) PullFromCentralTest.buildAttachments(org.opendatakit.briefcase.pull.central.PullFromCentralTest.buildAttachments) OffsetDateTime(java.time.OffsetDateTime) Paths(java.nio.file.Paths) Runner.running(com.github.dreamhead.moco.Runner.running) DateTimeFormatter(java.time.format.DateTimeFormatter) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) PathMatchers.exists(org.opendatakit.briefcase.matchers.PathMatchers.exists) Matchers.containsString(org.hamcrest.Matchers.containsString) Collections(java.util.Collections) Moco.by(com.github.dreamhead.moco.Moco.by) HttpServer(com.github.dreamhead.moco.HttpServer) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) Before(org.junit.Before)

Example 3 with InMemoryFormMetadataAdapter

use of org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter 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 4 with InMemoryFormMetadataAdapter

use of org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter 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 5 with InMemoryFormMetadataAdapter

use of org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter in project briefcase by opendatakit.

the class ExportToCsvScenario method runExport.

void runExport(boolean overwrite, boolean exportMedia, LocalDate startDate, LocalDate endDate, Path pemFile, boolean splitSelectMultiples) {
    ExportConfiguration configuration = ExportConfiguration.Builder.empty().setExportDir(outputDir.resolve("new")).setPemFile(pemFile).setStartDate(startDate).setEndDate(endDate).setOverwriteFiles(overwrite).setExportMedia(exportMedia).setSplitSelectMultiples(splitSelectMultiples).build();
    FormKey formKey = FormKey.of(formDef.getFormName(), formDef.getFormId());
    FormMetadata formMetadata = new FormMetadata(formKey, briefcaseDir, formDef.getFormDir().resolve(stripIllegalChars(formDef.getFormName()) + ".xml"), true, Cursor.empty(), Optional.empty(), Collections.emptySet());
    ExportToCsv.export(new InMemoryFormMetadataAdapter(), formMetadata, formStatus, formDef, briefcaseDir, configuration);
}
Also used : InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) FormKey(org.opendatakit.briefcase.model.form.FormKey) FormMetadata(org.opendatakit.briefcase.model.form.FormMetadata)

Aggregations

InMemoryFormMetadataAdapter (org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter)10 Test (org.junit.Test)7 FormStatus (org.opendatakit.briefcase.model.FormStatus)7 FakeHttp (org.opendatakit.briefcase.reused.http.FakeHttp)7 BriefcasePreferences (org.opendatakit.briefcase.model.BriefcasePreferences)6 Before (org.junit.Before)5 Path (java.nio.file.Path)4 List (java.util.List)4 Matchers.is (org.hamcrest.Matchers.is)4 After (org.junit.After)4 Assert.assertThat (org.junit.Assert.assertThat)4 FormKey (org.opendatakit.briefcase.model.form.FormKey)4 UncheckedFiles.createTempDirectory (org.opendatakit.briefcase.reused.UncheckedFiles.createTempDirectory)4 UncheckedFiles.deleteRecursive (org.opendatakit.briefcase.reused.UncheckedFiles.deleteRecursive)4 RequestBuilder.url (org.opendatakit.briefcase.reused.http.RequestBuilder.url)4 TestRunnerStatus (org.opendatakit.briefcase.reused.job.TestRunnerStatus)4 TransferTestHelpers.buildFormStatus (org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildFormStatus)4 Files (java.nio.file.Files)3 Optional (java.util.Optional)3 Collectors.joining (java.util.stream.Collectors.joining)3