### Question:
HttpRequestHandler extends SimpleChannelUpstreamHandler { protected HttpResponse handleGetClientApplication(HttpRequest req) { HttpResponse response = null; Matcher m = APPLICATION_PATTERN.matcher(req.getUri()); if (m.find()) { String clientId = m.group(1); ApplicationInfo appInfo = auth.getApplicationInfo(clientId); if (appInfo != null) { ObjectMapper mapper = new ObjectMapper(); try { String json = mapper.writeValueAsString(appInfo); log.debug(json); response = Response.createOkResponse(json); } catch (JsonGenerationException e) { log.error("error get application info", e); invokeExceptionHandler(e, req); } catch (JsonMappingException e) { log.error("error get application info", e); invokeExceptionHandler(e, req); } catch (IOException e) { log.error("error get application info", e); invokeExceptionHandler(e, req); } } else { response = Response.createResponse(HttpResponseStatus.NOT_FOUND, Response.CLIENT_APP_NOT_EXIST); } } else { response = Response.createNotFoundResponse(); } return response; }  @Override void messageReceived(ChannelHandlerContext ctx, MessageEvent e);  }### Answer:
@Test public void when_GET_application_with_clientId_invoke_get_application_with_client_id() throws Exception { String uri = HttpRequestHandler.APPLICATION_URI + "/218900b6c8d973881cf4185ecf2c6aba"; HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri); AuthorizationServer auth = mock(AuthorizationServer.class); ApplicationInfo info = new ApplicationInfo(); willReturn(info).given(auth).getApplicationInfo("218900b6c8d973881cf4185ecf2c6aba"); handler.auth = auth; handler.handleGetClientApplication(req); verify(handler.auth).getApplicationInfo("218900b6c8d973881cf4185ecf2c6aba"); }
@Test public void when_handleGetClientApplication_with_non_existing_clientId_return_not_found_status() throws Exception { String clientId = "acf627defb833"; String uri = HttpRequestHandler.APPLICATION_URI + "/" + clientId; HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri); AuthorizationServer auth = mock(AuthorizationServer.class); willReturn(null).given(auth).getApplicationInfo(clientId); handler.auth = auth; HttpResponse response = handler.handleGetClientApplication(req); assertEquals(response.getStatus(), HttpResponseStatus.NOT_FOUND); assertEquals(response.getContent().toString(CharsetUtil.UTF_8), Response.CLIENT_APP_NOT_EXIST); }