use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.
the class SubnetChooserServiceTest method testChooseSubnetsThenNetworkSelectorCalled.
@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());
}
use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.
the class SubnetChooserServiceTest method setupConnector.
private NetworkConnector setupConnector(String errorMessage) {
CloudConnector cloudConnector = mock(CloudConnector.class);
NetworkConnector networkConnector = mock(NetworkConnector.class);
SubnetSelectionResult subnetSelectionResult = StringUtils.isEmpty(errorMessage) ? new SubnetSelectionResult(List.of()) : new SubnetSelectionResult(errorMessage);
when(networkConnector.chooseSubnets(any(), any())).thenReturn(subnetSelectionResult);
when(cloudConnector.networkConnector()).thenReturn(networkConnector);
when(cloudPlatformConnectors.get(any())).thenReturn(cloudConnector);
return networkConnector;
}
use of com.sequenceiq.cloudbreak.cloud.NetworkConnector in project cloudbreak by hortonworks.
the class SubnetChooserServiceTest method testChooseSubnetsWhenAwsNoHaThenHaIsFalse.
@Test
public void testChooseSubnetsWhenAwsNoHaThenHaIsFalse() {
List<CloudSubnet> subnets = List.of();
NetworkConnector networkConnector = setupConnector();
DBStack dbStack = mock(DBStack.class);
when(dbStack.isHa()).thenReturn(false);
underTest.chooseSubnets(subnets, CloudPlatform.AWS, dbStack);
ArgumentCaptor<SubnetSelectionParameters> subnetSelectionParametersCaptor = ArgumentCaptor.forClass(SubnetSelectionParameters.class);
verify(networkConnector).chooseSubnets(eq(subnets), subnetSelectionParametersCaptor.capture());
assertTrue(subnetSelectionParametersCaptor.getValue().isPreferPrivateIfExist());
assertFalse(subnetSelectionParametersCaptor.getValue().isHa());
}
Aggregations