NinjaServletContext extends AbstractContext { @Override public boolean hasCookie(String cookieName) { return ServletCookieHelper.getCookie(cookieName, httpServletRequest.getCookies()) != null; } @Inject  NinjaServletContext(
            BodyParserEngineManager bodyParserEngineManager,
            FlashScope flashScope,
            NinjaProperties ninjaProperties,
            ResultHandler resultHandler,
            Session session,
            Validation validation,
            Injector injector,
            ParamParsers paramParsers); void init(ServletContext servletContext,
            HttpServletRequest httpServletRequest,
            HttpServletResponse httpServletResponse); @Override String getMethod(); @Deprecated @Override String getRequestUri(); @Override String getHostname(); @Override String getParameter(String key); @Override List<String> getParameterValues(String name); @Override String getScheme(); @Override String getRealRemoteAddr(); @Override Object getAttribute(String name); @Override void setAttribute(String name, Object value); @Override Map<String, Object> getAttributes(); @Override FileItem getParameterAsFileItem(String key); @Override List<FileItem> getParameterAsFileItems(String key); @Override Map<String, List<FileItem>> getParameterFileItems(); @Override Map<String, String[]> getParameters(); @Override String getHeader(String name); @Override List<String> getHeaders(String name); @Override Map<String, List<String>> getHeaders(); @Override Cookie getCookie(String cookieName); @Override boolean hasCookie(String cookieName); @Override List<Cookie> getCookies(); @Override void addCookie(Cookie cookie); @Override boolean isAsync(); @Override void returnResultAsync(Result result); @Override void handleAsync(); @Override Result controllerReturned(); @Override InputStream getInputStream(); @Override BufferedReader getReader(); @Override String getRequestContentType(); @Override boolean isMultipart(); @Override FileItemIterator getFileItemIterator(); ServletContext getServletContext(); HttpServletRequest getHttpServletRequest(); HttpServletResponse getHttpServletResponse(); @Override void cleanup();  }
@Test public void hasCookieTest() { javax.servlet.http.Cookie servletCookie1 = new javax.servlet.http.Cookie("contextCookie1", "theValue1"); javax.servlet.http.Cookie servletCookie2 = new javax.servlet.http.Cookie("contextCookie2", "theValue2"); javax.servlet.http.Cookie [] servletCookies = {servletCookie1, servletCookie2}; when(httpServletRequest.getCookies()).thenReturn(servletCookies); context.init(servletContext, httpServletRequest, httpServletResponse); assertFalse(context.hasCookie("doesNotExist")); assertTrue(context.hasCookie("contextCookie1")); assertTrue(context.hasCookie("contextCookie2")); }