### Question:
AbstractCommandArgs implements CommandArgs { @Override public boolean nextBoolean() throws MissingArgumentException, ArgumentParseException { String next = next(); if (next.equalsIgnoreCase("yes") || next.equalsIgnoreCase("true") || next.equalsIgnoreCase("y") || next.equalsIgnoreCase("1")) { return true; } else if (next.equalsIgnoreCase("no") || next.equalsIgnoreCase("false") || next.equalsIgnoreCase("n") || next.equalsIgnoreCase("0")) { return false; } else { throw new ArgumentParseException("Expected a boolean (yes/no), got '" + next + "'"); } }  @Override int nextInt(); @Override short nextShort(); @Override byte nextByte(); @Override double nextDouble(); @Override float nextFloat(); @Override boolean nextBoolean();  }### Answer:
@Test(expected = ArgumentParseException.class) public void testNextBadBoolean() throws Exception { CommandArgs args; args = createCommandArgs(ImmutableList.of("alpha")); assertThat(args.position(), is(0)); args.nextBoolean(); }
@Test public void testNextBoolean() throws Exception { CommandArgs args; args = createCommandArgs(ImmutableList.of("true")); assertThat(args.position(), is(0)); assertThat(args.nextBoolean(), is(true)); assertThat(args.position(), is(1)); args = createCommandArgs(ImmutableList.of("yes")); assertThat(args.position(), is(0)); assertThat(args.nextBoolean(), is(true)); assertThat(args.position(), is(1)); args = createCommandArgs(ImmutableList.of("false")); assertThat(args.position(), is(0)); assertThat(args.nextBoolean(), is(false)); assertThat(args.position(), is(1)); args = createCommandArgs(ImmutableList.of("no")); assertThat(args.position(), is(0)); assertThat(args.nextBoolean(), is(false)); assertThat(args.position(), is(1)); }