AbstractContext implements Context.Impl { @Override public <T> T getParameterAs(String key, Class<T> clazz) { return getParameterAs(key, clazz, null); } @Inject  AbstractContext(
            BodyParserEngineManager bodyParserEngineManager,
            FlashScope flashScope,
            NinjaProperties ninjaProperties,
            Session session,
            Validation validation,
            Injector injector,
            ParamParsers paramParsers); @Override void setRoute(Route route); @Override Route getRoute(); @Override Validation getValidation(); @Deprecated @Override FlashScope getFlashCookie(); @Override FlashScope getFlashScope(); @Deprecated @Override Session getSessionCookie(); @Override Session getSession(); @Override String getContextPath(); @Override String getRequestPath(); @Override String getRemoteAddr(); @Override T getAttribute(String name, Class<T> clazz); @Override String getPathParameter(String key); @Override String getPathParameterEncoded(String key); @Override Integer getPathParameterAsInteger(String key); @Override String getParameter(String key, String defaultValue); @Override Integer getParameterAsInteger(String key); @Override Integer getParameterAsInteger(String key, Integer defaultValue); @Override T getParameterAs(String key, Class<T> clazz); @Override T getParameterAs(String key, Class<T> clazz, T defaultValue); @Override T parseBody(Class<T> classOfT); @Override String getCookieValue(String name); @Override void unsetCookie(Cookie cookie); @Override void asyncRequestComplete(); @Override ResponseStreams finalizeHeadersWithoutFlashAndSessionCookie(Result result); @Override ResponseStreams finalizeHeaders(Result result); @Override String getAcceptContentType(); @Override String getAcceptEncoding(); @Override String getAcceptLanguage(); @Override String getAcceptCharset(); @Override boolean isRequestJson(); @Override boolean isRequestXml();  }
@Test public void getParameterAs() { AbstractContextImpl context = spy(abstractContext); doReturn(null).when(context).getParameter("key"); doReturn("100").when(context).getParameter("key1"); doReturn("true").when(context).getParameter("key2"); doReturn("10.1").when(context).getParameter("key3"); doReturn("x").when(context).getParameter("key4"); assertEquals(null, context.getParameterAs("key", Long.class)); assertEquals(new Integer(100), context.getParameterAs("key1", Integer.class)); assertEquals(new Long(100), context.getParameterAs("key1", Long.class)); assertEquals(Boolean.TRUE, context.getParameterAs("key2", Boolean.class)); assertEquals(new Float(10.1), context.getParameterAs("key3", Float.class)); assertEquals(new Character('x'), context.getParameterAs("key4", Character.class)); }