Search in sources :

Example 1 with AwsEnvironmentNetworkConverter

use of com.sequenceiq.environment.network.v1.converter.AwsEnvironmentNetworkConverter in project cloudbreak by hortonworks.

the class EnvironmentNetworkServiceTest method testCreateNetworkShouldReturnWithANewNetwork.

@Test
void testCreateNetworkShouldReturnWithANewNetwork() {
    EnvironmentDto environmentDto = EnvironmentDto.builder().withCloudPlatform(CLOUD_PLATFORM).withCreator(USER_CRN).build();
    BaseNetwork baseNetwork = new AwsNetwork();
    NetworkCreationRequest networkCreationRequest = new NetworkCreationRequest.Builder().build();
    CreatedCloudNetwork createdCloudNetwork = new CreatedCloudNetwork();
    AwsEnvironmentNetworkConverter networkConverter = Mockito.mock(AwsEnvironmentNetworkConverter.class);
    when(cloudConnector.networkConnector()).thenReturn(networkConnector);
    when(networkCreationRequestFactory.create(environmentDto)).thenReturn(networkCreationRequest);
    when(networkConnector.createNetworkWithSubnets(networkCreationRequest)).thenReturn(createdCloudNetwork);
    when(environmentNetworkConverterMap.get(CloudPlatform.valueOf(CLOUD_PLATFORM))).thenReturn(networkConverter);
    when(networkConverter.setCreatedCloudNetwork(baseNetwork, createdCloudNetwork)).thenReturn(baseNetwork);
    BaseNetwork actual = underTest.createCloudNetwork(environmentDto, baseNetwork);
    verify(cloudConnector).networkConnector();
    verify(cloudPlatformConnectors).get(any(CloudPlatformVariant.class));
    verify(networkCreationRequestFactory).create(environmentDto);
    verify(networkConnector).createNetworkWithSubnets(networkCreationRequest);
    verify(environmentNetworkConverterMap).get(CloudPlatform.valueOf(CLOUD_PLATFORM));
    verify(networkConverter).setCreatedCloudNetwork(baseNetwork, createdCloudNetwork);
    assertEquals(baseNetwork, actual);
}
Also used : AwsEnvironmentNetworkConverter(com.sequenceiq.environment.network.v1.converter.AwsEnvironmentNetworkConverter) BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) NetworkCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest) CreatedCloudNetwork(com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)1 NetworkCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)1 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)1 AwsEnvironmentNetworkConverter (com.sequenceiq.environment.network.v1.converter.AwsEnvironmentNetworkConverter)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1