Class Exchange
- java.lang.Object
-
- org.swisspush.gateleen.player.exchange.Exchange
-
public class Exchange extends java.lang.ObjectModels a request log entry.- Author:
- https://github.com/lbovet [Laurent Bovet]
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidassertSameExchange(Exchange expected, Exchange actual)Convenience method for unit tests.static <T extends org.springframework.http.HttpEntity<org.json.JSONObject>>
com.google.common.base.Predicate<T>body(com.jayway.jsonpath.Predicate bodyPredicate)Predicate that applies to a request or response body.booleanequals(java.lang.Object o)java.lang.StringgetId()Convenience method to retrieve thex-request-idheader.org.springframework.http.RequestEntity<org.json.JSONObject>getRequest()org.springframework.http.ResponseEntity<org.json.JSONObject>getResponse()java.lang.StringgetTimestamp()Convenience method to retrieve thex-client-timestampheader.inthashCode()static <T extends org.springframework.http.HttpEntity<org.json.JSONObject>,U extends java.lang.CharSequence>
com.google.common.base.Predicate<T>header(java.lang.String key, com.google.common.base.Predicate<U> stringPredicate)Predicate that applies to a given request or response header.static <T extends org.springframework.http.HttpEntity<org.json.JSONObject>>
com.google.common.base.Predicate<T>headers(com.google.common.base.Predicate<org.springframework.http.HttpHeaders> headersPredicate)Predicate that applies to request or response headers.static com.google.common.base.Predicate<org.springframework.http.RequestEntity<org.json.JSONObject>>method(com.google.common.base.Predicate<org.springframework.http.HttpMethod> methodPredicate)Predicate that applies to the request HTTP method.static com.google.common.base.Predicate<Exchange>request(com.google.common.base.Predicate<? super org.springframework.http.RequestEntity<org.json.JSONObject>> requestPredicate)Predicate that applies to the request part.static com.google.common.base.Predicate<Exchange>response(com.google.common.base.Predicate<? super org.springframework.http.ResponseEntity<org.json.JSONObject>> responsePredicate)Predicate that applies to the response part.voidsetRequest(org.springframework.http.RequestEntity<org.json.JSONObject> request)voidsetResponse(org.springframework.http.ResponseEntity<org.json.JSONObject> response)static com.google.common.base.Predicate<org.springframework.http.ResponseEntity<org.json.JSONObject>>status(com.google.common.base.Predicate<org.springframework.http.HttpStatus> statusPredicate)Predicate that applies to the response HTTP status code.java.lang.StringtoString()static com.google.common.base.Predicate<org.springframework.http.RequestEntity<org.json.JSONObject>>url(com.google.common.base.Predicate<? super java.lang.CharSequence> stringPredicate)Predicate that applies to the request URL.static com.google.common.base.Predicate<Exchange>withId(java.lang.String... requestIds)Predicate matching exchanges having one of the specifiedx-request-idheader.
-
-
-
Constructor Detail
-
Exchange
public Exchange(org.springframework.http.RequestEntity<org.json.JSONObject> request, org.springframework.http.ResponseEntity<org.json.JSONObject> response)
-
Exchange
public Exchange(java.lang.String urlPrefix, org.json.JSONObject json)- Parameters:
urlPrefix- A prefix added to the request URI.json- Source exchange in JSON form.
-
-
Method Detail
-
getRequest
public org.springframework.http.RequestEntity<org.json.JSONObject> getRequest()
-
setRequest
public void setRequest(org.springframework.http.RequestEntity<org.json.JSONObject> request)
-
getResponse
public org.springframework.http.ResponseEntity<org.json.JSONObject> getResponse()
-
setResponse
public void setResponse(org.springframework.http.ResponseEntity<org.json.JSONObject> response)
-
getTimestamp
public java.lang.String getTimestamp()
Convenience method to retrieve thex-client-timestampheader.- Returns:
- the ISO timestamp string
-
getId
public java.lang.String getId()
Convenience method to retrieve thex-request-idheader.- Returns:
- the ID
-
request
public static com.google.common.base.Predicate<Exchange> request(com.google.common.base.Predicate<? super org.springframework.http.RequestEntity<org.json.JSONObject>> requestPredicate)
Predicate that applies to the request part.- Parameters:
requestPredicate- requestPredicate- Returns:
- Predicate
-
response
public static com.google.common.base.Predicate<Exchange> response(com.google.common.base.Predicate<? super org.springframework.http.ResponseEntity<org.json.JSONObject>> responsePredicate)
Predicate that applies to the response part.- Parameters:
responsePredicate- responsePredicate- Returns:
- Predicate
-
withId
public static com.google.common.base.Predicate<Exchange> withId(java.lang.String... requestIds)
Predicate matching exchanges having one of the specifiedx-request-idheader.- Parameters:
requestIds- requestIds- Returns:
- Predicate
-
url
public static com.google.common.base.Predicate<org.springframework.http.RequestEntity<org.json.JSONObject>> url(com.google.common.base.Predicate<? super java.lang.CharSequence> stringPredicate)
Predicate that applies to the request URL.- Parameters:
stringPredicate- stringPredicate- Returns:
- Predicate
-
method
public static com.google.common.base.Predicate<org.springframework.http.RequestEntity<org.json.JSONObject>> method(com.google.common.base.Predicate<org.springframework.http.HttpMethod> methodPredicate)
Predicate that applies to the request HTTP method.- Parameters:
methodPredicate- methodPredicate- Returns:
- Predicate
-
status
public static com.google.common.base.Predicate<org.springframework.http.ResponseEntity<org.json.JSONObject>> status(com.google.common.base.Predicate<org.springframework.http.HttpStatus> statusPredicate)
Predicate that applies to the response HTTP status code.- Parameters:
statusPredicate- statusPredicate- Returns:
- Predicate
-
body
public static <T extends org.springframework.http.HttpEntity<org.json.JSONObject>> com.google.common.base.Predicate<T> body(com.jayway.jsonpath.Predicate bodyPredicate)
Predicate that applies to a request or response body.- Parameters:
bodyPredicate- bodyPredicate- Returns:
- Predicate
-
headers
public static <T extends org.springframework.http.HttpEntity<org.json.JSONObject>> com.google.common.base.Predicate<T> headers(com.google.common.base.Predicate<org.springframework.http.HttpHeaders> headersPredicate)
Predicate that applies to request or response headers.- Parameters:
headersPredicate- headersPredicate- Returns:
- Predicate
-
header
public static <T extends org.springframework.http.HttpEntity<org.json.JSONObject>,U extends java.lang.CharSequence> com.google.common.base.Predicate<T> header(java.lang.String key, com.google.common.base.Predicate<U> stringPredicate)Predicate that applies to a given request or response header.- Parameters:
key- keystringPredicate- stringPredicate- Returns:
- Predicate
-
assertSameExchange
public static void assertSameExchange(Exchange expected, Exchange actual)
Convenience method for unit tests.- Parameters:
expected- expectedactual- actual
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
-