Search in sources :

Example 1 with ManagementError

use of com.azure.core.management.exception.ManagementError in project terra-workspace-manager by DataBiosphere.

the class GetAzureStorageStepTest method setup.

@BeforeEach
public void setup() {
    when(mockAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
    when(mockCrlService.getStorageManager(mockAzureCloudContext, mockAzureConfig)).thenReturn(mockStorageManager);
    when(mockStorageManager.storageAccounts()).thenReturn(mockStorageAccounts);
    when(mockException.getValue()).thenReturn(new ManagementError("ResourceNotFound", "Resource was not found."));
    when(mockFlightContext.getWorkingMap()).thenReturn(mockWorkingMap);
    when(mockWorkingMap.get(ControlledResourceKeys.AZURE_CLOUD_CONTEXT, AzureCloudContext.class)).thenReturn(mockAzureCloudContext);
}
Also used : ManagementError(com.azure.core.management.exception.ManagementError) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ManagementError

use of com.azure.core.management.exception.ManagementError in project terra-workspace-manager by DataBiosphere.

the class CreateAzureDiskStepTest method setup.

@BeforeEach
public void setup() {
    // PublicIpAddresses mocks
    when(mockAzureCloudContext.getAzureTenantId()).thenReturn(STUB_STRING_RETURN);
    when(mockAzureCloudContext.getAzureSubscriptionId()).thenReturn(STUB_STRING_RETURN);
    when(mockAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
    when(mockCrlService.getComputeManager(mockAzureCloudContext, mockAzureConfig)).thenReturn(mockComputeManager);
    when(mockComputeManager.disks()).thenReturn(mockDisks);
    // Creation stages mocks
    when(mockDisks.define(anyString())).thenReturn(mockDiskStage1);
    when(mockDiskStage1.withRegion(anyString())).thenReturn(mockDiskStage2);
    when(mockDiskStage2.withExistingResourceGroup(anyString())).thenReturn(mockDiskStage3);
    when(mockDiskStage3.withData()).thenReturn(mockDiskStage4);
    when(mockDiskStage4.withSizeInGB(anyInt())).thenReturn(mockDiskStage5);
    when(mockDiskStage5.withTag(anyString(), anyString())).thenReturn(mockDiskStage6);
    when(mockDiskStage6.withTag(anyString(), anyString())).thenReturn(mockDiskStage7);
    when(mockDiskStage7.create(any(Context.class))).thenReturn(mockDisk);
    // Deletion mocks
    // Exception mock
    when(mockException.getValue()).thenReturn(new ManagementError("Conflict", "Resource already exists."));
    when(mockFlightContext.getWorkingMap()).thenReturn(mockWorkingMap);
    when(mockWorkingMap.get(ControlledResourceKeys.AZURE_CLOUD_CONTEXT, AzureCloudContext.class)).thenReturn(mockAzureCloudContext);
}
Also used : Context(com.azure.core.util.Context) AzureCloudContext(bio.terra.workspace.service.workspace.model.AzureCloudContext) FlightContext(bio.terra.stairway.FlightContext) ManagementError(com.azure.core.management.exception.ManagementError) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ManagementError

use of com.azure.core.management.exception.ManagementError in project terra-workspace-manager by DataBiosphere.

the class CreateAzureIpStepTest method setup.

@BeforeEach
public void setup() {
    // PublicIpAddresses mocks
    when(mockAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
    when(mockAzureCloudContext.getAzureTenantId()).thenReturn(STUB_STRING_RETURN);
    when(mockAzureCloudContext.getAzureSubscriptionId()).thenReturn(STUB_STRING_RETURN);
    when(mockCrlService.getComputeManager(mockAzureCloudContext, mockAzureConfig)).thenReturn(mockComputeManager);
    when(mockComputeManager.networkManager()).thenReturn(mockNetworkManager);
    when(mockNetworkManager.publicIpAddresses()).thenReturn(mockPublicIpAddresses);
    // Creation stages mocks
    when(mockPublicIpAddresses.define(anyString())).thenReturn(mockIpStage1);
    when(mockIpStage1.withRegion(anyString())).thenReturn(mockIpStage2);
    when(mockIpStage2.withExistingResourceGroup(anyString())).thenReturn(mockIpStage3);
    when(mockIpStage3.withDynamicIP()).thenReturn(mockIpStage3);
    when(mockIpStage3.withTag(anyString(), anyString())).thenReturn(mockIpStage3);
    when(mockIpStage3.create(any(Context.class))).thenReturn(mockPublicIpAddress);
    // Deletion mocks
    doNothing().when(mockPublicIpAddresses).deleteByResourceGroup(anyString(), anyString());
    // Exception mock
    when(mockException.getValue()).thenReturn(new ManagementError("Conflict", "Resource already exists."));
    when(mockFlightContext.getWorkingMap()).thenReturn(mockWorkingMap);
    when(mockWorkingMap.get(ControlledResourceKeys.AZURE_CLOUD_CONTEXT, AzureCloudContext.class)).thenReturn(mockAzureCloudContext);
}
Also used : Context(com.azure.core.util.Context) AzureCloudContext(bio.terra.workspace.service.workspace.model.AzureCloudContext) FlightContext(bio.terra.stairway.FlightContext) ManagementError(com.azure.core.management.exception.ManagementError) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ManagementError

use of com.azure.core.management.exception.ManagementError in project terra-workspace-manager by DataBiosphere.

the class GetAzureDiskStepTest method setup.

@BeforeEach
public void setup() {
    // PublicIpAddresses mocks
    when(mockAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
    when(mockCrlService.getComputeManager(mockAzureCloudContext, mockAzureConfig)).thenReturn(mockComputeManager);
    when(mockComputeManager.disks()).thenReturn(mockDisks);
    when(mockException.getValue()).thenReturn(new ManagementError("ResourceNotFound", "Resource was not found."));
    when(mockFlightContext.getWorkingMap()).thenReturn(mockWorkingMap);
    when(mockWorkingMap.get(ControlledResourceKeys.AZURE_CLOUD_CONTEXT, AzureCloudContext.class)).thenReturn(mockAzureCloudContext);
}
Also used : ManagementError(com.azure.core.management.exception.ManagementError) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ManagementError

use of com.azure.core.management.exception.ManagementError in project terra-workspace-manager by DataBiosphere.

the class GetAzureIpStepTest method setup.

@BeforeEach
public void setup() {
    // PublicIpAddresses mocks
    when(mockAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
    when(mockCrlService.getComputeManager(mockAzureCloudContext, mockAzureConfig)).thenReturn(mockComputeManager);
    when(mockComputeManager.networkManager()).thenReturn(mockNetworkManager);
    when(mockNetworkManager.publicIpAddresses()).thenReturn(mockPublicIpAddresses);
    when(mockException.getValue()).thenReturn(new ManagementError("ResourceNotFound", "Resource was not found."));
    when(mockFlightContext.getWorkingMap()).thenReturn(mockWorkingMap);
    when(mockWorkingMap.get(ControlledResourceKeys.AZURE_CLOUD_CONTEXT, AzureCloudContext.class)).thenReturn(mockAzureCloudContext);
}
Also used : ManagementError(com.azure.core.management.exception.ManagementError) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ManagementError (com.azure.core.management.exception.ManagementError)12 BeforeEach (org.junit.jupiter.api.BeforeEach)11 FlightContext (bio.terra.stairway.FlightContext)5 AzureCloudContext (bio.terra.workspace.service.workspace.model.AzureCloudContext)5 Context (com.azure.core.util.Context)5 AzureConfiguration (bio.terra.workspace.app.configuration.external.AzureConfiguration)2 NetworkSecurityGroup (com.azure.resourcemanager.network.models.NetworkSecurityGroup)2 SecurityRuleProtocol (com.azure.resourcemanager.network.models.SecurityRuleProtocol)2 ManagementException (com.azure.core.management.exception.ManagementException)1 Disk (com.azure.resourcemanager.compute.models.Disk)1 VirtualMachineSizeTypes (com.azure.resourcemanager.compute.models.VirtualMachineSizeTypes)1 Network (com.azure.resourcemanager.network.models.Network)1 PublicIpAddress (com.azure.resourcemanager.network.models.PublicIpAddress)1 RedisManager (com.azure.resourcemanager.redis.RedisManager)1 RedisClient (com.azure.resourcemanager.redis.fluent.RedisClient)1 CheckNameAvailabilityParameters (com.azure.resourcemanager.redis.models.CheckNameAvailabilityParameters)1 CheckNameAvailabilityResultEntity (com.microsoft.azure.toolkit.lib.common.entity.CheckNameAvailabilityResultEntity)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 UUID (java.util.UUID)1