use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.
the class MakeApiResourceDescriptionTest method mapReferencedBigQueryDatasetTest.
@Test
public void mapReferencedBigQueryDatasetTest() throws Exception {
String projectId = RandomStringUtils.randomAlphabetic(12);
String datasetName = RandomStringUtils.randomAlphabetic(12);
var resource = new ReferencedBigQueryDatasetResource(workspaceId, resourceId, resourceName, description, cloning, projectId, datasetName);
ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
validateWsmResource(resourceDescription);
ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
ApiGcpBigQueryDatasetAttributes attributes = union.getGcpBqDataset();
assertThat(attributes, is(notNullValue()));
assertEquals(attributes.getDatasetId(), datasetName);
assertEquals(attributes.getProjectId(), projectId);
}
use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.
the class MakeApiResourceDescriptionTest method mapReferencedGcsBucketTest.
@Test
public void mapReferencedGcsBucketTest() throws Exception {
String bucketName = RandomStringUtils.randomAlphabetic(5).toLowerCase();
var resource = new ReferencedGcsBucketResource(workspaceId, resourceId, resourceName, description, cloning, bucketName);
ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
validateWsmResource(resourceDescription);
ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
ApiGcpGcsBucketAttributes attributes = union.getGcpGcsBucket();
assertThat(attributes, is(notNullValue()));
assertEquals(attributes.getBucketName(), bucketName);
}
use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.
the class MakeApiResourceDescriptionTest method mapReferencedDataRepoSnapshotTest.
@Test
public void mapReferencedDataRepoSnapshotTest() throws Exception {
String snapshotId = UUID.randomUUID().toString();
String instanceName = RandomStringUtils.randomAlphabetic(5);
var resource = new ReferencedDataRepoSnapshotResource(workspaceId, resourceId, resourceName, description, cloning, instanceName, snapshotId);
ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
validateWsmResource(resourceDescription);
ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
ApiDataRepoSnapshotAttributes attributes = union.getGcpDataRepoSnapshot();
assertThat(attributes, is(notNullValue()));
assertEquals(attributes.getInstanceName(), instanceName);
assertEquals(attributes.getSnapshot(), snapshotId);
}
use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.
the class MakeApiResourceDescriptionTest method mapReferencedBigQueryDataTableTest.
@Test
public void mapReferencedBigQueryDataTableTest() throws Exception {
String projectId = RandomStringUtils.randomAlphabetic(12);
String datasetName = RandomStringUtils.randomAlphabetic(12);
String datatableName = RandomStringUtils.randomAlphabetic(12);
var resource = new ReferencedBigQueryDataTableResource(workspaceId, resourceId, resourceName, description, cloning, projectId, datasetName, datatableName);
ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
validateWsmResource(resourceDescription);
ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
ApiGcpBigQueryDataTableAttributes attributes = union.getGcpBqDataTable();
assertThat(attributes, is(notNullValue()));
assertEquals(attributes.getDatasetId(), datasetName);
assertEquals(attributes.getProjectId(), projectId);
assertEquals(attributes.getDataTableId(), datatableName);
}
use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.
the class ResourceController method makeApiResourceDescription.
// Convert a WsmResource into the API format for enumeration
@VisibleForTesting
public ApiResourceDescription makeApiResourceDescription(WsmResource wsmResource) {
ApiResourceMetadata common = wsmResource.toApiMetadata();
ApiResourceAttributesUnion union = wsmResource.toApiAttributesUnion();
return new ApiResourceDescription().metadata(common).resourceAttributes(union);
}
Aggregations