### Question:
RtcDefectAdapter implements DefectAdapter { Map<String, String> extractCookies(ResponseEntity<?> response) { Map<String, String> cookies = new HashMap<>(); final List<String> cookieSetters = response.getHeaders().get(HttpHeaders.SET_COOKIE); if (cookieSetters != null) { for (String headerValue : cookieSetters) { final Matcher matcher = COOKIE_PATTERN.matcher(headerValue); if (matcher.find()) { cookies.put(matcher.group(1), matcher.group(2)); } } } return cookies; } @Autowired  RtcDefectAdapter(SettingService settingService,
                            RestTemplateBuilder restTemplateBuilder,
                            RtcDateTimeAdapter rtcDateTimeAdapter,
                            SettingProviderService settingProviderService); @Override List<Defect> getStatuses(long projectId, List<String> ids); @Override List<Defect> getChangedDefects(long projectId, Date since); @Override boolean isValidId(long projectId, String id); @Override String getIdFormatHint(long projectId); @Override String getCode(); @Override String getName(); @Override List<SettingDTO> getSettingDefinitions();  }### Answer:
@Test public void extractCookies_should_extract_set_cookies() { Map<String, List<String>> headers = new HashMap<>(); headers.put("Some", Collections.singletonList("Too_be=Ignored")); headers.put("Set-Cookie", Arrays.asList("key1=value1", "key2=value2; some other properties", "wrong_format")); ResponseEntity<Map<String, List<String>>> response = new ResponseEntity<>(CollectionUtils.toMultiValueMap(headers), HttpStatus.OK); final Map<String, String> cookies = cut.extractCookies(response); assertThat(cookies).containsExactly(entry("key1", "value1"), entry("key2", "value2")); }
@Test public void extractCookies_should_return_none_if_no_cookies_set() { Map<String, List<String>> headers = new HashMap<>(); ResponseEntity<Map<String, List<String>>> response = new ResponseEntity<>(CollectionUtils.toMultiValueMap(headers), HttpStatus.OK); final Map<String, String> cookies = cut.extractCookies(response); assertThat(cookies).isEmpty(); }