### Question:
ResponseUtils { public void setCookies(HttpServletResponse response, ConsentReference consentReference, String accessTokenString, AccessTokenTO accessTokenTO) { int validity = cookieConfigProperties.getMaxAge(); if (StringUtils.isNoneBlank(accessTokenString) && accessTokenTO != null) { long diffInMillies = Math.abs(new Date().getTime() - accessTokenTO.getExp().getTime()); validity = ((Long) TimeUnit.SECONDS.convert(diffInMillies, TimeUnit.MILLISECONDS)).intValue(); Cookie accessTokenCookie = new Cookie(ACCESS_TOKEN_COOKIE_NAME, accessTokenString); accessTokenCookie.setHttpOnly(cookieConfigProperties.isHttpOnly()); accessTokenCookie.setSecure(cookieConfigProperties.isSecure()); accessTokenCookie.setMaxAge(validity); accessTokenCookie.setPath(cookieConfigProperties.getPath()); response.addCookie(accessTokenCookie); } else { removeCookie(response, ACCESS_TOKEN_COOKIE_NAME); } if (consentReference!=null && StringUtils.isNoneBlank(consentReference.getCookieString())) { Cookie consentCookie = new Cookie(CONSENT_COOKIE_NAME, consentReference.getCookieString()); consentCookie.setHttpOnly(true); consentCookie.setSecure(cookieConfigProperties.isSecure()); consentCookie.setMaxAge(validity); consentCookie.setPath(cookieConfigProperties.getPath()); response.addCookie(consentCookie); } }  void setCookies(HttpServletResponse response, ConsentReference consentReference, String accessTokenString,
			AccessTokenTO accessTokenTO); void removeCookies(HttpServletResponse response); ResponseEntity<T> unknownCredentials(
			T resp, HttpServletResponse httpResp); ResponseEntity<T> couldNotProcessRequest(T authResp, String message,
			HttpStatus status, HttpServletResponse httpResp); @SuppressWarnings("PMD.AvoidReassigningParameters") ResponseEntity<T> redirect(String locationURI, HttpServletResponse httpResp); ResponseEntity<T> error(T authResp, HttpStatus status, String message, HttpServletResponse response); String consentCookie(String cookieString); static final String CONSENT_COOKIE_NAME; static final String ACCESS_TOKEN_COOKIE_NAME; static final String UNKNOWN_CREDENTIALS; }### Answer:
@Test void setCookies() { HttpServletResponse response = Mockito.mock(HttpServletResponse.class); when(cookieConfigProperties.getMaxAge()).thenReturn(300); when(cookieConfigProperties.getPath()).thenReturn("somePath"); assertThatCode(() -> responseUtils.setCookies(response, getConsentReference(null), "accessTokenString", getAccessTokenTO())).doesNotThrowAnyException(); }
@Test void setCookies_accessTokenNull() { HttpServletResponse response = Mockito.mock(HttpServletResponse.class); when(cookieConfigProperties.getMaxAge()).thenReturn(300); when(cookieConfigProperties.getPath()).thenReturn("somePath"); assertThatCode(() -> responseUtils.setCookies(response, getConsentReference("someCookie"), null, getAccessTokenTO())).doesNotThrowAnyException(); }