use of com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request in project cloudbreak by hortonworks.
the class NetworkV1ToNetworkV4Converter method convertToNetworkV1Request.
public NetworkV1Request convertToNetworkV1Request(NetworkV4Request network) {
NetworkV1Request response = new NetworkV1Request();
response.setAws(getIfNotNull(network.getAws(), this::convertToAwsNetworkV1Parameters));
response.setAzure(getIfNotNull(network.getAzure(), this::convertToAzureNetworkV1Parameters));
response.setGcp(getIfNotNull(network.getGcp(), this::convertToGcpNetworkV1Parameters));
response.setYarn(getIfNotNull(network.getYarn(), this::convertToYarnNetworkV1Parameters));
response.setMock(getIfNotNull(network.getMock(), this::convertToMockNetworkV1Parameters));
return response;
}
use of com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method testGetNetworkWhenHasSameSubnetIdInInstanceGroupsNetworkAws.
@Test
public void testGetNetworkWhenHasSameSubnetIdInInstanceGroupsNetworkAws() {
NetworkV1Request networkRequest = new NetworkV1Request();
AwsNetworkV1Parameters aws = new AwsNetworkV1Parameters();
aws.setSubnetId("sub1");
networkRequest.setAws(aws);
Set<InstanceGroupV1Request> instanceGroups = new HashSet<>();
InstanceGroupV1Request ig1 = new InstanceGroupV1Request();
InstanceGroupNetworkV1Request network = new InstanceGroupNetworkV1Request();
InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters = new InstanceGroupAwsNetworkV1Parameters();
awsNetworkV1Parameters.setSubnetIds(List.of("subnet1"));
network.setAws(awsNetworkV1Parameters);
ig1.setNetwork(network);
InstanceGroupV1Request ig2 = new InstanceGroupV1Request();
InstanceGroupNetworkV1Request network1 = new InstanceGroupNetworkV1Request();
InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters1 = new InstanceGroupAwsNetworkV1Parameters();
awsNetworkV1Parameters1.setSubnetIds(List.of("subnet1"));
network1.setAws(awsNetworkV1Parameters1);
ig2.setNetwork(network1);
instanceGroups.add(ig1);
instanceGroups.add(ig2);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("ANY");
NetworkV4Request networkV4Request = new NetworkV4Request();
ArgumentCaptor<Pair<NetworkV1Request, DetailedEnvironmentResponse>> networkConverterCaptor = ArgumentCaptor.forClass(Pair.class);
when(networkConverter.convertToNetworkV4Request(any())).thenReturn(networkV4Request);
NetworkV4Request actual = underTest.getNetwork(networkRequest, environment, instanceGroups);
verify(networkConverter).convertToNetworkV4Request(networkConverterCaptor.capture());
Assertions.assertEquals(networkV4Request, actual);
Pair<NetworkV1Request, DetailedEnvironmentResponse> captured = networkConverterCaptor.getValue();
Assertions.assertEquals("subnet1", captured.getKey().getAws().getSubnetId());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method testGetNetworkWhenSubnetIdsIsNullInInstanceGroupsNetworkAws.
@Test
public void testGetNetworkWhenSubnetIdsIsNullInInstanceGroupsNetworkAws() {
NetworkV1Request networkRequest = new NetworkV1Request();
AwsNetworkV1Parameters aws = new AwsNetworkV1Parameters();
aws.setSubnetId("sub1");
networkRequest.setAws(aws);
Set<InstanceGroupV1Request> instanceGroups = new HashSet<>();
InstanceGroupV1Request ig1 = new InstanceGroupV1Request();
InstanceGroupNetworkV1Request network = new InstanceGroupNetworkV1Request();
network.setAws(new InstanceGroupAwsNetworkV1Parameters());
ig1.setNetwork(network);
InstanceGroupV1Request ig2 = new InstanceGroupV1Request();
InstanceGroupNetworkV1Request network1 = new InstanceGroupNetworkV1Request();
network1.setAws(new InstanceGroupAwsNetworkV1Parameters());
ig2.setNetwork(network1);
instanceGroups.add(ig1);
instanceGroups.add(ig2);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("ANY");
NetworkV4Request networkV4Request = new NetworkV4Request();
ArgumentCaptor<Pair<NetworkV1Request, DetailedEnvironmentResponse>> networkConverterCaptor = ArgumentCaptor.forClass(Pair.class);
when(networkConverter.convertToNetworkV4Request(any())).thenReturn(networkV4Request);
NetworkV4Request actual = underTest.getNetwork(networkRequest, environment, instanceGroups);
verify(networkConverter).convertToNetworkV4Request(networkConverterCaptor.capture());
Assertions.assertEquals(networkV4Request, actual);
Pair<NetworkV1Request, DetailedEnvironmentResponse> captured = networkConverterCaptor.getValue();
Assertions.assertEquals("sub1", captured.getKey().getAws().getSubnetId());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method testGetNetworkWhenNetworkIsNullInInstanceGroups.
@Test
public void testGetNetworkWhenNetworkIsNullInInstanceGroups() {
NetworkV1Request networkRequest = new NetworkV1Request();
AwsNetworkV1Parameters aws = new AwsNetworkV1Parameters();
aws.setSubnetId("sub1");
networkRequest.setAws(aws);
Set<InstanceGroupV1Request> instanceGroups = new HashSet<>();
instanceGroups.add(new InstanceGroupV1Request());
instanceGroups.add(new InstanceGroupV1Request());
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("ANY");
NetworkV4Request networkV4Request = new NetworkV4Request();
ArgumentCaptor<Pair<NetworkV1Request, DetailedEnvironmentResponse>> networkConverterCaptor = ArgumentCaptor.forClass(Pair.class);
when(networkConverter.convertToNetworkV4Request(any())).thenReturn(networkV4Request);
NetworkV4Request actual = underTest.getNetwork(networkRequest, environment, instanceGroups);
verify(networkConverter).convertToNetworkV4Request(networkConverterCaptor.capture());
Assertions.assertEquals(networkV4Request, actual);
Pair<NetworkV1Request, DetailedEnvironmentResponse> captured = networkConverterCaptor.getValue();
Assertions.assertEquals("sub1", captured.getKey().getAws().getSubnetId());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request in project cloudbreak by hortonworks.
the class NetworkV1ToNetworkV4ConverterTest method azureNetworkV1Request.
private NetworkV1Request azureNetworkV1Request() {
NetworkV1Request networkV1Request = new NetworkV1Request();
AzureNetworkV1Parameters azureNetworkV1Parameters = new AzureNetworkV1Parameters();
azureNetworkV1Parameters.setSubnetId(SUBNET_ID);
networkV1Request.setAzure(azureNetworkV1Parameters);
return networkV1Request;
}
Aggregations