### Question:
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);   }### Answer:
@Test public void testCreateDeploymentGroup() throws Exception { mockCreateResponse(CreateDeploymentGroupResponse.Status.CREATED); assertEquals(0, command.run(options, client, out, false, null)); final ArgumentCaptor<DeploymentGroup> captor = ArgumentCaptor.forClass(DeploymentGroup.class); verify(client).createDeploymentGroup(captor.capture()); assertEquals(GROUP_NAME, captor.getValue().getName()); assertEquals(HOST_SELECTORS, captor.getValue().getHostSelectors()); 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("CREATED")); }
@Test public void testCreateAlreadyExistingDeploymentGroup() throws Exception { mockCreateResponse(CreateDeploymentGroupResponse.Status.CREATED); assertEquals(0, command.run(options, client, out, false, null)); mockCreateResponse(CreateDeploymentGroupResponse.Status.NOT_MODIFIED); assertEquals(0, 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("NOT_MODIFIED")); }
@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")); }