### Question:
CookieUtil { public static List<Cookie> getCookies(final HttpServletRequest request, final String regex) { final ArrayList<Cookie> foundCookies = new ArrayList<Cookie>(); if (StringUtils.isBlank(regex)) { return foundCookies; } final Cookie[] cookies = request.getCookies(); if (cookies == null) { return Collections.emptyList(); } final Pattern p = Pattern.compile(regex); for (final Cookie cookie : cookies) { final Matcher m = p.matcher(cookie.getName()); if (m.matches()) { foundCookies.add(cookie); } } return foundCookies; } private  CookieUtil(); static boolean addCookie(final Cookie cookie, final HttpServletResponse response); static Cookie getCookie(final HttpServletRequest request, final String cookieName); static List<Cookie> getCookies(final HttpServletRequest request, final String regex); static boolean extendCookieLife(final HttpServletRequest request, final HttpServletResponse response,
                                           final String cookieName, final String cookiePath, final int expiry); static int dropCookies(final HttpServletRequest request, final HttpServletResponse response, final String cookiePath, final String... cookieNames); static int dropCookiesByRegex(final HttpServletRequest request, final HttpServletResponse response, final String cookiePath, final String... regexes); static int dropCookiesByRegexArray(final HttpServletRequest request, final HttpServletResponse response, final String cookiePath, final String[] regexes); static int dropAllCookies(final HttpServletRequest request, final HttpServletResponse response, final String cookiePath);  }### Answer:
@Test public void testGetCookies() { String regex = "(.*)mammal(.*)"; List<Cookie> expResult = new ArrayList<Cookie>(); expResult.add(catCookie); expResult.add(dogCookie); List<Cookie> result = CookieUtil.getCookies(request, regex); assertEquals(expResult, result); }