Class HttpHeadersAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractObjectAssert<HttpHeadersAssert,HttpHeaders>
org.springframework.test.http.HttpHeadersAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<HttpHeadersAssert,HttpHeaders>, org.assertj.core.api.Descriptable<HttpHeadersAssert>, org.assertj.core.api.ExtensionPoints<HttpHeadersAssert,HttpHeaders>

public class HttpHeadersAssert extends org.assertj.core.api.AbstractObjectAssert<HttpHeadersAssert,HttpHeaders>
AssertJ assertions that can be applied to HttpHeaders.
Since:
6.2
Author:
Stephane Nicoll, Simon Baslé
  • Field Summary

    Fields inherited from class org.assertj.core.api.AbstractAssert

    actual, info, myself, objects, throwUnsupportedExceptionOnEquals
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Verify that the actual HTTP headers contain a header with the given name.
    Verify that the actual HTTP headers contain the headers with the given names.
    Verify that the actual HTTP headers contain only the headers with the given names, in any order and in a case-insensitive manner.
    Verify that the actual HTTP headers do not contain a header with the given name.
    Verify that the actual HTTP headers do not contain any of the headers with the given names.
    Verify that the given header has a full list of values exactly equal to the given list of values, and in the same order.
    Verify that the given header has a full list of values exactly equal to the given list of values, in any order.
    hasHeaderSatisfying(String name, Consumer<List<String>> valueRequirements)
    Verify that the actual HTTP headers contain a header with the given name that satisfies the given valueRequirements.
    Verify that the number of actual headers is the same as in the given HttpHeaders.
    hasSingleValue(String name, long value)
    Verify that the actual HTTP headers contain a header with the given name and long primary value.
    Verify that the actual HTTP headers contain a header with the given name and String primary value.
    Verify that the actual HTTP headers contain a header with the given name and Instant primary value.
    hasSize(int expected)
    Verify that there are exactly expected headers present, when considering header names in a case-insensitive manner.
    hasValue(String name, long value)
    Verify that the actual HTTP headers contain a header with the given name and long primary value.
    hasValue(String name, String value)
    Verify that the actual HTTP headers contain a header with the given name and String primary value.
    hasValue(String name, Instant value)
    Verify that the actual HTTP headers contain a header with the given name and Instant primary value.
    Verify that the actual HTTP headers are empty and no header is present.
    Verify that the actual HTTP headers are not empty and at least one header is present.

    Methods inherited from class org.assertj.core.api.AbstractObjectAssert

    as, as, doesNotReturn, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison

    Methods inherited from class org.assertj.core.api.AbstractAssert

    actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingEquals, usingEquals, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.assertj.core.api.Descriptable

    as, describedAs, describedAs
  • Constructor Details

    • HttpHeadersAssert

      public HttpHeadersAssert(HttpHeaders actual)
  • Method Details

    • containsHeader

      public HttpHeadersAssert containsHeader(String name)
      Verify that the actual HTTP headers contain a header with the given name.
      Parameters:
      name - the name of an expected HTTP header
    • containsHeaders

      public HttpHeadersAssert containsHeaders(String... names)
      Verify that the actual HTTP headers contain the headers with the given names.
      Parameters:
      names - the names of expected HTTP headers
    • containsOnlyHeaders

      public HttpHeadersAssert containsOnlyHeaders(String... names)
      Verify that the actual HTTP headers contain only the headers with the given names, in any order and in a case-insensitive manner.
      Parameters:
      names - the names of expected HTTP headers
      Since:
      7.0
    • doesNotContainHeader

      public HttpHeadersAssert doesNotContainHeader(String name)
      Verify that the actual HTTP headers do not contain a header with the given name.
      Parameters:
      name - the name of an HTTP header that should not be present
    • doesNotContainHeaders

      public HttpHeadersAssert doesNotContainHeaders(String... names)
      Verify that the actual HTTP headers do not contain any of the headers with the given names.
      Parameters:
      names - the names of HTTP headers that should not be present
      Since:
      6.2.2
    • hasHeaderSatisfying

      public HttpHeadersAssert hasHeaderSatisfying(String name, Consumer<List<String>> valueRequirements)
      Verify that the actual HTTP headers contain a header with the given name that satisfies the given valueRequirements.
      Parameters:
      name - the name of the header
      valueRequirements - the group of assertions to run against the values of the header with the given name
      Since:
      7.0
    • hasValue

      public HttpHeadersAssert hasValue(String name, String value)
      Verify that the actual HTTP headers contain a header with the given name and String primary value.
      Parameters:
      name - the name of the header
      value - the expected value of the header
    • hasValue

      public HttpHeadersAssert hasValue(String name, long value)
      Verify that the actual HTTP headers contain a header with the given name and long primary value.
      Parameters:
      name - the name of the header
      value - the expected value of the header
    • hasValue

      public HttpHeadersAssert hasValue(String name, Instant value)
      Verify that the actual HTTP headers contain a header with the given name and Instant primary value.
      Parameters:
      name - the name of the header
      value - the expected value of the header
    • hasSingleValue

      public HttpHeadersAssert hasSingleValue(String name, String value)
      Verify that the actual HTTP headers contain a header with the given name and String primary value.

      This assertion fails if the header has secondary values.

      Parameters:
      name - the name of the header
      value - the expected value of the header
      Since:
      7.0
    • hasSingleValue

      public HttpHeadersAssert hasSingleValue(String name, long value)
      Verify that the actual HTTP headers contain a header with the given name and long primary value.

      This assertion fails if the header has secondary values.

      Parameters:
      name - the name of the header
      value - the expected value of the header
      Since:
      7.0
    • hasSingleValue

      public HttpHeadersAssert hasSingleValue(String name, Instant value)
      Verify that the actual HTTP headers contain a header with the given name and Instant primary value.

      This assertion fails if the header has secondary values.

      Parameters:
      name - the name of the header
      value - the expected value of the header
      Since:
      7.0
    • hasExactlyValues

      public HttpHeadersAssert hasExactlyValues(String name, List<String> values)
      Verify that the given header has a full list of values exactly equal to the given list of values, and in the same order.
      Parameters:
      name - the considered header name (case-insensitive)
      values - the exhaustive list of expected values
      Since:
      7.0
    • hasExactlyValuesInAnyOrder

      public HttpHeadersAssert hasExactlyValuesInAnyOrder(String name, List<String> values)
      Verify that the given header has a full list of values exactly equal to the given list of values, in any order.
      Parameters:
      name - the considered header name (case-insensitive)
      values - the exhaustive list of expected values
      Since:
      7.0
    • isEmpty

      public HttpHeadersAssert isEmpty()
      Verify that the actual HTTP headers are empty and no header is present.
    • isNotEmpty

      public HttpHeadersAssert isNotEmpty()
      Verify that the actual HTTP headers are not empty and at least one header is present.
    • hasSize

      public HttpHeadersAssert hasSize(int expected)
      Verify that there are exactly expected headers present, when considering header names in a case-insensitive manner.
      Parameters:
      expected - the expected number of headers
    • hasSameSizeAs

      public HttpHeadersAssert hasSameSizeAs(HttpHeaders other)
      Verify that the number of actual headers is the same as in the given HttpHeaders.
      Parameters:
      other - the HttpHeaders to compare size with
      Since:
      7.0