@Test public void testDeploymentGroupInspectCommandNotFound() throws Exception { when(options.getString("name")).thenReturn(NON_EXISTENT_NAME); final int ret = command.run(options, client, out, false, null); assertEquals(1, ret); final String output = baos.toString(); assertThat(output, containsString("Unknown deployment group: " + NON_EXISTENT_NAME)); }
@Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final DeploymentGroup deploymentGroup = client.deploymentGroup(name).get(); if (deploymentGroup == null) { if (json) { final Map<String, Object> output = Maps.newHashMap(); output.put("status", "DEPLOYMENT_GROUP_NOT_FOUND"); out.print(Json.asStringUnchecked(output)); } else { out.printf("Unknown deployment group: %s%n", name); } return 1; } if (json) { out.println(Json.asPrettyStringUnchecked(deploymentGroup)); } else { out.printf("Name: %s%n", deploymentGroup.getName()); out.printf("Host selectors:%n"); for (final HostSelector hostSelector : deploymentGroup.getHostSelectors()) { out.printf(" %s%n", hostSelector.toPrettyString()); } out.printf("Job: %s%n", deploymentGroup.getJobId()); if (deploymentGroup.getRollingUpdateReason() != null) { out.printf("Rolling update reason: %s%n", deploymentGroup.getRollingUpdateReason()); } final RolloutOptions rolloutOptions = deploymentGroup.getRolloutOptions(); if (rolloutOptions != null) { out.printf("Rollout options:%n"); out.printf(" Migrate: %s%n", rolloutOptions.getMigrate()); out.printf(" Overlap: %s%n", rolloutOptions.getOverlap()); out.printf(" Parallelism: %d%n", rolloutOptions.getParallelism()); out.printf(" Timeout: %d%n", rolloutOptions.getTimeout()); if (!isNullOrEmpty(rolloutOptions.getToken())) { out.printf(" Token: %s%n", rolloutOptions.getToken()); } out.printf(" Ignore failures: %b%n", rolloutOptions.getIgnoreFailures()); } } return 0; }
DeploymentGroupInspectCommand extends ControlCommand { @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final DeploymentGroup deploymentGroup = client.deploymentGroup(name).get(); if (deploymentGroup == null) { if (json) { final Map<String, Object> output = Maps.newHashMap(); output.put("status", "DEPLOYMENT_GROUP_NOT_FOUND"); out.print(Json.asStringUnchecked(output)); } else { out.printf("Unknown deployment group: %s%n", name); } return 1; } if (json) { out.println(Json.asPrettyStringUnchecked(deploymentGroup)); } else { out.printf("Name: %s%n", deploymentGroup.getName()); out.printf("Host selectors:%n"); for (final HostSelector hostSelector : deploymentGroup.getHostSelectors()) { out.printf(" %s%n", hostSelector.toPrettyString()); } out.printf("Job: %s%n", deploymentGroup.getJobId()); if (deploymentGroup.getRollingUpdateReason() != null) { out.printf("Rolling update reason: %s%n", deploymentGroup.getRollingUpdateReason()); } final RolloutOptions rolloutOptions = deploymentGroup.getRolloutOptions(); if (rolloutOptions != null) { out.printf("Rollout options:%n"); out.printf(" Migrate: %s%n", rolloutOptions.getMigrate()); out.printf(" Overlap: %s%n", rolloutOptions.getOverlap()); out.printf(" Parallelism: %d%n", rolloutOptions.getParallelism()); out.printf(" Timeout: %d%n", rolloutOptions.getTimeout()); if (!isNullOrEmpty(rolloutOptions.getToken())) { out.printf(" Token: %s%n", rolloutOptions.getToken()); } out.printf(" Ignore failures: %b%n", rolloutOptions.getIgnoreFailures()); } } return 0; } }
DeploymentGroupInspectCommand extends ControlCommand { @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final DeploymentGroup deploymentGroup = client.deploymentGroup(name).get(); if (deploymentGroup == null) { if (json) { final Map<String, Object> output = Maps.newHashMap(); output.put("status", "DEPLOYMENT_GROUP_NOT_FOUND"); out.print(Json.asStringUnchecked(output)); } else { out.printf("Unknown deployment group: %s%n", name); } return 1; } if (json) { out.println(Json.asPrettyStringUnchecked(deploymentGroup)); } else { out.printf("Name: %s%n", deploymentGroup.getName()); out.printf("Host selectors:%n"); for (final HostSelector hostSelector : deploymentGroup.getHostSelectors()) { out.printf(" %s%n", hostSelector.toPrettyString()); } out.printf("Job: %s%n", deploymentGroup.getJobId()); if (deploymentGroup.getRollingUpdateReason() != null) { out.printf("Rolling update reason: %s%n", deploymentGroup.getRollingUpdateReason()); } final RolloutOptions rolloutOptions = deploymentGroup.getRolloutOptions(); if (rolloutOptions != null) { out.printf("Rollout options:%n"); out.printf(" Migrate: %s%n", rolloutOptions.getMigrate()); out.printf(" Overlap: %s%n", rolloutOptions.getOverlap()); out.printf(" Parallelism: %d%n", rolloutOptions.getParallelism()); out.printf(" Timeout: %d%n", rolloutOptions.getTimeout()); if (!isNullOrEmpty(rolloutOptions.getToken())) { out.printf(" Token: %s%n", rolloutOptions.getToken()); } out.printf(" Ignore failures: %b%n", rolloutOptions.getIgnoreFailures()); } } return 0; } DeploymentGroupInspectCommand(final Subparser parser); }
DeploymentGroupInspectCommand extends ControlCommand { @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final DeploymentGroup deploymentGroup = client.deploymentGroup(name).get(); if (deploymentGroup == null) { if (json) { final Map<String, Object> output = Maps.newHashMap(); output.put("status", "DEPLOYMENT_GROUP_NOT_FOUND"); out.print(Json.asStringUnchecked(output)); } else { out.printf("Unknown deployment group: %s%n", name); } return 1; } if (json) { out.println(Json.asPrettyStringUnchecked(deploymentGroup)); } else { out.printf("Name: %s%n", deploymentGroup.getName()); out.printf("Host selectors:%n"); for (final HostSelector hostSelector : deploymentGroup.getHostSelectors()) { out.printf(" %s%n", hostSelector.toPrettyString()); } out.printf("Job: %s%n", deploymentGroup.getJobId()); if (deploymentGroup.getRollingUpdateReason() != null) { out.printf("Rolling update reason: %s%n", deploymentGroup.getRollingUpdateReason()); } final RolloutOptions rolloutOptions = deploymentGroup.getRolloutOptions(); if (rolloutOptions != null) { out.printf("Rollout options:%n"); out.printf(" Migrate: %s%n", rolloutOptions.getMigrate()); out.printf(" Overlap: %s%n", rolloutOptions.getOverlap()); out.printf(" Parallelism: %d%n", rolloutOptions.getParallelism()); out.printf(" Timeout: %d%n", rolloutOptions.getTimeout()); if (!isNullOrEmpty(rolloutOptions.getToken())) { out.printf(" Token: %s%n", rolloutOptions.getToken()); } out.printf(" Ignore failures: %b%n", rolloutOptions.getIgnoreFailures()); } } return 0; } DeploymentGroupInspectCommand(final Subparser parser);  }
DeploymentGroupInspectCommand extends ControlCommand { @Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String name = options.getString(nameArg.getDest()); final DeploymentGroup deploymentGroup = client.deploymentGroup(name).get(); if (deploymentGroup == null) { if (json) { final Map<String, Object> output = Maps.newHashMap(); output.put("status", "DEPLOYMENT_GROUP_NOT_FOUND"); out.print(Json.asStringUnchecked(output)); } else { out.printf("Unknown deployment group: %s%n", name); } return 1; } if (json) { out.println(Json.asPrettyStringUnchecked(deploymentGroup)); } else { out.printf("Name: %s%n", deploymentGroup.getName()); out.printf("Host selectors:%n"); for (final HostSelector hostSelector : deploymentGroup.getHostSelectors()) { out.printf(" %s%n", hostSelector.toPrettyString()); } out.printf("Job: %s%n", deploymentGroup.getJobId()); if (deploymentGroup.getRollingUpdateReason() != null) { out.printf("Rolling update reason: %s%n", deploymentGroup.getRollingUpdateReason()); } final RolloutOptions rolloutOptions = deploymentGroup.getRolloutOptions(); if (rolloutOptions != null) { out.printf("Rollout options:%n"); out.printf(" Migrate: %s%n", rolloutOptions.getMigrate()); out.printf(" Overlap: %s%n", rolloutOptions.getOverlap()); out.printf(" Parallelism: %d%n", rolloutOptions.getParallelism()); out.printf(" Timeout: %d%n", rolloutOptions.getTimeout()); if (!isNullOrEmpty(rolloutOptions.getToken())) { out.printf(" Token: %s%n", rolloutOptions.getToken()); } out.printf(" Ignore failures: %b%n", rolloutOptions.getIgnoreFailures()); } } return 0; } DeploymentGroupInspectCommand(final Subparser parser);   }