Search in sources :

Example 1 with TestRunnerStatus

use of org.opendatakit.briefcase.reused.job.TestRunnerStatus 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 TestRunnerStatus

use of org.opendatakit.briefcase.reused.job.TestRunnerStatus 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 3 with TestRunnerStatus

use of org.opendatakit.briefcase.reused.job.TestRunnerStatus 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)

Example 4 with TestRunnerStatus

use of org.opendatakit.briefcase.reused.job.TestRunnerStatus in project briefcase by opendatakit.

the class PushToAggregateTest method setUp.

@Before
public void setUp() throws IOException {
    http = new FakeHttp();
    briefcaseDir = createTempDirectory("briefcase-test-");
    events = new ArrayList<>();
    runnerStatus = new TestRunnerStatus(false);
    tracker = new PushToAggregateTracker(formStatus, this::onEvent);
    form = TransferTestHelpers.installForm(formStatus, TransferTestHelpers.getResourcePath("/org/opendatakit/briefcase/push/aggregate/push-form-test.xml"), briefcaseDir);
    formAttachment = TransferTestHelpers.installFormAttachment(formStatus, TransferTestHelpers.getResourcePath("/org/opendatakit/briefcase/push/aggregate/sparrow.png"), briefcaseDir);
    submission = TransferTestHelpers.installSubmission(formStatus, TransferTestHelpers.getResourcePath("/org/opendatakit/briefcase/push/aggregate/submission.xml"), briefcaseDir);
    submissionAttachment = TransferTestHelpers.installSubmissionAttachment(formStatus, TransferTestHelpers.getResourcePath("/org/opendatakit/briefcase/push/aggregate/1556532531101.jpg"), briefcaseDir, instanceId);
}
Also used : TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) FakeHttp(org.opendatakit.briefcase.reused.http.FakeHttp) Before(org.junit.Before)

Example 5 with TestRunnerStatus

use of org.opendatakit.briefcase.reused.job.TestRunnerStatus in project briefcase by opendatakit.

the class PullFromCentralTest method init.

@Before
public void init() {
    http = new FakeHttp();
    events = new ArrayList<>();
    tracker = new PullFromCentralTracker(form, e -> events.add(e.getStatusString()));
    pullOp = new PullFromCentral(http, server, briefcaseDir, token, e -> {
    }, new InMemoryFormMetadataAdapter());
    runnerStatus = new TestRunnerStatus(false);
}
Also used : IntStream(java.util.stream.IntStream) InMemoryFormMetadataAdapter(org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter) UncheckedFiles.deleteRecursive(org.opendatakit.briefcase.reused.UncheckedFiles.deleteRecursive) FakeHttp(org.opendatakit.briefcase.reused.http.FakeHttp) CentralAttachment(org.opendatakit.briefcase.reused.transfer.CentralAttachment) Credentials(org.opendatakit.briefcase.reused.http.Credentials) RequestBuilder.url(org.opendatakit.briefcase.reused.http.RequestBuilder.url) TransferTestHelpers.buildFormStatus(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildFormStatus) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UncheckedFiles.readAllBytes(org.opendatakit.briefcase.reused.UncheckedFiles.readAllBytes) After(org.junit.After) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Path(java.nio.file.Path) Before(org.junit.Before) FormStatus(org.opendatakit.briefcase.model.FormStatus) CentralServer(org.opendatakit.briefcase.reused.transfer.CentralServer) ResponseHelpers.ok(org.opendatakit.briefcase.reused.http.response.ResponseHelpers.ok) IOException(java.io.IOException) Test(org.junit.Test) UncheckedFiles.createTempDirectory(org.opendatakit.briefcase.reused.UncheckedFiles.createTempDirectory) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) TransferTestHelpers.buildSubmissionXml(org.opendatakit.briefcase.reused.transfer.TransferTestHelpers.buildSubmissionXml) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Matchers.hasItem(org.hamcrest.Matchers.hasItem) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.is(org.hamcrest.Matchers.is) PathMatchers.exists(org.opendatakit.briefcase.matchers.PathMatchers.exists) TestRunnerStatus(org.opendatakit.briefcase.reused.job.TestRunnerStatus) 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

Before (org.junit.Before)5 TestRunnerStatus (org.opendatakit.briefcase.reused.job.TestRunnerStatus)5 InMemoryFormMetadataAdapter (org.opendatakit.briefcase.model.form.InMemoryFormMetadataAdapter)4 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 List (java.util.List)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Matchers.hasSize (org.hamcrest.Matchers.hasSize)3 Matchers.is (org.hamcrest.Matchers.is)3 After (org.junit.After)3 Assert.assertThat (org.junit.Assert.assertThat)3 Test (org.junit.Test)3 FormStatus (org.opendatakit.briefcase.model.FormStatus)3 UncheckedFiles.createTempDirectory (org.opendatakit.briefcase.reused.UncheckedFiles.createTempDirectory)3 UncheckedFiles.deleteRecursive (org.opendatakit.briefcase.reused.UncheckedFiles.deleteRecursive)3 FakeHttp (org.opendatakit.briefcase.reused.http.FakeHttp)3 Files (java.nio.file.Files)2 ArrayList (java.util.ArrayList)2 Optional (java.util.Optional)2 Collectors.joining (java.util.stream.Collectors.joining)2