use of bio.terra.model.SnapshotSourceModel in project jade-data-repo by DataBiosphere.
the class SnapshotService method makeSourceModelFromSource.
private SnapshotSourceModel makeSourceModelFromSource(SnapshotSource source) {
// TODO: when source summary methods are available, use those. Here I roll my own
Dataset dataset = source.getDataset();
DatasetSummaryModel summaryModel = new DatasetSummaryModel().id(dataset.getId().toString()).name(dataset.getName()).description(dataset.getDescription()).defaultProfileId(dataset.getDefaultProfileId().toString()).createdDate(dataset.getCreatedDate().toString());
SnapshotSourceModel sourceModel = new SnapshotSourceModel().dataset(summaryModel);
AssetSpecification assetSpec = source.getAssetSpecification();
if (assetSpec != null) {
sourceModel.asset(assetSpec.getName());
}
return sourceModel;
}
use of bio.terra.model.SnapshotSourceModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method getTestSnapshot.
private SnapshotModel getTestSnapshot(String id, SnapshotRequestModel snapshotRequest, DatasetSummaryModel datasetSummary) throws Exception {
MvcResult result = mvc.perform(get("/api/repository/v1/snapshots/" + id)).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andReturn();
MockHttpServletResponse response = result.getResponse();
SnapshotModel snapshotModel = objectMapper.readValue(response.getContentAsString(), SnapshotModel.class);
assertThat(snapshotModel.getDescription(), equalTo(snapshotRequest.getDescription()));
assertThat(snapshotModel.getName(), startsWith(snapshotRequest.getName()));
assertThat("source array has one element", snapshotModel.getSource().size(), equalTo(1));
SnapshotSourceModel sourceModel = snapshotModel.getSource().get(0);
assertThat("snapshot dataset summary is the same as from dataset", sourceModel.getDataset(), equalTo(datasetSummary));
return snapshotModel;
}
Aggregations