Search in sources :

Example 6 with EnvironmentNetworkGcpParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams in project cloudbreak by hortonworks.

the class GcpEnvironmentNetworkConverterTest method getNoPublicIpAttributeForLegacyNetwork.

@Test
void getNoPublicIpAttributeForLegacyNetwork() {
    EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
    EnvironmentNetworkGcpParams environmentNetworkGcpParams = mock(EnvironmentNetworkGcpParams.class);
    when(environmentNetworkResponse.getGcp()).thenReturn(environmentNetworkGcpParams);
    when(environmentNetworkGcpParams.getNoPublicIp()).thenReturn(true);
    Map<String, Object> result = converter.getAttributesForLegacyNetwork(environmentNetworkResponse);
    assertEquals(true, result.get("noPublicIp"));
}
Also used : EnvironmentNetworkGcpParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 7 with EnvironmentNetworkGcpParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams in project cloudbreak by hortonworks.

the class GcpEnvironmentNetworkConverterTest method getSharedProjectIdAttributeForLegacyNetwork.

@Test
void getSharedProjectIdAttributeForLegacyNetwork() {
    EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
    EnvironmentNetworkGcpParams environmentNetworkGcpParams = mock(EnvironmentNetworkGcpParams.class);
    when(environmentNetworkResponse.getGcp()).thenReturn(environmentNetworkGcpParams);
    when(environmentNetworkGcpParams.getSharedProjectId()).thenReturn(GCP_SHARED_PROJECT_ID);
    Map<String, Object> result = converter.getAttributesForLegacyNetwork(environmentNetworkResponse);
    assertEquals(GCP_SHARED_PROJECT_ID, result.get("sharedProjectId"));
}
Also used : EnvironmentNetworkGcpParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 8 with EnvironmentNetworkGcpParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams in project cloudbreak by hortonworks.

the class GcpEnvironmentNetworkConverterTest method testAllNullAttributesForLegacyNetwork.

@Test
void testAllNullAttributesForLegacyNetwork() {
    EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
    EnvironmentNetworkGcpParams environmentNetworkGcpParams = mock(EnvironmentNetworkGcpParams.class);
    when(environmentNetworkResponse.getGcp()).thenReturn(environmentNetworkGcpParams);
    when(environmentNetworkGcpParams.getNetworkId()).thenReturn(null);
    when(environmentNetworkGcpParams.getNoFirewallRules()).thenReturn(null);
    when(environmentNetworkGcpParams.getNoPublicIp()).thenReturn(null);
    when(environmentNetworkGcpParams.getSharedProjectId()).thenReturn(null);
    Map<String, Object> result = converter.getAttributesForLegacyNetwork(environmentNetworkResponse);
    assertFalse(result.containsKey("networkId"));
}
Also used : EnvironmentNetworkGcpParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 9 with EnvironmentNetworkGcpParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams in project cloudbreak by hortonworks.

the class NetworkV1ToNetworkV4ConverterTest method testConvertToNetworkV4RequestWhenGcpNetworkKeyIsNullThenBasicSettingShouldHappen.

@Test
void testConvertToNetworkV4RequestWhenGcpNetworkKeyIsNullThenBasicSettingShouldHappen() {
    DetailedEnvironmentResponse input = createGcpEnvironment();
    NetworkV4Request result = underTest.convertToNetworkV4Request(new ImmutablePair<>(null, input));
    Assertions.assertNotNull(result);
    GcpNetworkV4Parameters gcpNetworkResult = result.getGcp();
    EnvironmentNetworkGcpParams inputGcpNetwork = input.getNetwork().getGcp();
    Assertions.assertNotNull(gcpNetworkResult);
    assertEquals(inputGcpNetwork.getNetworkId(), gcpNetworkResult.getNetworkId());
    assertEquals(inputGcpNetwork.getNoPublicIp(), gcpNetworkResult.getNoPublicIp());
    assertEquals(inputGcpNetwork.getSharedProjectId(), gcpNetworkResult.getSharedProjectId());
    assertEquals(inputGcpNetwork.getNoFirewallRules(), gcpNetworkResult.getNoFirewallRules());
}
Also used : GcpNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.GcpNetworkV4Parameters) EnvironmentNetworkGcpParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) Test(org.junit.jupiter.api.Test)

Example 10 with EnvironmentNetworkGcpParams

use of com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams in project cloudbreak by hortonworks.

the class NetworkV1ToNetworkV4ConverterTest method createEnvironmentNetworkGcpParams.

private EnvironmentNetworkGcpParams createEnvironmentNetworkGcpParams() {
    EnvironmentNetworkGcpParams gcpParams = new EnvironmentNetworkGcpParams();
    gcpParams.setSharedProjectId("someSharedProjectId");
    gcpParams.setNoPublicIp(true);
    gcpParams.setNoFirewallRules(true);
    gcpParams.setNetworkId("someNetworkId");
    return gcpParams;
}
Also used : EnvironmentNetworkGcpParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams)

Aggregations

EnvironmentNetworkGcpParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams)10 Test (org.junit.jupiter.api.Test)6 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)5 GcpNetworkV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.GcpNetworkV4Parameters)1 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 HashMap (java.util.HashMap)1