Search in sources :

Example 1 with GatewayTopologyV4Request

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

the class GatewayTopologyToGatewayTopologyV4RequestConverter method convert.

public GatewayTopologyV4Request convert(GatewayTopology gatewayTopology) {
    GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
    gatewayTopologyJson.setTopologyName(gatewayTopology.getTopologyName());
    Json exposedJson = gatewayTopology.getExposedServices();
    if (exposedJson != null && StringUtils.isNotEmpty(exposedJson.getValue())) {
        try {
            gatewayTopologyJson.setExposedServices(exposedJson.get(ExposedServices.class).getServices());
        } catch (IOException e) {
            LOGGER.info("Failed to add exposedServices to response", e);
            throw new CloudbreakApiException("Failed to add exposedServices to response", e);
        }
    }
    return gatewayTopologyJson;
}
Also used : GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException)

Example 2 with GatewayTopologyV4Request

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

the class GatewayTopologyV4RequestToGatewayTopologyConverterTest method testConvertWithValidationError.

@Test
public void testConvertWithValidationError() {
    GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
    gatewayTopologyJson.setExposedServices(Collections.singletonList(exposedService("CLOUDERA_MANAGER_UI").getKnoxService()));
    when(gatewayTopologyV4RequestValidator.validate(any(GatewayTopologyV4Request.class))).thenReturn(new ValidationResultBuilder().error("INVALID").build());
    thrown.expect(BadRequestException.class);
    underTest.convert(gatewayTopologyJson);
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) Test(org.junit.Test)

Example 3 with GatewayTopologyV4Request

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

the class GatewayTopologyV4RequestToGatewayTopologyConverterTest method testConvert.

@Test
public void testConvert() throws IOException {
    GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
    gatewayTopologyJson.setTopologyName(TOPOLOGY_NAME);
    List<String> allServices = Collections.singletonList("ALL");
    ExposedServices exposedServices = new ExposedServices();
    exposedServices.setServices(allServices);
    gatewayTopologyJson.setExposedServices(allServices);
    when(gatewayTopologyV4RequestValidator.validate(any(GatewayTopologyV4Request.class))).thenReturn(new ValidationResultBuilder().build());
    when(gatewayTopologyV4RequestToExposedServicesConverter.convert(any(GatewayTopologyV4Request.class))).thenReturn(exposedServices);
    GatewayTopology result = underTest.convert(gatewayTopologyJson);
    assertEquals(TOPOLOGY_NAME, result.getTopologyName());
    assertTrue(result.getExposedServices().get(ExposedServices.class).getServices().contains("ALL"));
// assertTrue(result.getExposedServices().get(ExposedServices.class).getFullServiceList().containsAll(ExposedService.getAllKnoxExposed()));
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Test(org.junit.Test)

Example 4 with GatewayTopologyV4Request

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

the class GatewayTopologyV4RequestValidatorTest method testWithKnoxServiceButNoTopologyName.

@Test
public void testWithKnoxServiceButNoTopologyName() {
    GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
    gatewayTopologyJson.setExposedServices(Collections.singletonList(exposedService("CLOUDERA_MANAGER_UI").getKnoxService()));
    ValidationResult result = underTest.validate(gatewayTopologyJson);
    assertEquals(1L, result.getErrors().size());
    assertTrue(result.getErrors().get(0).contains("topologyName must be set in gateway topology."));
}
Also used : GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Example 5 with GatewayTopologyV4Request

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

the class GatewayTopologyV4RequestValidatorTest method testWithNoTopologyName.

@Test
public void testWithNoTopologyName() {
    GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
    ValidationResult result = underTest.validate(gatewayTopologyJson);
    assertEquals(1L, result.getErrors().size());
    assertTrue(result.getErrors().get(0).contains("topologyName must be set in gateway topology."));
}
Also used : GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Aggregations

GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)23 Test (org.junit.Test)15 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)8 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)6 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)5 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)5 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)5 Json (com.sequenceiq.cloudbreak.common.json.Json)4 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)2 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)1 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)1 IOException (java.io.IOException)1