HeaderUtils { public static int extractIntHeader(HttpResponse response, ResponseHeader responseHeader, int defaultValue) { Integer headerValue = extractIntegerHeader(response, responseHeader); if (headerValue == null) { return defaultValue; } return headerValue; }  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 extractIntHeader_withInvalidHeader_shouldUseDefaultValue() throws Exception { response.addHeader(AD_TIMEOUT.getKey(), "5"); assertThat(HeaderUtils.extractIntHeader(response, AD_TIMEOUT, 10)).isEqualTo(5); response.addHeader(AD_TIMEOUT.getKey(), "five!"); assertThat(HeaderUtils.extractIntHeader(response, AD_TIMEOUT, 10)).isEqualTo(10); }