@Test void testGetNetworkCidr() { Credential credential = mock(Credential.class); CloudCredential cloudCredential = mock(CloudCredential.class); Network network = mock(Network.class); String networkCidr = "10.0.0.0/16"; when(credentialToCloudCredentialConverter.convert(credential)).thenReturn(cloudCredential); when(cloudConnector.networkConnector()).thenReturn(networkConnector); when(networkConnector.getNetworkCidr(network, cloudCredential)).thenReturn(new NetworkCidr(networkCidr)); NetworkCidr result = underTest.getNetworkCidr(network, "AWS", credential); assertEquals(networkCidr, result.getCidr()); }
public NetworkCidr getNetworkCidr(Network network, String cloudPlatform, Credential credential) { if (network == null) { LOGGER.info("Could not fetch network cidr from {}, because the network is null", cloudPlatform); return null; } NetworkConnector networkConnector = getNetworkConnector(cloudPlatform) .orElseThrow(() -> new BadRequestException("No network connector for cloud platform: " + cloudPlatform)); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential); return networkConnector.getNetworkCidr(network, cloudCredential); }
EnvironmentNetworkService { public NetworkCidr getNetworkCidr(Network network, String cloudPlatform, Credential credential) { if (network == null) { LOGGER.info("Could not fetch network cidr from {}, because the network is null", cloudPlatform); return null; } NetworkConnector networkConnector = getNetworkConnector(cloudPlatform) .orElseThrow(() -> new BadRequestException("No network connector for cloud platform: " + cloudPlatform)); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential); return networkConnector.getNetworkCidr(network, cloudCredential); } }
EnvironmentNetworkService { public NetworkCidr getNetworkCidr(Network network, String cloudPlatform, Credential credential) { if (network == null) { LOGGER.info("Could not fetch network cidr from {}, because the network is null", cloudPlatform); return null; } NetworkConnector networkConnector = getNetworkConnector(cloudPlatform) .orElseThrow(() -> new BadRequestException("No network connector for cloud platform: " + cloudPlatform)); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential); return networkConnector.getNetworkCidr(network, cloudCredential); } EnvironmentNetworkService(
            CloudPlatformConnectors cloudPlatformConnectors,
            NetworkCreationRequestFactory networkCreationRequestFactory,
            Map<CloudPlatform, EnvironmentNetworkConverter> environmentNetworkConverterMap,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter); }
EnvironmentNetworkService { public NetworkCidr getNetworkCidr(Network network, String cloudPlatform, Credential credential) { if (network == null) { LOGGER.info("Could not fetch network cidr from {}, because the network is null", cloudPlatform); return null; } NetworkConnector networkConnector = getNetworkConnector(cloudPlatform) .orElseThrow(() -> new BadRequestException("No network connector for cloud platform: " + cloudPlatform)); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential); return networkConnector.getNetworkCidr(network, cloudCredential); } EnvironmentNetworkService(
            CloudPlatformConnectors cloudPlatformConnectors,
            NetworkCreationRequestFactory networkCreationRequestFactory,
            Map<CloudPlatform, EnvironmentNetworkConverter> environmentNetworkConverterMap,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter); BaseNetwork createCloudNetwork(EnvironmentDto environment, BaseNetwork baseNetwork); NetworkCidr getNetworkCidr(Network network, String cloudPlatform, Credential credential); void deleteNetwork(EnvironmentDto environment); }
EnvironmentNetworkService { public NetworkCidr getNetworkCidr(Network network, String cloudPlatform, Credential credential) { if (network == null) { LOGGER.info("Could not fetch network cidr from {}, because the network is null", cloudPlatform); return null; } NetworkConnector networkConnector = getNetworkConnector(cloudPlatform) .orElseThrow(() -> new BadRequestException("No network connector for cloud platform: " + cloudPlatform)); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential); return networkConnector.getNetworkCidr(network, cloudCredential); } EnvironmentNetworkService(
            CloudPlatformConnectors cloudPlatformConnectors,
            NetworkCreationRequestFactory networkCreationRequestFactory,
            Map<CloudPlatform, EnvironmentNetworkConverter> environmentNetworkConverterMap,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter); BaseNetwork createCloudNetwork(EnvironmentDto environment, BaseNetwork baseNetwork); NetworkCidr getNetworkCidr(Network network, String cloudPlatform, Credential credential); void deleteNetwork(EnvironmentDto environment);  }