use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverterTest method testConvertWhenGatewayExists.
@Test
public void testConvertWhenGatewayExists() {
String clusterName = "cluster-name";
ClusterV4Request source = new ClusterV4Request();
GatewayV4Request gatewayJson = new GatewayV4Request();
source.setGateway(gatewayJson);
source.setBlueprintName(BLUEPRINT);
when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
Gateway gateway = new Gateway();
when(gatewayV4RequestToGatewayConverter.convert(gatewayJson)).thenReturn(gateway);
Cluster actual = underTest.convert(source);
assertThat(actual.getGateway(), is(gateway));
verify(gatewayV4RequestToGatewayConverter, times(1)).convert(gatewayJson);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY 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.base.InstanceMetadataType.GATEWAY 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);
}
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class GatewayToGatewayV4RequestConverter method convert.
public GatewayV4Request convert(Gateway gateway) {
GatewayV4Request gatewayJson = new GatewayV4Request();
gatewayJson.setPath(gateway.getPath());
gatewayJson.setTokenCert(gateway.getTokenCert());
gatewayJson.setSsoProvider(gateway.getSsoProvider());
gatewayJson.setSsoType(gateway.getSsoType());
gatewayJson.setGatewayType(gateway.getGatewayType());
gatewayJson.setTopologies(convertTopologies(gateway, gatewayJson));
return gatewayJson;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class GatewayToGatewayV4ResponseConverter method convert.
public GatewayV4Response convert(Gateway source) {
GatewayV4Response response = new GatewayV4Response();
response.setGatewayType(source.getGatewayType());
response.setPath(source.getPath());
response.setSsoProvider(source.getSsoProvider());
response.setSsoType(source.getSsoType());
response.setTokenCert(source.getTokenCert());
response.setTopologies(source.getTopologies().stream().map(t -> gatewayTopologyToGatewayTopologyV4ResponseConverter.convert(t)).collect(Collectors.toList()));
return response;
}
Aggregations