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