### Question:
IndexAction extends OneBusAwayNYCActionSupport { @Override public String execute() throws Exception { ActionContext context = ActionContext.getContext(); ActionInvocation invocation = context.getActionInvocation(); ActionProxy proxy = invocation.getProxy(); String name = proxy.getActionName().toLowerCase(); String namespace = proxy.getNamespace().toLowerCase(); if((name.equals("") || name.equals("index")) && (namespace.equals("") || namespace.equals("/"))) { return SUCCESS; } return "NotFound"; }  String getGoogleMapsClientId(); String getGoogleAdClientId(); String getMapInstance(); String getGoogleMapsApiKey(); String getGoogleMapsChannel(); List<ServiceAlertBean> getGlobalServiceAlerts(); String getPsa(); @Override String execute();  }### Answer:
@Test public void testExecute() throws Exception { ActionProxy proxy = Mockito.mock(ActionProxy.class); Mockito.when(proxy.getActionName()).thenReturn("index"); Mockito.when(proxy.getNamespace()).thenReturn("/"); ActionInvocation invocation = Mockito.mock(ActionInvocation.class); Mockito.when(invocation.getProxy()).thenReturn(proxy); Map<String, Object> c = new HashMap<String, Object>(); ActionContext ac = new ActionContext(c); ac.setActionInvocation(invocation); ActionContext.setContext(ac); IndexAction action = new IndexAction(); String response = action.execute(); assertEquals("successful response", "success", response); }
@Test public void test404() throws Exception { ActionProxy proxy = Mockito.mock(ActionProxy.class); Mockito.when(proxy.getActionName()).thenReturn("something-else"); Mockito.when(proxy.getNamespace()).thenReturn("/"); ActionInvocation invocation = Mockito.mock(ActionInvocation.class); Mockito.when(invocation.getProxy()).thenReturn(proxy); Map<String, Object> c = new HashMap<String, Object>(); ActionContext ac = new ActionContext(c); ac.setActionInvocation(invocation); ActionContext.setContext(ac); IndexAction action = new IndexAction(); String response = action.execute(); assertEquals("404 response", "NotFound", response); }