Search in sources :

Example 1 with SnapshotSourceModel

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;
}
Also used : Dataset(bio.terra.service.dataset.Dataset) SnapshotSourceModel(bio.terra.model.SnapshotSourceModel) DatasetSummaryModel(bio.terra.model.DatasetSummaryModel) AssetSpecification(bio.terra.service.dataset.AssetSpecification)

Example 2 with SnapshotSourceModel

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;
}
Also used : SnapshotSourceModel(bio.terra.model.SnapshotSourceModel) MvcResult(org.springframework.test.web.servlet.MvcResult) SnapshotModel(bio.terra.model.SnapshotModel) EnumerateSnapshotModel(bio.terra.model.EnumerateSnapshotModel) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Aggregations

SnapshotSourceModel (bio.terra.model.SnapshotSourceModel)2 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)1 EnumerateSnapshotModel (bio.terra.model.EnumerateSnapshotModel)1 SnapshotModel (bio.terra.model.SnapshotModel)1 AssetSpecification (bio.terra.service.dataset.AssetSpecification)1 Dataset (bio.terra.service.dataset.Dataset)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1