### Question:
BaseService { public static Cookie getCookie(HttpServletRequest request, String name) { Cookie[] cookies = request.getCookies(); if (cookies != null && cookies.length > 0) { for (Cookie cookie : cookies) { if (StringUtils.isNotEmpty(name) && name.equalsIgnoreCase(cookie.getName())) { return cookie; } } } return null; }  static Cookie getCookie(HttpServletRequest request, String name);  }### Answer:
@Test public void testGetCookie(){ MockHttpServletRequest request = new MockHttpServletRequest(); MockCookie mockCookie = new MockCookie("userId","1"); request.setCookies(mockCookie); Cookie cookie = BaseService.getCookie(request,"userId"); Assert.assertNotNull(cookie); cookie = BaseService.getCookie(request,"userName"); Assert.assertNull(cookie); }