@Test public void testChooseSubnetsThenNetworkSelectorCalled() { List<CloudSubnet> subnets = List.of( new CloudSubnet(SUBNET_1, "", AVAILABILITY_ZONE_A, ""), new CloudSubnet(SUBNET_2, "", AVAILABILITY_ZONE_B, ""), new CloudSubnet(SUBNET_3, "", AVAILABILITY_ZONE_B, "") ); NetworkConnector networkConnector = setupConnector(); underTest.chooseSubnets(subnets, CloudPlatform.AWS, new DBStack()); ArgumentCaptor<SubnetSelectionParameters> subnetSelectionParametersCaptor = ArgumentCaptor.forClass(SubnetSelectionParameters.class); verify(networkConnector).chooseSubnets(eq(subnets), subnetSelectionParametersCaptor.capture()); assertTrue(subnetSelectionParametersCaptor.getValue().isPreferPrivateIfExist()); assertTrue(subnetSelectionParametersCaptor.getValue().isHa()); }
public List<CloudSubnet> chooseSubnets(List<CloudSubnet> subnetMetas, CloudPlatform cloudPlatform, DBStack dbStack) { NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())) .networkConnector(); SubnetSelectionParameters build = SubnetSelectionParameters .builder() .withHa(dbStack.isHa()) .withPreferPrivateIfExist() .build(); SubnetSelectionResult subnetSelectionResult = networkConnector.chooseSubnets(subnetMetas, build); if (subnetSelectionResult.hasError()) { throw new BadRequestException(subnetSelectionResult.getErrorMessage()); } return subnetSelectionResult.getResult(); }
SubnetChooserService { public List<CloudSubnet> chooseSubnets(List<CloudSubnet> subnetMetas, CloudPlatform cloudPlatform, DBStack dbStack) { NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())) .networkConnector(); SubnetSelectionParameters build = SubnetSelectionParameters .builder() .withHa(dbStack.isHa()) .withPreferPrivateIfExist() .build(); SubnetSelectionResult subnetSelectionResult = networkConnector.chooseSubnets(subnetMetas, build); if (subnetSelectionResult.hasError()) { throw new BadRequestException(subnetSelectionResult.getErrorMessage()); } return subnetSelectionResult.getResult(); } }
SubnetChooserService { public List<CloudSubnet> chooseSubnets(List<CloudSubnet> subnetMetas, CloudPlatform cloudPlatform, DBStack dbStack) { NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())) .networkConnector(); SubnetSelectionParameters build = SubnetSelectionParameters .builder() .withHa(dbStack.isHa()) .withPreferPrivateIfExist() .build(); SubnetSelectionResult subnetSelectionResult = networkConnector.chooseSubnets(subnetMetas, build); if (subnetSelectionResult.hasError()) { throw new BadRequestException(subnetSelectionResult.getErrorMessage()); } return subnetSelectionResult.getResult(); }  }
SubnetChooserService { public List<CloudSubnet> chooseSubnets(List<CloudSubnet> subnetMetas, CloudPlatform cloudPlatform, DBStack dbStack) { NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())) .networkConnector(); SubnetSelectionParameters build = SubnetSelectionParameters .builder() .withHa(dbStack.isHa()) .withPreferPrivateIfExist() .build(); SubnetSelectionResult subnetSelectionResult = networkConnector.chooseSubnets(subnetMetas, build); if (subnetSelectionResult.hasError()) { throw new BadRequestException(subnetSelectionResult.getErrorMessage()); } return subnetSelectionResult.getResult(); }  List<CloudSubnet> chooseSubnets(List<CloudSubnet> subnetMetas, CloudPlatform cloudPlatform, DBStack dbStack); }
SubnetChooserService { public List<CloudSubnet> chooseSubnets(List<CloudSubnet> subnetMetas, CloudPlatform cloudPlatform, DBStack dbStack) { NetworkConnector networkConnector = cloudPlatformConnectors.get(new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant())) .networkConnector(); SubnetSelectionParameters build = SubnetSelectionParameters .builder() .withHa(dbStack.isHa()) .withPreferPrivateIfExist() .build(); SubnetSelectionResult subnetSelectionResult = networkConnector.chooseSubnets(subnetMetas, build); if (subnetSelectionResult.hasError()) { throw new BadRequestException(subnetSelectionResult.getErrorMessage()); } return subnetSelectionResult.getResult(); }  List<CloudSubnet> chooseSubnets(List<CloudSubnet> subnetMetas, CloudPlatform cloudPlatform, DBStack dbStack);  }