@Test public void testChooseSubnetsWhenSubnetChooserReturnsErrorThenThrows() { List<CloudSubnet> subnets = List.of(); setupConnector("my error message"); DBStack dbStack = mock(DBStack.class); when(dbStack.isHa()).thenReturn(true); thrown.expect(BadRequestException.class); thrown.expectMessage("my error message"); underTest.chooseSubnets(subnets, CloudPlatform.AWS, dbStack); }
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);  }