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