@Test public void testChooseSubnetsThenCloudPlatformConnectorGetIsCalled() { List<CloudSubnet> subnets = List.of(); setupConnector(); DBStack dbStack = new DBStack(); dbStack.setCloudPlatform("MyCloudPlatform"); dbStack.setPlatformVariant("MyPlatformVariant"); underTest.chooseSubnets(subnets, CloudPlatform.AWS, dbStack); ArgumentCaptor<CloudPlatformVariant> cloudPlatformVariantArgumentCaptor = ArgumentCaptor.forClass(CloudPlatformVariant.class); verify(cloudPlatformConnectors).get(cloudPlatformVariantArgumentCaptor.capture()); assertEquals("MyCloudPlatform", cloudPlatformVariantArgumentCaptor.getValue().getPlatform().value()); assertEquals("MyPlatformVariant", cloudPlatformVariantArgumentCaptor.getValue().getVariant().value()); }
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);  }