### Question:
StatusHandler implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> { @Override public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) { APIGatewayProxyResponseEvent output = new APIGatewayProxyResponseEvent(); try { Map<String, String> queryStringParameters = input.getQueryStringParameters(); String id = null; if (queryStringParameters != null) { id = queryStringParameters.get("id"); } Object response = (id == null) ? Prodigy.status() : Prodigy.status(id); ObjectMapper mapper = new ObjectMapper(); return output.withStatusCode(200).withBody(mapper.writeValueAsString(response)); } catch (IllegalArgumentException e) { log.warn(e.getMessage(), e); return output.withStatusCode(400).withBody(e.getMessage()); } catch (Exception e) { log.error(e.getMessage(), e); return output.withStatusCode(500).withBody(e.getMessage()); } }  @Override APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context);  }### Answer:
@Test public void testHandleRequest() { StatusHandler handler = new StatusHandler(); Scheduler scheduler = mock(Scheduler.class); doReturn(null).when(scheduler).get(anyString()); Prodigy.container(new Container(scheduler, mock(Repository.class))); APIGatewayProxyRequestEvent input = new APIGatewayProxyRequestEvent(); Map<String, String> queryStringParameters = new HashMap<>(); queryStringParameters.put("id", "fault-id-2"); input.setQueryStringParameters(queryStringParameters); APIGatewayProxyResponseEvent output = handler.handleRequest(input, null); assertThat(output.getStatusCode(), is(400)); assertThat(output.getBody(), is("Fault id [fault-id-2] not found")); scheduler = mock(Scheduler.class); doThrow(new IllegalStateException("hello")).when(scheduler).list(); Prodigy.container(new Container(scheduler, mock(Repository.class))); output = handler.handleRequest(new APIGatewayProxyRequestEvent(), null); assertThat(output.getStatusCode(), is(500)); assertThat(output.getBody(), is("hello")); scheduler = mock(Scheduler.class); List<Entry> entries = new ArrayList<>(); Entry entry = new Entry("fault-id-1", "fault-1", "ACTIVE", "{}"); entries.add(entry); doReturn(entries).when(scheduler).list(); Prodigy.container(new Container(scheduler, mock(Repository.class))); output = handler.handleRequest(new APIGatewayProxyRequestEvent(), null); assertThat(output.getStatusCode(), is(200)); assertThat(output.getBody(), is("[{\"id\":\"fault-id-1\",\"name\":\"fault-1\",\"status\":\"ACTIVE\",\"params\":\"{}\"}]")); scheduler = mock(Scheduler.class); entry = new Entry("fault-id-2", "fault-2", "ACTIVE", "{}"); doReturn(entry).when(scheduler).get(anyString()); Prodigy.container(new Container(scheduler, mock(Repository.class))); input = new APIGatewayProxyRequestEvent(); queryStringParameters = new HashMap<>(); queryStringParameters.put("id", "fault-id-2"); input.setQueryStringParameters(queryStringParameters); output = handler.handleRequest(input, null); assertThat(output.getStatusCode(), is(200)); assertThat(output.getBody(), is("{\"id\":\"fault-id-2\",\"name\":\"fault-2\",\"status\":\"ACTIVE\",\"params\":\"{}\"}")); }