@Test public void testCreateConflictingDeploymentGroup() throws Exception { mockCreateResponse(CreateDeploymentGroupResponse.Status.CREATED); assertEquals(0, command.run(options, client, out, false, null)); mockCreateResponse(CreateDeploymentGroupResponse.Status.CONFLICT); assertEquals(1, command.run(options, client, out, false, null)); final String output = baos.toString(); assertThat(output, containsString("\"name\":\"foo-group\"")); assertThat(output, containsString( "\"hostSelectors\":[" + "{\"label\":\"foo\",\"operand\":\"bar\",\"operator\":\"EQUALS\"}," + "{\"label\":\"baz\",\"operand\":\"qux\",\"operator\":\"EQUALS\"}" + "]")); assertThat(output, containsString("CONFLICT")); }
@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 List<HostSelector> hostSelectors = Utils.parseHostSelectors(options, hostSelectorsArg); final boolean quiet = options.getBoolean(quietArg.getDest()); final DeploymentGroup deploymentGroup = DeploymentGroup.newBuilder() .setName(name) .setHostSelectors(hostSelectors) .build(); if (!quiet && !json) { out.println("Creating deployment group: " + deploymentGroup.toJsonString()); } final CreateDeploymentGroupResponse status = client.createDeploymentGroup(deploymentGroup).get(); if (status == null) { throw new RuntimeException("The Helios master could not create a deployment group."); } if (status.getStatus() != CreateDeploymentGroupResponse.Status.CONFLICT) { out.println(status.toJsonString()); return 0; } else { if (!quiet && !json) { out.println("Failed: " + status); } else if (json) { out.println(status.toJsonString()); } return 1; } }
DeploymentGroupCreateCommand 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 List<HostSelector> hostSelectors = Utils.parseHostSelectors(options, hostSelectorsArg); final boolean quiet = options.getBoolean(quietArg.getDest()); final DeploymentGroup deploymentGroup = DeploymentGroup.newBuilder() .setName(name) .setHostSelectors(hostSelectors) .build(); if (!quiet && !json) { out.println("Creating deployment group: " + deploymentGroup.toJsonString()); } final CreateDeploymentGroupResponse status = client.createDeploymentGroup(deploymentGroup).get(); if (status == null) { throw new RuntimeException("The Helios master could not create a deployment group."); } if (status.getStatus() != CreateDeploymentGroupResponse.Status.CONFLICT) { out.println(status.toJsonString()); return 0; } else { if (!quiet && !json) { out.println("Failed: " + status); } else if (json) { out.println(status.toJsonString()); } return 1; } } }
DeploymentGroupCreateCommand 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 List<HostSelector> hostSelectors = Utils.parseHostSelectors(options, hostSelectorsArg); final boolean quiet = options.getBoolean(quietArg.getDest()); final DeploymentGroup deploymentGroup = DeploymentGroup.newBuilder() .setName(name) .setHostSelectors(hostSelectors) .build(); if (!quiet && !json) { out.println("Creating deployment group: " + deploymentGroup.toJsonString()); } final CreateDeploymentGroupResponse status = client.createDeploymentGroup(deploymentGroup).get(); if (status == null) { throw new RuntimeException("The Helios master could not create a deployment group."); } if (status.getStatus() != CreateDeploymentGroupResponse.Status.CONFLICT) { out.println(status.toJsonString()); return 0; } else { if (!quiet && !json) { out.println("Failed: " + status); } else if (json) { out.println(status.toJsonString()); } return 1; } } DeploymentGroupCreateCommand(final Subparser parser); }
DeploymentGroupCreateCommand 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 List<HostSelector> hostSelectors = Utils.parseHostSelectors(options, hostSelectorsArg); final boolean quiet = options.getBoolean(quietArg.getDest()); final DeploymentGroup deploymentGroup = DeploymentGroup.newBuilder() .setName(name) .setHostSelectors(hostSelectors) .build(); if (!quiet && !json) { out.println("Creating deployment group: " + deploymentGroup.toJsonString()); } final CreateDeploymentGroupResponse status = client.createDeploymentGroup(deploymentGroup).get(); if (status == null) { throw new RuntimeException("The Helios master could not create a deployment group."); } if (status.getStatus() != CreateDeploymentGroupResponse.Status.CONFLICT) { out.println(status.toJsonString()); return 0; } else { if (!quiet && !json) { out.println("Failed: " + status); } else if (json) { out.println(status.toJsonString()); } return 1; } } DeploymentGroupCreateCommand(final Subparser parser);  }
DeploymentGroupCreateCommand 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 List<HostSelector> hostSelectors = Utils.parseHostSelectors(options, hostSelectorsArg); final boolean quiet = options.getBoolean(quietArg.getDest()); final DeploymentGroup deploymentGroup = DeploymentGroup.newBuilder() .setName(name) .setHostSelectors(hostSelectors) .build(); if (!quiet && !json) { out.println("Creating deployment group: " + deploymentGroup.toJsonString()); } final CreateDeploymentGroupResponse status = client.createDeploymentGroup(deploymentGroup).get(); if (status == null) { throw new RuntimeException("The Helios master could not create a deployment group."); } if (status.getStatus() != CreateDeploymentGroupResponse.Status.CONFLICT) { out.println(status.toJsonString()); return 0; } else { if (!quiet && !json) { out.println("Failed: " + status); } else if (json) { out.println(status.toJsonString()); } return 1; } } DeploymentGroupCreateCommand(final Subparser parser);   }