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);
}
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);
}
use of com.azure.core.management.exception.ManagementError in project terra-workspace-manager by DataBiosphere.
the class CreateAzureNetworkStepTest method setup.
@BeforeEach
public void setup() {
when(mockAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
when(mockAzureCloudContext.getAzureTenantId()).thenReturn(STUB_STRING_RETURN);
when(mockAzureCloudContext.getAzureSubscriptionId()).thenReturn(STUB_STRING_RETURN);
when(mockCrlService.getComputeManager(any(AzureCloudContext.class), any(AzureConfiguration.class))).thenReturn(mockComputeManager);
when(mockComputeManager.networkManager()).thenReturn(mockNetworkManager);
when(mockNetworkManager.networks()).thenReturn(mockNetworks);
when(mockNetworks.getByResourceGroup(anyString(), anyString())).thenReturn(mockNetwork);
// create network security group mocks
when(mockNetworkManager.networkSecurityGroups()).thenReturn(mockNsgs);
when(mockNsgs.define(anyString())).thenReturn(mockNetworkStage1);
when(mockNetworkStage1.withRegion(anyString())).thenReturn(mockNetworkStage1a);
when(mockNetworkStage1a.withExistingResourceGroup(anyString())).thenReturn(mockNetworkStage2);
when(mockNetworkStage2.withTag(anyString(), anyString())).thenReturn(mockNetworkStage2);
when(mockNetworkStage2.defineRule(anyString())).thenReturn(mockNetworkStage3);
when(mockNetworkStage3.allowInbound()).thenReturn(mockNetworkStage4);
when(mockNetworkStage3.denyOutbound()).thenReturn(mockNetworkStage4);
when(mockNetworkStage4.fromAddress(anyString())).thenReturn(mockNetworkStage5);
when(mockNetworkStage4.fromAnyAddress()).thenReturn(mockNetworkStage5);
when(mockNetworkStage5.fromAnyPort()).thenReturn(mockNetworkStage6);
when(mockNetworkStage6.toAnyAddress()).thenReturn(mockNetworkStage7);
when(mockNetworkStage6.toAddress(anyString())).thenReturn(mockNetworkStage7);
when(mockNetworkStage7.toPort(anyInt())).thenReturn(mockNetworkStage8);
when(mockNetworkStage7.toAnyPort()).thenReturn(mockNetworkStage8);
when(mockNetworkStage8.withProtocol(any(SecurityRuleProtocol.class))).thenReturn(mockNetworkStage9);
when(mockNetworkStage8.withAnyProtocol()).thenReturn(mockNetworkStage9);
when(mockNetworkStage9.attach()).thenReturn(mockNetworkStage2);
when(mockNetworkStage2.create(any(Context.class))).thenReturn(mockNsg);
// create network mocks
when(mockNetworks.define(anyString())).thenReturn(mockNetworkStage10);
when(mockNetworkStage10.withRegion(anyString())).thenReturn(mockNetworkStage11);
when(mockNetworkStage11.withExistingResourceGroup(anyString())).thenReturn(mockNetworkStage12);
when(mockNetworkStage12.withTag(anyString(), anyString())).thenReturn(mockNetworkStage12);
when(mockNetworkStage12.withAddressSpace(anyString())).thenReturn(mockNetworkStage13);
when(mockNetworkStage13.defineSubnet(anyString())).thenReturn(mockNetworkStage14);
when(mockNetworkStage14.withAddressPrefix(anyString())).thenReturn(mockNetworkStage15);
when(mockNetworkStage15.withExistingNetworkSecurityGroup(any(NetworkSecurityGroup.class))).thenReturn(mockNetworkStage15);
when(mockNetworkStage15.attach()).thenReturn(mockNetworkStage13);
when(mockNetworkStage13.create(any(Context.class))).thenReturn(mockNetwork);
// 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);
}
use of com.azure.core.management.exception.ManagementError in project terra-workspace-manager by DataBiosphere.
the class GetAzureNetworkStepTest method setup.
@BeforeEach
public void setup() {
when(mockAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
when(mockCrlService.getComputeManager(mockAzureCloudContext, mockAzureConfig)).thenReturn(mockComputeManager);
when(mockComputeManager.networkManager()).thenReturn(mockNetworkManager);
when(mockNetworkManager.networks()).thenReturn(mockNetworks);
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);
}
use of com.azure.core.management.exception.ManagementError in project terra-workspace-manager by DataBiosphere.
the class CreateAzureRelayNamespaceStepTest method setup.
@BeforeEach
public void setup() {
when(dummyAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
when(dummyAzureCloudContext.getAzureTenantId()).thenReturn(STUB_STRING_RETURN);
when(dummyAzureCloudContext.getAzureSubscriptionId()).thenReturn(STUB_STRING_RETURN);
when(mockCrlService.getRelayManager(dummyAzureCloudContext, mockAzureConfig)).thenReturn(mockRelayManager);
when(dummyAzureCloudContext.getAzureResourceGroupId()).thenReturn(STUB_STRING_RETURN);
when(mockCrlService.getRelayManager(dummyAzureCloudContext, mockAzureConfig)).thenReturn(mockRelayManager);
when(mockRelayManager.namespaces()).thenReturn(mockNamespaces);
when(mockNamespaces.define(anyString())).thenReturn(mockStage1);
when(mockStage1.withRegion(anyString())).thenReturn(mockStage2);
when(mockStage2.withExistingResourceGroup(anyString())).thenReturn(mockStage3);
when(mockStage3.create(any())).thenReturn(mockRelayNamespace);
// 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(dummyAzureCloudContext);
// Deletion mocks
doNothing().when(mockNamespaces).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(dummyAzureCloudContext);
}
Aggregations