### Question:
CommandExpectationGroup { @Override public String toString() { final StringBuffer sb = new StringBuffer(); if (maskCommands) { if (maskedCommands == null) { maskedCommands = new ArrayList<String>(commands.size()); for (int idx = 0; idx < commands.size(); idx++) { maskedCommands.add("********"); } } sb.append(maskedCommands).append(expectations); } else { sb.append(commands).append(expectations); } return sb.toString(); } CommandExpectationGroup(); protected  CommandExpectationGroup(final boolean maskCommands); void addCommand(final String command); void addCommands(final List<String> commands); void addExpectation(final String expectation); void addExpectations(final List<String> expectations); List<String> getCommands(); List<String> getExpectations(); boolean maskCommands(); @Override String toString();  }### Answer:
@Test public void testToString() { CommandExpectationGroup commandExpectationGroup = new CommandExpectationGroup(); commandExpectationGroup.addCommand("solo command 1"); commandExpectationGroup.addExpectation("solo expectation 1"); commandExpectationGroup.addCommands( Arrays.asList(new String[] { "grouped command 1", "grouped command 2", "grouped command 3" })); commandExpectationGroup.addExpectations(Arrays.asList(new String[] { "grouped expectation 1" })); commandExpectationGroup.addExpectation("solo expectation 2"); commandExpectationGroup.addCommand("solo command 2"); commandExpectationGroup .addExpectations(Arrays.asList(new String[] { "grouped expectation 2", "grouped expectation 3" })); assertThat(commandExpectationGroup.toString()).isEqualTo(Arrays .asList(new String[] { "solo command 1", "grouped command 1", "grouped command 2", "grouped command 3", "solo command 2" }) .toString() + Arrays.asList(new String[] { "solo expectation 1", "grouped expectation 1", "solo expectation 2", "grouped expectation 2", "grouped expectation 3" }).toString()); commandExpectationGroup = new CommandExpectationGroup(); commandExpectationGroup.addCommands(Arrays.asList(new String[] { "grouped command 1", "grouped command 2" })); commandExpectationGroup.addExpectation("solo expectation 1"); commandExpectationGroup.addCommands(Arrays.asList(new String[] { "grouped command 3", "grouped command 4" })); commandExpectationGroup .addExpectations(Arrays.asList(new String[] { "grouped expectation 1", "grouped expectation 2" })); commandExpectationGroup.addExpectation("solo expectation 2"); commandExpectationGroup.addCommand("solo command 1"); assertThat(commandExpectationGroup.toString()).isEqualTo(Arrays .asList(new String[] { "grouped command 1", "grouped command 2", "grouped command 3", "grouped command 4", "solo command 1" }) .toString() + Arrays.asList(new String[] { "solo expectation 1", "grouped expectation 1", "grouped expectation 2", "solo expectation 2" }).toString()); commandExpectationGroup .addExpectations(Arrays.asList(new String[] { "extra expectation 1g", "extra expectation 2g" })); commandExpectationGroup.addCommand("extra command 1"); commandExpectationGroup.addExpectation("extra expectation 1"); commandExpectationGroup.addCommands(Arrays.asList(new String[] { "extra command 1g", "extra command 2g" })); assertThat(commandExpectationGroup.toString()).isEqualTo(Arrays .asList(new String[] { "grouped command 1", "grouped command 2", "grouped command 3", "grouped command 4", "solo command 1", "extra command 1", "extra command 1g", "extra command 2g" }) .toString() + Arrays.asList(new String[] { "solo expectation 1", "grouped expectation 1", "grouped expectation 2", "solo expectation 2", "extra expectation 1g", "extra expectation 2g", "extra expectation 1" }) .toString()); }