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")));
}
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");
}
}
}
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"));
}
Aggregations