HeaderUtils { public static boolean extractBooleanHeader(HttpResponse response, ResponseHeader responseHeader, boolean defaultValue) { String header = extractHeader(response, responseHeader); if (header == null) { return defaultValue; } return header.equals("1"); }  static String extractHeader(Map<String, String> headers, ResponseHeader responseHeader); static String extractHeader(HttpResponse response, ResponseHeader responseHeader); static boolean extractBooleanHeader(HttpResponse response, ResponseHeader responseHeader, boolean defaultValue); static Integer extractIntegerHeader(HttpResponse response, ResponseHeader responseHeader); static int extractIntHeader(HttpResponse response, ResponseHeader responseHeader, int defaultValue);  }
@Test public void extractBooleanHeader_whenValueIsZero_shouldReturnFalse() throws Exception { response.addHeader(SCROLLABLE.getKey(), "0"); assertThat(HeaderUtils.extractBooleanHeader(response, SCROLLABLE, false)).isFalse(); response.addHeader(SCROLLABLE.getKey(), "0"); assertThat(HeaderUtils.extractBooleanHeader(response, SCROLLABLE, true)).isFalse(); }
@Test public void extractBooleanHeader_whenValueIsOne_shouldReturnTrue() throws Exception { response.addHeader(SCROLLABLE.getKey(), "1"); assertThat(HeaderUtils.extractBooleanHeader(response, SCROLLABLE, false)).isTrue(); response.addHeader(SCROLLABLE.getKey(), "1"); assertThat(HeaderUtils.extractBooleanHeader(response, SCROLLABLE, true)).isTrue(); }
@Test public void extractBooleanHeader_shouldReturnDefaultValue() throws Exception { assertThat(HeaderUtils.extractBooleanHeader(response, SCROLLABLE, false)).isFalse(); assertThat(HeaderUtils.extractBooleanHeader(response, SCROLLABLE, true)).isTrue(); }