Class HttpRequestResult
java.lang.Object
com.soklet.HttpRequestResult
Encapsulates the results of a request that would normally be handled by your
HttpServer (both logical response and bytes to be sent over the wire), used for integration testing via Simulator.performHttpRequest(Request).
Instances can be acquired via the withMarshaledResponse(MarshaledResponse) builder factory method.
A convenience instance factory is also available via fromMarshaledResponse(MarshaledResponse).
The Server-Sent Event equivalent of this type is SseRequestResult, which is used for integration testing via Simulator.performSseRequest(Request).
See https://www.soklet.com/docs/testing#integration-testing for detailed documentation.
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder used to construct instances ofHttpRequestResultviawithMarshaledResponse(MarshaledResponse).static final classBuilder used to copy instances ofHttpRequestResultviacopy(). -
Method Summary
Modifier and TypeMethodDescriptioncopy()Vends a mutable copier seeded with this instance's data, suitable for building new instances.booleanstatic @NonNull HttpRequestResultfromMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Creates aHttpRequestResultfrom a marshaled response without additional customization.The CORS preflight logical response, if applicable for the request.The final representation of the response to be written over the wire.The Resource Method that handled the request, if available.The logical response, determined by the return value of the Resource Method (if available).inthashCode()toString()withMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Acquires a builder forHttpRequestResultinstances.
-
Method Details
-
withMarshaledResponse
public static @NonNull HttpRequestResult.Builder withMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Acquires a builder forHttpRequestResultinstances.- Parameters:
marshaledResponse- the bytes that will ultimately be written over the wire- Returns:
- the builder
-
fromMarshaledResponse
public static @NonNull HttpRequestResult fromMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Creates aHttpRequestResultfrom a marshaled response without additional customization.- Parameters:
marshaledResponse- the bytes that will ultimately be written over the wire- Returns:
- a
HttpRequestResultinstance
-
copy
Vends a mutable copier seeded with this instance's data, suitable for building new instances.- Returns:
- a copier for this instance
-
toString
-
equals
-
hashCode
-
getMarshaledResponse
The final representation of the response to be written over the wire.- Returns:
- the response to be written over the wire
-
getResponse
The logical response, determined by the return value of the Resource Method (if available).- Returns:
- the logical response
-
getCorsPreflightResponse
The CORS preflight logical response, if applicable for the request.- Returns:
- the CORS preflight logical response
-
getResourceMethod
The Resource Method that handled the request, if available.- Returns:
- the Resource Method that handled the request
-