Search in sources :

Example 21 with GatewayV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request in project cloudbreak by hortonworks.

the class ClusterRequestToGatewayConverterTest method testThrowsExceptionWhenRequestIsInvalid.

@Test(expected = BadRequestException.class)
public void testThrowsExceptionWhenRequestIsInvalid() {
    GatewayV4Request source = new GatewayV4Request();
    underTest.convert(source);
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Test(org.junit.Test)

Example 22 with GatewayV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request in project cloudbreak by hortonworks.

the class GatewayToGatewayJsonConverterTest method testConvert.

@Test
public void testConvert() {
    Gateway gateway = new Gateway();
    gateway.setPath(PATH);
    gateway.setSsoProvider(SSO_PROVIDER);
    gateway.setSsoType(SSOType.SSO_PROVIDER);
    gateway.setGatewayType(GatewayType.CENTRAL);
    gateway.setTokenCert(TOKEN_CERT);
    gateway.setSignKey(SIGN_KEY);
    gateway.setSignCert(SIGN_CERT);
    gateway.setTopologies(Sets.newHashSet(new GatewayTopology(), new GatewayTopology()));
    GatewayV4Request result = underTest.convert(gateway);
    assertEquals(SSOType.SSO_PROVIDER, result.getSsoType());
    assertEquals(TOKEN_CERT, result.getTokenCert());
    assertEquals(GatewayType.CENTRAL, result.getGatewayType());
    assertEquals(result.getTopologies().size(), 2);
    assertEquals(SSO_PROVIDER, result.getSsoProvider());
    assertEquals(PATH, result.getPath());
    assertEquals(2L, result.getTopologies().size());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Test(org.junit.Test)

Example 23 with GatewayV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request in project cloudbreak by hortonworks.

the class DistroXClusterToClusterConverterTest method testConvertWithEnvWhenExposedServiceIsNotEmptyThenItShouldBeConverted.

@Test
void testConvertWithEnvWhenExposedServiceIsNotEmptyThenItShouldBeConverted() {
    GatewayV4Request gr = new GatewayV4Request();
    when(gatewayConverter.convert(distroXV1RequestInput.getCluster().getExposedServices())).thenReturn(gr);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ClusterV4Request result = testConvertDistroXV1RequestWithEnvironment();
    assertNotNull(result);
    assertEquals(gr, result.getGateway());
    verify(gatewayConverter, times(1)).convert(anyList());
    verify(gatewayConverter, times(1)).convert(distroXV1RequestInput.getCluster().getExposedServices());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Test(org.junit.jupiter.api.Test)

Example 24 with GatewayV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request in project cloudbreak by hortonworks.

the class DistroXClusterToClusterConverterTest method testConvertWithEnvWhenExposedServiceIsEmptyThenAllShouldBeConverted.

@Test
void testConvertWithEnvWhenExposedServiceIsEmptyThenAllShouldBeConverted() {
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    distroXV1RequestInput.getCluster().setExposedServices(new ArrayList<>(0));
    GatewayV4Request gr = new GatewayV4Request();
    when(gatewayConverter.convert(List.of("ALL"))).thenReturn(gr);
    ClusterV4Request result = testConvertDistroXV1RequestWithEnvironment();
    assertNotNull(result);
    assertEquals(gr, result.getGateway());
    verify(gatewayConverter, times(1)).convert(anyList());
    verify(gatewayConverter, times(1)).convert(List.of("ALL"));
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Test(org.junit.jupiter.api.Test)

Example 25 with GatewayV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request in project cloudbreak by hortonworks.

the class ClusterV4RequestToClusterConverter method convertGateway.

private void convertGateway(ClusterV4Request source, Cluster cluster) {
    GatewayV4Request gatewayRequest = source.getGateway();
    if (gatewayRequest != null) {
        if (StringUtils.isEmpty(gatewayRequest.getPath())) {
            gatewayRequest.setPath(source.getName());
        }
        Gateway gateway = gatewayV4RequestToGatewayConverter.convert(gatewayRequest);
        if (gateway != null) {
            cluster.setGateway(gateway);
            gateway.setCluster(cluster);
        }
    }
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)

Aggregations

GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)27 Test (org.junit.Test)15 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)13 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)7 Test (org.junit.jupiter.api.Test)6 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)5 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)4 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)4 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1