ZonesCommand extends CommandSupport { @Override public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception { out.printf("CloudStack zones for provider %s\n", getProvider().getId()); for (Zone zone : client.getZoneClient().listZones()) { out.printf("---\n%s\n", zone.toString()); } out.println(); return null; } ZonesCommand(DefaultProviderConfig defaultProviderConfig); @Override Object doExecuteWithContext(CloudStackClient client, PrintStream out); static final String NAME; }
@Test public void testZonesCommandPrintsZones() throws Exception { final ZonesCommand zonesCommand = new ZonesCommand(defaultProviderConfig); final ZoneClient zoneClient = mock(ZoneClient.class); when(client.getZoneClient()).thenReturn(zoneClient); when(zoneClient.listZones()).thenReturn(zones); zonesCommand.doExecuteWithContext(client, out); out.close(); final String result = byteArrayOutputStream.toString(); assertThat(result) .contains("zone-1") .contains("zone-one") .contains("false"); }