use of bio.terra.cloudres.azure.resourcemanager.compute.data.CreatePublicIpRequestData in project terra-workspace-manager by DataBiosphere.
the class CreateAzureIpStepTest method createIp.
@Test
void createIp() throws InterruptedException {
final ApiAzureIpCreationParameters creationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
CreateAzureIpStep createAzureIpStep = new CreateAzureIpStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureIp(creationParameters.getName(), creationParameters.getRegion()));
final StepResult stepResult = createAzureIpStep.doStep(mockFlightContext);
// Verify step returns success
assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
// Verify Azure create call was made correctly
verify(mockIpStage3).create(contextCaptor.capture());
Context context = contextCaptor.getValue();
Optional<CreatePublicIpRequestData> publicIpRequestDataOpt = context.getValues().values().stream().filter(CreatePublicIpRequestData.class::isInstance).map(CreatePublicIpRequestData.class::cast).findFirst();
CreatePublicIpRequestData expected = CreatePublicIpRequestData.builder().setName(creationParameters.getName()).setRegion(Region.fromName(creationParameters.getRegion())).setIpAllocationMethod(IpAllocationMethod.DYNAMIC).setTenantId(mockAzureCloudContext.getAzureTenantId()).setSubscriptionId(mockAzureCloudContext.getAzureSubscriptionId()).setResourceGroupName(mockAzureCloudContext.getAzureResourceGroupId()).build();
assertThat(publicIpRequestDataOpt, equalTo(Optional.of(expected)));
}
use of bio.terra.cloudres.azure.resourcemanager.compute.data.CreatePublicIpRequestData in project terra-cloud-resource-lib by DataBiosphere.
the class ComputeRequestDataTest method serializeCreatePublicIp.
@Test
public void serializeCreatePublicIp() {
CreatePublicIpRequestData createPublicIp = CreatePublicIpRequestData.builder().setName("my-ip").setTenantId("my-tenant").setSubscriptionId("my-sub").setResourceGroupName("my-rg").setRegion(Region.US_EAST).setIpAllocationMethod(IpAllocationMethod.DYNAMIC).build();
assertEquals(ComputeManagerOperation.AZURE_CREATE_PUBLIC_IP, createPublicIp.cloudOperation());
assertEquals("{\"tenantId\":\"my-tenant\",\"subscriptionId\":\"my-sub\",\"resourceGroupName\":\"my-rg\"," + "\"name\":\"my-ip\",\"region\":\"eastus\"," + "\"ipAllocationMethod\":\"Dynamic\"}", createPublicIp.serialize().toString());
assertEquals(Optional.of(new CloudResourceUid().azurePublicIp(new AzurePublicIp().resourceGroup(azureResourceGroup(createPublicIp)).ipName("my-ip"))), createPublicIp.resourceUidCreation());
}
Aggregations