### Question:
HeadersUtil { public static String toLogMsg(DpsHeaders headers, String userEmail) { ArrayList<String> msgs = new ArrayList<>(); msgs.add(String.format("account id: %s", headers.getAccountId())); if(headers.getHeaders().containsKey(DpsHeaders.PRIMARY_PARTITION_ID)) { msgs.add(String.format("primary account id: %s", headers.getHeaders().get(DpsHeaders.PRIMARY_PARTITION_ID))); } if (!Strings.isNullOrEmpty(headers.getOnBehalfOf())) { String onBehalfEmail = getEmailClaim(headers.getOnBehalfOf()); msgs.add(String.format("on behalf: %s", onBehalfEmail == null ? headers.getOnBehalfOf() : onBehalfEmail)); } String email = Strings.isNullOrEmpty(userEmail) ? headers.getUserEmail() : userEmail; if (Strings.isNullOrEmpty(email)) { if (!Strings.isNullOrEmpty(headers.getAuthorization())) { email = getEmailClaim(headers.getAuthorization()); } } if (!Strings.isNullOrEmpty(email)) msgs.add(String.format("user email: %s", email)); msgs.add(String.format("correlation id: %s", headers.getCorrelationId())); return String.join(" | ", msgs); }  static String toLogMsg(DpsHeaders headers, String userEmail); static String getEmailClaim(String bearerToken);  }### Answer:
@Test public void should_return_header_logs_when_header_contains_email() { List<String> token = new ArrayList<>(); token.add("any token"); List<String> onBehalf = new ArrayList<>(); onBehalf.add("bearer invalidJwtToken"); List<String> correlationId = new ArrayList<>(); correlationId.add("any correlationId"); List<String> userEmail = new ArrayList<>(); userEmail.add("abc@xyz.com"); List<String> accountId = new ArrayList<>(); accountId.add("any account"); MultiValueMap<String, String> requestHeaders = new LinkedMultiValueMap<>();; requestHeaders.put(DpsHeaders.AUTHORIZATION, token); requestHeaders.put(DpsHeaders.ON_BEHALF_OF, onBehalf); requestHeaders.put(DpsHeaders.CORRELATION_ID, correlationId); requestHeaders.put(DpsHeaders.USER_EMAIL, userEmail); requestHeaders.put(DpsHeaders.ACCOUNT_ID, accountId); DpsHeaders headers = DpsHeaders.createFromEntrySet(requestHeaders.entrySet()); assertEquals("account id: any account | on behalf: bearer invalidJwtToken | user email: any onBehalf | correlation id: " + "any correlationId", HeadersUtil.toLogMsg(headers, "any onBehalf")); }