Search in sources :

Example 36 with GATEWAY

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);
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 37 with GATEWAY

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());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Test(org.junit.Test)

Example 38 with GATEWAY

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);
        }
    }
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)

Example 39 with GATEWAY

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;
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)

Example 40 with GATEWAY

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;
}
Also used : GatewayV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.GatewayV4Response)

Aggregations

Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)20 Test (org.junit.Test)18 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)16 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)16 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)15 Set (java.util.Set)15 Map (java.util.Map)14 List (java.util.List)13 Test (org.junit.jupiter.api.Test)12 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)10 Json (com.sequenceiq.cloudbreak.common.json.Json)9 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)9 Optional (java.util.Optional)9 Collectors (java.util.stream.Collectors)9 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)8 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)8 HashSet (java.util.HashSet)8 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)7 InstanceMetaDataService (com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService)7