Search in sources :

Example 16 with GatewayTopology

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

Example 17 with GatewayTopology

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());
}
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 18 with GatewayTopology

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")));
}
Also used : GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Json(com.sequenceiq.cloudbreak.common.json.Json) Test(org.junit.Test)

Example 19 with GatewayTopology

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());
}
Also used : ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Json(com.sequenceiq.cloudbreak.common.json.Json) GatewayTopologyV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response) Test(org.junit.Test)

Example 20 with GatewayTopology

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;
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Aggregations

GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)23 Test (org.junit.Test)11 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)9 Json (com.sequenceiq.cloudbreak.common.json.Json)7 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)7 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)5 GatewayTopologyV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response)3 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)3 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)3 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)2 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)2 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)2 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)2 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)2 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)2 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)2 Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)2