Class HttpResponseAssertionBuilder
java.lang.Object
com.atlassian.bamboo.testutils.http.HttpResponseAssertionBuilder
A utility class to build and perform assertions on HTTP response headers and status codes
This class is used in test cases to assert that responses have the expected headers and status
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum representing the type of content disposition -
Constructor Summary
ConstructorDescriptionHttpResponseAssertionBuilder
(org.springframework.mock.web.MockHttpServletResponse response) Constructs a HeaderAssertionBuilder for the specified response -
Method Summary
Modifier and TypeMethodDescriptioncontentDisposition
(HttpResponseAssertionBuilder.DispositionType dispositionType, String filename) Specifies the expected content disposition headerheaderEquals
(String header, String value) Specifies a header and its expected value in the responseisCompressed
(boolean expectedCompressed, long expectedDecompressedLength) Specifies whether the response content is expected to be compressednullHeaders
(String... headers) Specifies the headers that are expected to be absent (null) in the responsestatusIs
(int status) Specifies the expected HTTP status code for the responsevoid
verify()
Executes the assertions based on the specified expectations Verifies that the response has the expected status code, null headers, and header values
-
Constructor Details
-
HttpResponseAssertionBuilder
public HttpResponseAssertionBuilder(org.springframework.mock.web.MockHttpServletResponse response) Constructs a HeaderAssertionBuilder for the specified response- Parameters:
response
- the HTTP response to perform assertions on
-
-
Method Details
-
statusIs
Specifies the expected HTTP status code for the response- Parameters:
status
- the expected status code- Returns:
- the current instance of HeaderAssertionBuilder
-
nullHeaders
Specifies the headers that are expected to be absent (null) in the response- Parameters:
headers
- the names of the headers expected to be null- Returns:
- the current instance of HeaderAssertionBuilder
-
headerEquals
Specifies a header and its expected value in the response- Parameters:
header
- the name of the headervalue
- the expected value of the header- Returns:
- the current instance of HeaderAssertionBuilder
-
isCompressed
public HttpResponseAssertionBuilder isCompressed(boolean expectedCompressed, long expectedDecompressedLength) Specifies whether the response content is expected to be compressed- Parameters:
expectedCompressed
- true if the content is expected to be compressed, false otherwiseexpectedDecompressedLength
- the expected length of the decompressed content- Returns:
- the current instance of HeaderAssertionBuilder
-
contentDisposition
public HttpResponseAssertionBuilder contentDisposition(HttpResponseAssertionBuilder.DispositionType dispositionType, String filename) Specifies the expected content disposition header- Parameters:
dispositionType
- the expected disposition type (ATTACHMENT or INLINE)filename
- the expected filename in the content disposition- Returns:
- the current instance of HeaderAssertionBuilder
-
verify
public void verify()Executes the assertions based on the specified expectations Verifies that the response has the expected status code, null headers, and header values
-