CodeSampleParams { public boolean parseArguments(String[] args) { return parseArguments(args, Runtime.getRuntime(), System.err); }  boolean parseArguments(String[] args);  }
@Test public void testParseArgumentsReturnsFalseWithNoArgs() throws Exception { TestSampleParams p = new TestSampleParams(); assertFalse(p.parseArguments(new String[] {})); }
@Test public void testParseArgumentsReturnsTrueWithAllRequiredArgs() throws Exception { String[] args = new String[] {"--stringParam", "abc", "--longParam", "123"}; TestSampleParams p = new TestSampleParams(); assertTrue(p.parseArguments(args)); }
@Test public void testParseArgumentsReturnsTrueWithAllArgs() throws Exception { String[] args = new String[] {"--stringParam", "abc", "--longParam", "123", "--longOptionalParam", "456"}; TestSampleParams p = new TestSampleParams(); assertTrue(p.parseArguments(args)); }
@Test public void testParseArgumentsThrowsExceptionWithPartialRequiredArgs() throws Exception { String[] args = new String[] {"--stringParam", "abc"}; TestSampleParams p = new TestSampleParams(); exception.expect(ParameterException.class); p.parseArguments(args); }
@Test public void testParseArgumentsPrintsUsageAndExitsWithHelp() throws Exception { TestSampleParams p = new TestSampleParams(); PrintStream mockPrintStream = Mockito.mock(PrintStream.class); try { p.parseArguments(new String[] {"--help"}, mockRuntime, mockPrintStream); fail("parseArguments above should have called runtime.exit(0)"); } catch (RuntimeException e) { } finally { verify(mockPrintStream, times(1)).println(anyString()); } }