Class RequestResult
java.lang.Object
com.soklet.RequestResult
Encapsulates the results of a request that would normally be handled by your
Server (both logical response and bytes to be sent over the wire), used for integration testing via Simulator.performRequest(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 ServerSentEventRequestResult, which is used for integration testing via Simulator.performServerSentEventRequest(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 ofRequestResultviawithMarshaledResponse(MarshaledResponse).static final classBuilder used to copy instances ofRequestResultviacopy(). -
Method Summary
Modifier and TypeMethodDescriptioncopy()Vends a mutable copier seeded with this instance's data, suitable for building new instances.booleanstatic @NonNull RequestResultfromMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Creates aRequestResultfrom 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()static @NonNull RequestResult.BuilderwithMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Acquires a builder forRequestResultinstances.
-
Method Details
-
withMarshaledResponse
public static @NonNull RequestResult.Builder withMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Acquires a builder forRequestResultinstances.- Parameters:
marshaledResponse- the bytes that will ultimately be written over the wire- Returns:
- the builder
-
fromMarshaledResponse
public static @NonNull RequestResult fromMarshaledResponse(@NonNull MarshaledResponse marshaledResponse) Creates aRequestResultfrom a marshaled response without additional customization.- Parameters:
marshaledResponse- the bytes that will ultimately be written over the wire- Returns:
- a
RequestResultinstance
-
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
-