### Question:
CommandLineParser { public static String parse(String command) throws AgentUserException{ String[] args = command.split(" "); return CommandLineAction.getActionByKey(args[0]).perform(args); } private  CommandLineParser(); static String parse(String command);  }### Answer:
@Test(expected = AgentUserException.class) public void throwsAgentUserExceptionWhenParse() throws AgentUserException { when(CommandLineAction.getActionByKey(anyString())).thenReturn(CommandLineAction.PROVISION_ACTION); when(fieldAgent.provision(anyString())).thenReturn(mock(JsonObject.class)); when(CommandLineAction.getActionByKey(anyString()).perform(mockArguments)).thenThrow(mock(AgentUserException.class)); commandLineParser.parse("provision key"); PowerMockito.verifyStatic(CommandLineAction.class); CommandLineAction.getActionByKey("provision"); }
@Test public void testParse() { try { assertEquals("Test perform", commandLineParser.parse("help")); PowerMockito.verifyStatic(CommandLineAction.class); CommandLineAction.getActionByKey("help"); } catch (AgentUserException e) { fail("This should never happen"); } }