Search in sources :

Example 1 with CreatePublicIpRequestData

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)));
}
Also used : ApiAzureIpCreationParameters(bio.terra.workspace.generated.model.ApiAzureIpCreationParameters) Context(com.azure.core.util.Context) AzureCloudContext(bio.terra.workspace.service.workspace.model.AzureCloudContext) FlightContext(bio.terra.stairway.FlightContext) CreatePublicIpRequestData(bio.terra.cloudres.azure.resourcemanager.compute.data.CreatePublicIpRequestData) StepResult(bio.terra.stairway.StepResult) Test(org.junit.jupiter.api.Test) BaseAzureTest(bio.terra.workspace.common.BaseAzureTest)

Example 2 with CreatePublicIpRequestData

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());
}
Also used : CloudResourceUid(bio.terra.janitor.model.CloudResourceUid) CreatePublicIpRequestData(bio.terra.cloudres.azure.resourcemanager.compute.data.CreatePublicIpRequestData) AzurePublicIp(bio.terra.janitor.model.AzurePublicIp) Test(org.junit.jupiter.api.Test)

Aggregations

CreatePublicIpRequestData (bio.terra.cloudres.azure.resourcemanager.compute.data.CreatePublicIpRequestData)2 Test (org.junit.jupiter.api.Test)2 AzurePublicIp (bio.terra.janitor.model.AzurePublicIp)1 CloudResourceUid (bio.terra.janitor.model.CloudResourceUid)1 FlightContext (bio.terra.stairway.FlightContext)1 StepResult (bio.terra.stairway.StepResult)1 BaseAzureTest (bio.terra.workspace.common.BaseAzureTest)1 ApiAzureIpCreationParameters (bio.terra.workspace.generated.model.ApiAzureIpCreationParameters)1 AzureCloudContext (bio.terra.workspace.service.workspace.model.AzureCloudContext)1 Context (com.azure.core.util.Context)1