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);
}
Aggregations