use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.
the class GatewayConvertUtilTest method testSetMultipleTopologies.
@Test
public void testSetMultipleTopologies() {
GatewayV4Request source = new GatewayV4Request();
GatewayTopologyV4Request topology1 = new GatewayTopologyV4Request();
topology1.setTopologyName("topology1");
topology1.setExposedServices(Collections.singletonList("AMBARI"));
GatewayTopologyV4Request topology2 = new GatewayTopologyV4Request();
topology2.setTopologyName("topology2");
topology2.setExposedServices(Collections.singletonList("ALL"));
source.setTopologies(Arrays.asList(topology1, topology2));
Gateway result = new Gateway();
when(gatewayTopologyV4RequestToGatewayTopologyConverter.convert(any())).thenReturn(new GatewayTopology());
underTest.setTopologies(source, result);
verify(gatewayTopologyV4RequestToGatewayTopologyConverter, times(2)).convert(any());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology 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());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.
the class GatewayTopologyToGatewayTopologyJsonConverterTest method testConvert.
@Test
public void testConvert() {
String topologyName = "topology1";
GatewayTopology gatewayTopology = new GatewayTopology();
gatewayTopology.setTopologyName(topologyName);
ExposedServices exposedServices = new ExposedServices();
exposedServices.setServices(List.of("SERVICE1", "SERVICE2"));
gatewayTopology.setExposedServices(new Json(exposedServices));
GatewayTopologyV4Request result = underTest.convert(gatewayTopology);
assertEquals(topologyName, result.getTopologyName());
assertEquals(2, result.getExposedServices().size());
assertTrue(result.getExposedServices().containsAll(List.of("SERVICE1", "SERVICE2")));
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.
the class GatewayTopologyToGatewayTopologyV4ResponseConverterTest method testConvertWithNoServicesAndEmptyList.
@Test
public void testConvertWithNoServicesAndEmptyList() throws IOException {
GatewayTopology source = mock(GatewayTopology.class);
when(source.getTopologyName()).thenReturn(TOPOLOGY);
ExposedServices exposedServices = mock(ExposedServices.class);
List<String> services = Collections.emptyList();
when(exposedServices.getServices()).thenReturn(services);
Json json = mock(Json.class);
when(json.get(ExposedServices.class)).thenReturn(exposedServices);
when(json.getValue()).thenReturn("{}");
when(source.getExposedServices()).thenReturn(json);
GatewayTopologyV4Response result = underTest.convert(source);
assertNotNull(result);
assertEquals(TOPOLOGY, result.getTopologyName());
assertEquals(services, result.getExposedServices());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.
the class GatewayTopologyV4RequestToGatewayTopologyConverter method convert.
public GatewayTopology convert(GatewayTopologyV4Request source) {
ValidationResult validationResult = validator.validate(source);
if (validationResult.getState() == State.ERROR) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
GatewayTopology gatewayTopology = new GatewayTopology();
gatewayTopology.setTopologyName(source.getTopologyName());
convertExposedServices(gatewayTopology, source);
return gatewayTopology;
}
Aggregations