use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class EnvironmentNetworkServiceTest method testCreateNetworkIfUnableToObtainNetworkConnectorThenNetworkConnectorNotFoundExceptionComes.
@Test
@SuppressWarnings("unchecked")
void testCreateNetworkIfUnableToObtainNetworkConnectorThenNetworkConnectorNotFoundExceptionComes() {
EnvironmentDto environmentDto = EnvironmentDto.builder().withCloudPlatform(CLOUD_PLATFORM).build();
CloudConnector<Object> cloudConnector = mock(CloudConnector.class);
when(cloudPlatformConnectors.get(any(CloudPlatformVariant.class))).thenReturn(cloudConnector);
when(cloudConnector.networkConnector()).thenReturn(null);
Assertions.assertThrows(NetworkConnectorNotFoundException.class, () -> underTest.createCloudNetwork(environmentDto, new AzureNetwork()));
verify(cloudPlatformConnectors, times(1)).get(any());
}
use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method testConvertShouldCreateABaseNetworkFromAnEnvironmentAndANetworkDto.
@Test
void testConvertShouldCreateABaseNetworkFromAnEnvironmentAndANetworkDto() {
Environment environment = createEnvironment();
NetworkDto networkDto = NetworkDto.builder().withAzure(AzureParams.builder().withNetworkId(NETWORK_ID).withResourceGroupName(RESOURCE_GROUP_NAME).withNoPublicIp(true).build()).withName(NETWORK_NAME).withNetworkCidr(NETWORK_CIDR).withSubnetMetas(createSubnetMetas()).build();
AzureNetwork actual = (AzureNetwork) underTest.convert(environment, networkDto, Map.of(), Map.of());
assertEquals(NETWORK_NAME, actual.getName());
assertEquals(NETWORK_ID, actual.getNetworkId());
assertEquals(RESOURCE_GROUP_NAME, actual.getResourceGroupName());
assertTrue(actual.getNoPublicIp());
assertEquals(NETWORK_CIDR, actual.getNetworkCidr());
assertEquals(RegistrationType.EXISTING, actual.getRegistrationType());
assertTrue(SUBNET_IDS.containsAll(actual.getSubnetMetas().keySet()));
verify(environmentViewConverter).convert(environment);
}
use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method testSetProviderSpecificNetworkShouldPopulateTheExistingNetworkWithTheNewNetworkData.
@Test
void testSetProviderSpecificNetworkShouldPopulateTheExistingNetworkWithTheNewNetworkData() {
AzureNetwork azureNetwork = new AzureNetwork();
Set<CreatedSubnet> createdSubnets = createCreatedSubnets();
Map<String, Object> properties = Map.of("resourceGroupName", RESOURCE_GROUP_NAME);
CreatedCloudNetwork createdCloudNetwork = new CreatedCloudNetwork("network-1", NETWORK_ID, createdSubnets, properties);
AzureNetwork actual = (AzureNetwork) underTest.setCreatedCloudNetwork(azureNetwork, createdCloudNetwork);
assertEquals(createdCloudNetwork.getStackName(), actual.getName());
assertEquals(NETWORK_ID, actual.getNetworkId());
assertEquals(RESOURCE_GROUP_NAME, actual.getResourceGroupName());
assertTrue(SUBNET_IDS.containsAll(actual.getSubnetMetas().keySet()));
assertEquals(SUBNET_1, actual.getSubnetMetas().get(SUBNET_1).getId());
assertEquals(SUBNET_1, actual.getSubnetMetas().get(SUBNET_1).getName());
assertEquals(AZ_1, actual.getSubnetMetas().get(SUBNET_1).getAvailabilityZone());
assertEquals(SUBNET_CIDR_1, actual.getSubnetMetas().get(SUBNET_1).getCidr());
assertTrue(actual.getSubnetMetas().get(SUBNET_1).isPrivateSubnet());
assertEquals(SUBNET_2, actual.getSubnetMetas().get(SUBNET_2).getId());
assertEquals(SUBNET_2, actual.getSubnetMetas().get(SUBNET_2).getName());
assertEquals(AZ_2, actual.getSubnetMetas().get(SUBNET_2).getAvailabilityZone());
assertEquals(SUBNET_CIDR_2, actual.getSubnetMetas().get(SUBNET_2).getCidr());
assertTrue(actual.getSubnetMetas().get(SUBNET_2).isPrivateSubnet());
assertEquals(SUBNET_3, actual.getSubnetMetas().get(SUBNET_3).getId());
assertEquals(SUBNET_3, actual.getSubnetMetas().get(SUBNET_3).getName());
assertEquals(AZ_3, actual.getSubnetMetas().get(SUBNET_3).getAvailabilityZone());
assertEquals(SUBNET_CIDR_3, actual.getSubnetMetas().get(SUBNET_3).getCidr());
assertTrue(actual.getSubnetMetas().get(SUBNET_3).isPrivateSubnet());
}
use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method createEnvironment.
private Environment createEnvironment() {
Environment environment = new Environment();
environment.setName(ENV_NAME);
environment.setId(1L);
environment.setAccountId("2");
environment.setDescription("description");
environment.setCloudPlatform("AZURE");
environment.setCredential(new Credential());
environment.setLatitude(2.4);
environment.setLongitude(3.5);
environment.setLocation(LOCATION);
environment.setLocationDisplayName("London");
environment.setNetwork(new AzureNetwork());
environment.setRegions(Collections.singleton(new Region()));
return environment;
}
use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverter method convertToNetwork.
@Override
public Network convertToNetwork(BaseNetwork baseNetwork) {
AzureNetwork azureNetwork = (AzureNetwork) baseNetwork;
Map<String, Object> param = new HashMap<>();
param.put(RG_NAME, azureNetwork.getResourceGroupName());
param.put(NETWORK_ID, azureNetwork.getNetworkId());
param.put(DATABASE_PRIVATE_DS_ZONE_ID, azureNetwork.getDatabasePrivateDnsZoneId());
return new Network(null, param);
}
Aggregations