use of bio.terra.model.SnapshotRequestModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method testBadData.
@Test
public void testBadData() throws Exception {
SnapshotRequestModel badDataRequest = makeSnapshotTestRequest(datasetSummary, "snapshot-test-snapshot-baddata.json");
MockHttpServletResponse response = performCreateSnapshot(badDataRequest, "_baddata_");
ErrorModel errorModel = handleCreateSnapshotFailureCase(response);
assertThat(errorModel.getMessage(), containsString("Fred"));
}
use of bio.terra.model.SnapshotRequestModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method testMinimalBadAsset.
@Test
public void testMinimalBadAsset() throws Exception {
DatasetSummaryModel datasetMinimalSummary = setupMinimalDataset();
SnapshotRequestModel snapshotRequest = makeSnapshotTestRequest(datasetMinimalSummary, "dataset-minimal-snapshot-bad-asset.json");
MvcResult result = launchCreateSnapshot(snapshotRequest, "");
MockHttpServletResponse response = connectedOperations.validateJobModelAndWait(result);
assertThat(response.getStatus(), equalTo(HttpStatus.NOT_FOUND.value()));
}
use of bio.terra.model.SnapshotRequestModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method testEnumeration.
@Test
public void testEnumeration() throws Exception {
SnapshotRequestModel snapshotRequest = makeSnapshotTestRequest(datasetSummary, "snapshot-test-snapshot.json");
// Other unit tests exercise the array bounds, so here we don't fuss with that here.
// Just make sure we get the same snapshot summary that we made.
List<SnapshotSummaryModel> snapshotList = new ArrayList<>();
for (int i = 0; i < 5; i++) {
MockHttpServletResponse response = performCreateSnapshot(snapshotRequest, "_en_");
SnapshotSummaryModel summaryModel = validateSnapshotCreated(snapshotRequest, response);
snapshotList.add(summaryModel);
}
List<UUID> snapshotIds = snapshotList.stream().map(snapshot -> UUID.fromString(snapshot.getId())).collect(Collectors.toList());
when(samService.listAuthorizedResources(any(), any())).thenReturn(snapshotIds);
EnumerateSnapshotModel enumResponse = enumerateTestSnapshots();
List<SnapshotSummaryModel> enumeratedArray = enumResponse.getItems();
assertThat("total is correct", enumResponse.getTotal(), equalTo(5));
// The enumeratedArray may contain more snapshots than just the set we created,
// but ours should be in order in the enumeration. So we do a merge waiting until we match
// by id and then comparing contents.
int compareIndex = 0;
for (SnapshotSummaryModel anEnumeratedSnapshot : enumeratedArray) {
if (anEnumeratedSnapshot.getId().equals(snapshotList.get(compareIndex).getId())) {
assertThat("MetadataEnumeration summary matches create summary", anEnumeratedSnapshot, equalTo(snapshotList.get(compareIndex)));
compareIndex++;
}
}
assertThat("we found all snapshots", compareIndex, equalTo(5));
for (int i = 0; i < 5; i++) {
connectedOperations.deleteTestSnapshot(enumeratedArray.get(i).getId());
}
}
use of bio.terra.model.SnapshotRequestModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method snapshotHappyPathTestingHelper.
private void snapshotHappyPathTestingHelper(String path) throws Exception {
SnapshotRequestModel snapshotRequest = makeSnapshotTestRequest(datasetSummary, path);
MockHttpServletResponse response = performCreateSnapshot(snapshotRequest, "_thp_");
SnapshotSummaryModel summaryModel = validateSnapshotCreated(snapshotRequest, response);
SnapshotModel snapshotModel = getTestSnapshot(summaryModel.getId(), snapshotRequest, datasetSummary);
connectedOperations.deleteTestSnapshot(snapshotModel.getId());
// Duplicate delete should work
connectedOperations.deleteTestSnapshot(snapshotModel.getId());
connectedOperations.getSnapshotExpectError(snapshotModel.getId(), HttpStatus.NOT_FOUND);
}
use of bio.terra.model.SnapshotRequestModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method makeSnapshotTestRequest.
private SnapshotRequestModel makeSnapshotTestRequest(DatasetSummaryModel datasetSummaryModel, String resourcePath) throws Exception {
SnapshotRequestModel snapshotRequest = jsonLoader.loadObject(resourcePath, SnapshotRequestModel.class);
SnapshotRequestContentsModel content = snapshotRequest.getContents().get(0);
// TODO SingleDatasetSnapshot
String newDatasetName = datasetSummaryModel.getName();
String origDatasetName = content.getDatasetName();
// swap in the correct dataset name (with the id at the end)
content.setDatasetName(newDatasetName);
snapshotRequest.profileId(datasetSummaryModel.getDefaultProfileId());
if (content.getMode().equals(SnapshotRequestContentsModel.ModeEnum.BYQUERY)) {
// if its by query, also set swap in the correct dataset name in the query
String query = content.getQuerySpec().getQuery();
content.getQuerySpec().setQuery(query.replace(origDatasetName, newDatasetName));
}
return snapshotRequest;
}
Aggregations