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;
}
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);
}
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()));
}
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."));
}
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."));
}
Aggregations