use of bio.terra.cloudres.azure.resourcemanager.compute.data.CreateDiskRequestData in project terra-workspace-manager by DataBiosphere.
the class CreateAzureDiskStepTest method createDisk.
@Test
void createDisk() throws InterruptedException {
final ApiAzureDiskCreationParameters creationParameters = ControlledResourceFixtures.getAzureDiskCreationParameters();
var createAzureDiskStep = new CreateAzureDiskStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureDisk(creationParameters.getName(), creationParameters.getRegion(), creationParameters.getSize()));
final StepResult stepResult = createAzureDiskStep.doStep(mockFlightContext);
// Verify step returns success
assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
// Verify Azure create call was made correctly
verify(mockDiskStage7).create(contextCaptor.capture());
Context context = contextCaptor.getValue();
Optional<CreateDiskRequestData> requestDataOpt = context.getValues().values().stream().filter(CreateDiskRequestData.class::isInstance).map(CreateDiskRequestData.class::cast).findFirst();
CreateDiskRequestData expected = CreateDiskRequestData.builder().setName(creationParameters.getName()).setRegion(Region.fromName(creationParameters.getRegion())).setSize(50).setTenantId(mockAzureCloudContext.getAzureTenantId()).setSubscriptionId(mockAzureCloudContext.getAzureSubscriptionId()).setResourceGroupName(mockAzureCloudContext.getAzureResourceGroupId()).build();
assertThat(requestDataOpt, equalTo(Optional.of(expected)));
}
use of bio.terra.cloudres.azure.resourcemanager.compute.data.CreateDiskRequestData in project terra-cloud-resource-lib by DataBiosphere.
the class ComputeRequestDataTest method serializeCreateDisk.
@Test
public void serializeCreateDisk() {
CreateDiskRequestData createDisk = CreateDiskRequestData.builder().setName("my-disk").setTenantId("my-tenant").setSubscriptionId("my-sub").setResourceGroupName("my-rg").setRegion(Region.US_EAST).setSize(500).build();
assertEquals(ComputeManagerOperation.AZURE_CREATE_DISK, createDisk.cloudOperation());
assertEquals("{\"tenantId\":\"my-tenant\",\"subscriptionId\":\"my-sub\",\"resourceGroupName\":\"my-rg\",\"name\":\"my-disk\",\"region\":\"eastus\",\"size\":500}", createDisk.serialize().toString());
assertEquals(Optional.of(new CloudResourceUid().azureDisk(new AzureDisk().resourceGroup(azureResourceGroup(createDisk)).diskName("my-disk"))), createDisk.resourceUidCreation());
}
Aggregations