### Question:
AwsNetworkService { public List<String> getVpcCidrs(AuthenticatedContext ac, CloudStack stack) { AwsNetworkView awsNetworkView = new AwsNetworkView(stack.getNetwork()); if (awsNetworkView.isExistingVPC()) { String region = ac.getCloudContext().getLocation().getRegion().value(); AmazonEC2Client ec2Client = awsClient.createAccess(new AwsCredentialView(ac.getCloudCredential()), region); DescribeVpcsRequest vpcRequest = new DescribeVpcsRequest().withVpcIds(awsNetworkView.getExistingVpc()); Vpc vpc = ec2Client.describeVpcs(vpcRequest).getVpcs().get(0); List<String> cidrBlockAssociationSet = vpc.getCidrBlockAssociationSet().stream() .map(VpcCidrBlockAssociation::getCidrBlock) .collect(Collectors.toList()); LOGGER.info("VPC associated CIDR blocks: [{}]", cidrBlockAssociationSet); return cidrBlockAssociationSet; } else { return Collections.emptyList(); } }  List<Group> getGatewayGroups(Collection<Group> groups); List<String> getExistingSubnetCidr(AuthenticatedContext ac, CloudStack stack); boolean isMapPublicOnLaunch(AwsNetworkView awsNetworkView, AmazonEC2 amazonEC2Client); String findNonOverLappingCIDR(AuthenticatedContext ac, CloudStack stack); List<String> getVpcCidrs(AuthenticatedContext ac, CloudStack stack);  }### Answer:
@Test public void testGetVpcCidrs() { String cidr1 = "1.2.3.0/24"; String cidr2 = "10.0.0.0/8"; AuthenticatedContext authenticatedContext = mock(AuthenticatedContext.class); CloudContext cloudContext = mock(CloudContext.class); CloudStack cloudStack = mock(CloudStack.class); AmazonEC2Client ec2Client = mock(AmazonEC2Client.class); when(authenticatedContext.getCloudContext()).thenReturn(cloudContext); when(cloudStack.getNetwork()).thenReturn(new Network(new Subnet(null), Map.of("vpcId", "vpc-123"))); when(cloudContext.getLocation()).thenReturn(Location.location(Region.region("eu-west1"))); when(awsClient.createAccess(any(AwsCredentialView.class), anyString())).thenReturn(ec2Client); when(ec2Client.describeVpcs(any(DescribeVpcsRequest.class))) .thenReturn(new DescribeVpcsResult().withVpcs(new Vpc() .withCidrBlockAssociationSet(new VpcCidrBlockAssociation().withCidrBlock(cidr1), new VpcCidrBlockAssociation().withCidrBlock(cidr2)))); List<String> vpcCidrs = underTest.getVpcCidrs(authenticatedContext, cloudStack); assertTrue(vpcCidrs.contains(cidr1)); assertTrue(vpcCidrs.contains(cidr2)); }
@Test public void testGetVpcCidrsEmpty() { AuthenticatedContext authenticatedContext = mock(AuthenticatedContext.class); CloudStack cloudStack = mock(CloudStack.class); when(cloudStack.getNetwork()).thenReturn(new Network(new Subnet(null))); List<String> vpcCidrs = underTest.getVpcCidrs(authenticatedContext, cloudStack); assertTrue(vpcCidrs.isEmpty()); }