OfferingsCommand extends CommandSupport { @Override public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception { if (isDiskOfferingListed() || isServiceOfferingListed() || isNetworkOfferingListed()) { out.printf("CloudStack Offerings for provider %s\n", getProvider().getId()); listServiceOfferingsIfSpecified(client, out); listNetworkOfferingsIfSpecified(client, out); listDiskOfferingsIfSpecified(client, out); } else { out.printf("No option specified. See --help for details."); } return null; } OfferingsCommand(DefaultProviderConfig providerConfig); @Override Object doExecuteWithContext(CloudStackClient client, PrintStream out); boolean isDiskOfferingListed(); void setDiskOffering(boolean diskOffering); boolean isNetworkOfferingListed(); void setNetworkOffering(boolean networkOffering); boolean isServiceOfferingListed(); void setServiceOffering(boolean serviceOffering); static final String NAME; }
@Test public void testOfferingCommandWithNoOptionSpecified() throws Exception { final OfferingsCommand offeringsCommand = new OfferingsCommand(defaultProviderConfig); offeringsCommand.doExecuteWithContext(client, out); out.close(); assertThat(byteArrayOutputStream.toString()).contains("No option specified"); }