Source:
<code>public void testGetAction() throws Exception { ActionFactory actionFactory = new ActionFactory(); ______TS("Action exists and is retrieved"); MockHttpServletRequest existingActionServletRequest = new MockHttpServletRequest( HttpGet.METHOD_NAME, Const.ResourceURIs.URI_PREFIX + Const.ResourceURIs.AUTH); existingActionServletRequest.addHeader("Backdoor-Key", "samplekey"); Action existingAction = actionFactory.getAction(existingActionServletRequest, HttpGet.METHOD_NAME); assertTrue(existingAction instanceof GetAuthInfoAction); ______TS("Action does not exist and ActionMappingException is thrown"); MockHttpServletRequest nonExistentActionServletRequest = new MockHttpServletRequest( HttpGet.METHOD_NAME, Const.ResourceURIs.URI_PREFIX + "blahblahblah"); nonExistentActionServletRequest.addHeader("Backdoor-Key", "samplekey"); assertThrows(ActionMappingException.class, () -> { actionFactory.getAction(nonExistentActionServletRequest, HttpGet.METHOD_NAME); <START> }); <END> ______TS("Method does not on action exist and ActionMappingException is thrown"); MockHttpServletRequest nonExistentMethodOnActionServletRequest = new MockHttpServletRequest( HttpGet.METHOD_NAME, Const.ResourceURIs.URI_PREFIX + Const.ResourceURIs.AUTH); nonExistentMethodOnActionServletRequest.addHeader("Backdoor-Key", "samplekey"); assertThrows(ActionMappingException.class, () -> { actionFactory.getAction(nonExistentMethodOnActionServletRequest, HttpPost.METHOD_NAME); }); }</code><technical_language>Besides checking exception is thrown, is for check error message? This is ActionFactory.java, ActionMappingException thrown for reasons. (Same for test below)</technical_language>

Target:
public void testGetAction() throws Exception { ActionFactory actionFactory = new ActionFactory(); ______TS("Action exists and is retrieved"); MockHttpServletRequest existingActionServletRequest = new MockHttpServletRequest( HttpGet.METHOD_NAME, Const.ResourceURIs.URI_PREFIX + Const.ResourceURIs.AUTH); existingActionServletRequest.addHeader("Backdoor-Key", "samplekey"); Action existingAction = actionFactory.getAction(existingActionServletRequest, HttpGet.METHOD_NAME); assertTrue(existingAction instanceof GetAuthInfoAction); ______TS("Action does not exist and ActionMappingException is thrown"); MockHttpServletRequest nonExistentActionServletRequest = new MockHttpServletRequest( HttpGet.METHOD_NAME, Const.ResourceURIs.URI_PREFIX + "blahblahblah"); nonExistentActionServletRequest.addHeader("Backdoor-Key", "samplekey"); ActionMappingException nonExistentActionException = assertThrows(ActionMappingException.class, () -> actionFactory.getAction(nonExistentActionServletRequest, HttpGet.METHOD_NAME)); assertTrue(nonExistentActionException.getMessage() .equals("Resource with URI " + Const.ResourceURIs.URI_PREFIX + "blahblahblah" + " is not found.")); ______TS("Method does not exist on action and ActionMappingException is thrown"); MockHttpServletRequest nonExistentMethodOnActionServletRequest = new MockHttpServletRequest( HttpGet.METHOD_NAME, Const.ResourceURIs.URI_PREFIX + Const.ResourceURIs.AUTH); nonExistentMethodOnActionServletRequest.addHeader("Backdoor-Key", "samplekey"); ActionMappingException nonExistentMethodOnActionException = assertThrows(ActionMappingException.class, () -> actionFactory.getAction(nonExistentMethodOnActionServletRequest, HttpPost.METHOD_NAME)); assertTrue(nonExistentMethodOnActionException.getMessage() .equals("Method [" + HttpPost.METHOD_NAME + "] is not allowed for URI " + Const.ResourceURIs.URI_PREFIX + Const.ResourceURIs.AUTH + ".")); }