Search in sources :

Example 1 with GatewayTopologyV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response in project cloudbreak by hortonworks.

the class GatewayTopologyToGatewayTopologyV4ResponseConverterTest method testConvertWithNoServicesAndException.

@Test
public void testConvertWithNoServicesAndException() throws IOException {
    GatewayTopology source = mock(GatewayTopology.class);
    when(source.getTopologyName()).thenReturn(TOPOLOGY);
    Json json = mock(Json.class);
    when(source.getExposedServices()).thenReturn(json);
    when(json.getValue()).thenReturn("{}");
    when(json.get(ExposedServices.class)).thenThrow(new IOException("Foo"));
    GatewayTopologyV4Response result = underTest.convert(source);
    assertNotNull(result);
    assertEquals(TOPOLOGY, result.getTopologyName());
    assertNull(result.getExposedServices());
}
Also used : GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException) GatewayTopologyV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response) Test(org.junit.Test)

Example 2 with GatewayTopologyV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response in project cloudbreak by hortonworks.

the class GatewayTopologyToGatewayTopologyV4ResponseConverterTest method testConvertWithSomeServices.

@Test
public void testConvertWithSomeServices() throws IOException {
    GatewayTopology source = mock(GatewayTopology.class);
    when(source.getTopologyName()).thenReturn(TOPOLOGY);
    ExposedServices exposedServices = mock(ExposedServices.class);
    List<String> services = List.of("SERVICE1", "SERVICE2");
    when(exposedServices.getServices()).thenReturn(services);
    Json json = mock(Json.class);
    when(source.getExposedServices()).thenReturn(json);
    when(json.getValue()).thenReturn("{}");
    when(json.get(ExposedServices.class)).thenReturn(exposedServices);
    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 3 with GatewayTopologyV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response 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 4 with GatewayTopologyV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response in project cloudbreak by hortonworks.

the class GatewayTopologyToGatewayTopologyV4ResponseConverter method convert.

public GatewayTopologyV4Response convert(GatewayTopology source) {
    GatewayTopologyV4Response response = new GatewayTopologyV4Response();
    ExposedServices exposedServices = getExposedServices(source);
    if (exposedServices != null) {
        response.setExposedServices(exposedServices.getServices());
    }
    response.setTopologyName(source.getTopologyName());
    return response;
}
Also used : ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) GatewayTopologyV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response)

Aggregations

GatewayTopologyV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response)4 Json (com.sequenceiq.cloudbreak.common.json.Json)3 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)3 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)3 Test (org.junit.Test)3 IOException (java.io.IOException)1