Search in sources :

Example 16 with JobModel

use of bio.terra.model.JobModel in project jade-data-repo by DataBiosphere.

the class IngestTest method ingestWildcardMalformedTest.

@Test
public void ingestWildcardMalformedTest() throws Exception {
    IngestRequestModel request = dataRepoFixtures.buildSimpleIngest("file", "ingest-test/ingest-test-p*.json");
    DataRepoResponse<JobModel> ingestJobResponse = dataRepoFixtures.ingestJsonDataLaunch(steward(), datasetId, request);
    DataRepoResponse<IngestResponseModel> ingestResponse = dataRepoClient.waitForResponse(steward(), ingestJobResponse, IngestResponseModel.class);
    assertThat("ingest failed", ingestResponse.getStatusCode(), equalTo(HttpStatus.BAD_REQUEST));
    assertThat("failure is explained", ingestResponse.getErrorObject().orElseThrow(IllegalStateException::new).getErrorDetail(), hasItem(containsString("too many errors")));
}
Also used : JobModel(bio.terra.model.JobModel) IngestRequestModel(bio.terra.model.IngestRequestModel) IngestResponseModel(bio.terra.model.IngestResponseModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 17 with JobModel

use of bio.terra.model.JobModel in project jade-data-repo by DataBiosphere.

the class ConnectedOperations method validateJobModelAndWait.

public MockHttpServletResponse validateJobModelAndWait(MvcResult inResult) throws Exception {
    MvcResult result = inResult;
    while (true) {
        MockHttpServletResponse response = result.getResponse();
        HttpStatus status = HttpStatus.valueOf(response.getStatus());
        assertTrue("expected jobs polling status, got " + status.toString(), (status == HttpStatus.ACCEPTED || status == HttpStatus.OK));
        JobModel jobModel = TestUtils.mapFromJson(response.getContentAsString(), JobModel.class);
        String jobId = jobModel.getId();
        String locationUrl = response.getHeader("Location");
        assertNotNull("location URL was specified", locationUrl);
        switch(status) {
            case ACCEPTED:
                // Not done case: sleep and probe using the header URL
                assertThat("location header for probe", locationUrl, equalTo(String.format("/api/repository/v1/jobs/%s", jobId)));
                TimeUnit.SECONDS.sleep(1);
                result = mvc.perform(get(locationUrl).accept(MediaType.APPLICATION_JSON)).andReturn();
                break;
            case OK:
                // Done case: get the result with the header URL and return the response;
                // let the caller interpret the response
                assertThat("location header for result", locationUrl, equalTo(String.format("/api/repository/v1/jobs/%s/result", jobId)));
                result = mvc.perform(get(locationUrl).accept(MediaType.APPLICATION_JSON)).andReturn();
                return result.getResponse();
            default:
                fail("invalid response status");
        }
    }
}
Also used : HttpStatus(org.springframework.http.HttpStatus) JobModel(bio.terra.model.JobModel) MvcResult(org.springframework.test.web.servlet.MvcResult) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 18 with JobModel

use of bio.terra.model.JobModel in project jade-data-repo by DataBiosphere.

the class IngestTest method ingestEmptyPatternTest.

@Test
public void ingestEmptyPatternTest() throws Exception {
    IngestRequestModel request = dataRepoFixtures.buildSimpleIngest("file", "prefix-matching-nothing/*");
    DataRepoResponse<JobModel> ingestJobResponse = dataRepoFixtures.ingestJsonDataLaunch(steward(), datasetId, request);
    DataRepoResponse<IngestResponseModel> ingestResponse = dataRepoClient.waitForResponse(steward(), ingestJobResponse, IngestResponseModel.class);
    assertThat("ingest failed", ingestResponse.getStatusCode(), equalTo(HttpStatus.NOT_FOUND));
    assertThat("failure is explained", ingestResponse.getErrorObject().orElseThrow(IllegalStateException::new).getMessage(), containsString("not found"));
}
Also used : JobModel(bio.terra.model.JobModel) IngestRequestModel(bio.terra.model.IngestRequestModel) IngestResponseModel(bio.terra.model.IngestResponseModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

JobModel (bio.terra.model.JobModel)18 Test (org.junit.Test)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 IngestRequestModel (bio.terra.model.IngestRequestModel)8 IngestResponseModel (bio.terra.model.IngestResponseModel)8 BulkLoadFileModel (bio.terra.model.BulkLoadFileModel)2 ErrorModel (bio.terra.model.ErrorModel)2 FileModel (bio.terra.model.FileModel)2 ArrayList (java.util.ArrayList)2 HttpStatus (org.springframework.http.HttpStatus)2 BulkLoadArrayResultModel (bio.terra.model.BulkLoadArrayResultModel)1 DatasetModel (bio.terra.model.DatasetModel)1 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)1 EnumerateDatasetModel (bio.terra.model.EnumerateDatasetModel)1 EnumerateSnapshotModel (bio.terra.model.EnumerateSnapshotModel)1 SnapshotModel (bio.terra.model.SnapshotModel)1 SnapshotSummaryModel (bio.terra.model.SnapshotSummaryModel)1 InternalStairwayException (bio.terra.service.job.exception.InternalStairwayException)1 JobServiceShutdownException (bio.terra.service.job.exception.JobServiceShutdownException)1 FlightFilter (bio.terra.stairway.FlightFilter)1