Search in sources :

Example 6 with GatewayV4Request

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

the class StackV4RequestToGatewayConverterTest method shouldCreateCorrectSsoUrlWhenClusterNameisProvided.

@Test
public void shouldCreateCorrectSsoUrlWhenClusterNameisProvided() {
    GatewayV4Request gatewayJson = new GatewayV4Request();
    gatewayJson.setPath("funnyPath");
    gatewayJson.setTopologies(Arrays.asList(getGatewayTopologyV4Request()));
    StackV4Request source = generateStackV4Request(gatewayJson);
    when(gatewayJsonValidator.validate(gatewayJson)).thenReturn(ValidationResult.builder().build());
    doAnswer(i -> {
        Gateway gw = i.getArgument(1);
        gw.setSsoProvider("SSOPROVIDER");
        gw.setPath(gatewayJson.getPath());
        gw.setTopologies(GATEWAY_TOPOLOGY);
        gw.setGatewayType(GatewayType.CENTRAL);
        return null;
    }).when(convertUtil).setBasicProperties(eq(gatewayJson), any(Gateway.class));
    Gateway result = underTest.convert(source);
    assertEquals("SSOPROVIDER", result.getSsoProvider());
    assertEquals("funnyPath", result.getPath());
    assertTrue(EqualsBuilder.reflectionEquals(GATEWAY_TOPOLOGY, result.getTopologies()));
    assertEquals(GatewayType.CENTRAL, result.getGatewayType());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.Test)

Example 7 with GatewayV4Request

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

the class StackV4RequestToTemplatePreparationObjectConverterTest method testConvertWhenGatewayExistsInStack.

@Test
public void testConvertWhenGatewayExistsInStack() {
    when(stackV4RequestToGatewayConverter.convert(source)).thenReturn(new Gateway());
    when(cluster.getGateway()).thenReturn(new GatewayV4Request());
    TemplatePreparationObject result = underTest.convert(source);
    assertNotNull(result.getGatewayView());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.Test)

Example 8 with GatewayV4Request

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

the class DistroXClusterToClusterConverterTest method testConvertWithoutEnvWhenExposedServiceIsEmptyThenAllShouldBeConverted.

@Test
void testConvertWithoutEnvWhenExposedServiceIsEmptyThenAllShouldBeConverted() {
    distroXV1RequestInput.getCluster().setExposedServices(new ArrayList<>(0));
    GatewayV4Request gr = new GatewayV4Request();
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    when(gatewayConverter.convert(List.of("ALL"))).thenReturn(gr);
    ClusterV4Request result = testConvertDistroXV1Request();
    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 9 with GatewayV4Request

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

the class DistroXClusterToClusterConverterTest method testConvertWithoutEnvWhenExposedServiceIsNotEmptyThenItShouldBeConverted.

@Test
void testConvertWithoutEnvWhenExposedServiceIsNotEmptyThenItShouldBeConverted() {
    GatewayV4Request gr = new GatewayV4Request();
    when(gatewayConverter.convert(distroXV1RequestInput.getCluster().getExposedServices())).thenReturn(gr);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ClusterV4Request result = testConvertDistroXV1Request();
    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 10 with GatewayV4Request

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

the class ClusterRequestToGatewayConverterTest method testConvertNewTopologies.

@Test
public void testConvertNewTopologies() {
    GatewayV4Request source = new GatewayV4Request();
    GatewayTopologyV4Request topology1 = new GatewayTopologyV4Request();
    topology1.setTopologyName("topology1");
    source.setTopologies(Collections.singletonList(topology1));
    Gateway result = underTest.convert(source);
    assertFalse(result.getTopologies().isEmpty());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) Test(org.junit.Test)

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