Search in sources :

Example 1 with MockNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.MockNetworkV4Parameters in project cloudbreak by hortonworks.

the class NetworkV1ToNetworkV4Converter method convertToMockNetworkParams.

private MockNetworkV4Parameters convertToMockNetworkParams(Pair<MockNetworkV1Parameters, EnvironmentNetworkResponse> source) {
    EnvironmentNetworkResponse value = source.getValue();
    MockNetworkV1Parameters key = source.getKey();
    MockNetworkV4Parameters params = new MockNetworkV4Parameters();
    if (key != null) {
        String subnetId = key.getSubnetId();
        if (value != null) {
            evaluateIfTrueDoOtherwise(subnetId, StringUtils::isNotEmpty, params::setSubnetId, s -> params.setSubnetId(value.getPreferedSubnetId()));
        }
        params.setInternetGatewayId(key.getInternetGatewayId());
        params.setVpcId(key.getVpcId());
    }
    return params;
}
Also used : MockNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.mock.MockNetworkV1Parameters) StringUtils(org.apache.commons.lang3.StringUtils) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) MockNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.MockNetworkV4Parameters)

Example 2 with MockNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.MockNetworkV4Parameters in project cloudbreak by hortonworks.

the class NetworkV1ToNetworkV4ConverterTest method testConvertToNetworkV4RequestWhenMockNetworkKeyIsNullThenBasicSettingShouldHappen.

@Test
void testConvertToNetworkV4RequestWhenMockNetworkKeyIsNullThenBasicSettingShouldHappen() {
    DetailedEnvironmentResponse input = createMockEnvironment();
    NetworkV4Request result = underTest.convertToNetworkV4Request(new ImmutablePair<>(null, input));
    Assertions.assertNotNull(result);
    MockNetworkV4Parameters mockNetworkResult = result.getMock();
    Assertions.assertNotNull(mockNetworkResult);
    Assertions.assertNull(mockNetworkResult.getVpcId());
    Assertions.assertNull(mockNetworkResult.getInternetGatewayId());
    assertTrue(StringUtils.isNotEmpty(mockNetworkResult.getSubnetId()));
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) MockNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.MockNetworkV4Parameters) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) Test(org.junit.jupiter.api.Test)

Example 3 with MockNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.MockNetworkV4Parameters in project cloudbreak by hortonworks.

the class TestUtil method networkV4RequestForMock.

public static NetworkV4Request networkV4RequestForMock() {
    NetworkV4Request r = new NetworkV4Request();
    r.setMock(mockNetworkV4Parameters());
    r.setCloudPlatform(CloudPlatform.MOCK);
    r.setSubnetCIDR("0.0.0.0/0");
    return r;
}
Also used : NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)

Example 4 with MockNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.MockNetworkV4Parameters in project cloudbreak by hortonworks.

the class TestUtil method mockNetworkV4Parameters.

public static MockNetworkV4Parameters mockNetworkV4Parameters() {
    MockNetworkV4Parameters p = new MockNetworkV4Parameters();
    p.setSubnetId("someMockSubnet");
    p.setVpcId("someMockVpc");
    p.setInternetGatewayId("someMockInternetGatewayId");
    return p;
}
Also used : MockNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.MockNetworkV4Parameters)

Aggregations

MockNetworkV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.MockNetworkV4Parameters)3 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)2 MockNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.mock.MockNetworkV1Parameters)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Test (org.junit.jupiter.api.Test)1