Package net.officefloor.pay.paypal.mock
Class AbstractPayPalJUnit
- java.lang.Object
-
- net.officefloor.pay.paypal.mock.AbstractPayPalJUnit
-
- Direct Known Subclasses:
PayPalExtension
,PayPalRule
public class AbstractPayPalJUnit extends java.lang.Object
Abstract JUnit functionality to mockPayPalHttpClient
interaction.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
AbstractPayPalJUnit.Interaction<R extends com.paypal.http.HttpRequest<? extends java.lang.Object>>
Interaction.static interface
AbstractPayPalJUnit.Validator<R extends com.paypal.http.HttpRequest<? extends java.lang.Object>>
Validates theHttpRequest
.
-
Constructor Summary
Constructors Constructor Description AbstractPayPalJUnit()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addException(java.io.IOException exception)
Adds a failureAbstractPayPalJUnit.Interaction
.void
addException(java.util.function.Predicate<com.paypal.http.HttpRequest<com.paypal.orders.Order>> matcher, java.io.IOException exception)
Adds a failureAbstractPayPalJUnit.Interaction
.<R extends com.paypal.http.HttpRequest<? extends java.lang.Object>>
AbstractPayPalJUnit.Interaction<R>addInteraction(java.util.function.Predicate<java.lang.Object> matcher, int statusCode, java.lang.Object result, java.lang.String... headerNameValues)
Adds anAbstractPayPalJUnit.Interaction
.AbstractPayPalJUnit.Interaction<com.paypal.orders.OrdersCaptureRequest>
addOrdersCaptureResponse(com.paypal.orders.Order order, java.lang.String... headerNameValues)
Adds anOrdersCaptureRequest
AbstractPayPalJUnit.Interaction
.AbstractPayPalJUnit.Interaction<com.paypal.orders.OrdersCaptureRequest>
addOrdersCaptureResponse(java.util.function.Predicate<com.paypal.orders.OrdersCaptureRequest> matcher, int statusCode, com.paypal.orders.Order order, java.lang.String... headerNameValues)
Adds anOrdersCaptureRequest
AbstractPayPalJUnit.Interaction
.AbstractPayPalJUnit.Interaction<com.paypal.orders.OrdersCreateRequest>
addOrdersCreateResponse(com.paypal.orders.Order order, java.lang.String... headerNameValues)
Adds anOrdersCreateRequest
AbstractPayPalJUnit.Interaction
.AbstractPayPalJUnit.Interaction<com.paypal.orders.OrdersCreateRequest>
addOrdersCreateResponse(java.util.function.Predicate<com.paypal.orders.OrdersCreateRequest> matcher, int statusCode, com.paypal.orders.Order order, java.lang.String... headerNameValues)
Adds anOrdersCreateRequest
AbstractPayPalJUnit.Interaction
.void
assertInteractions()
Asserts the interactions.java.lang.String
getOrderId(com.paypal.orders.OrdersCaptureRequest request)
Extracts theOrder
id from theOrdersCaptureRequest
.protected void
setupMockPayPaylHttpClient()
Sets up the mock PayPal HTTP client.protected void
tearDownMockPayPaylHttpClient()
Tears down the mock PayPal HTTP client.
-
-
-
Method Detail
-
addInteraction
public <R extends com.paypal.http.HttpRequest<? extends java.lang.Object>> AbstractPayPalJUnit.Interaction<R> addInteraction(java.util.function.Predicate<java.lang.Object> matcher, int statusCode, java.lang.Object result, java.lang.String... headerNameValues)
Adds anAbstractPayPalJUnit.Interaction
.- Parameters:
matcher
-Predicate
to matchHttpRequest
.statusCode
- Status code.result
- Result.headerNameValues
-Headers
name/value pairs.- Returns:
AbstractPayPalJUnit.Interaction
.
-
addOrdersCreateResponse
public AbstractPayPalJUnit.Interaction<com.paypal.orders.OrdersCreateRequest> addOrdersCreateResponse(com.paypal.orders.Order order, java.lang.String... headerNameValues)
Adds anOrdersCreateRequest
AbstractPayPalJUnit.Interaction
.- Parameters:
order
-Order
.headerNameValues
-Headers
name/value pairs.- Returns:
AbstractPayPalJUnit.Interaction
.
-
addOrdersCreateResponse
public AbstractPayPalJUnit.Interaction<com.paypal.orders.OrdersCreateRequest> addOrdersCreateResponse(java.util.function.Predicate<com.paypal.orders.OrdersCreateRequest> matcher, int statusCode, com.paypal.orders.Order order, java.lang.String... headerNameValues)
Adds anOrdersCreateRequest
AbstractPayPalJUnit.Interaction
.- Parameters:
matcher
-Predicate
to matchOrdersCreateRequest
.statusCode
- Status code.order
-Order
.headerNameValues
-Headers
name/value pairs.- Returns:
AbstractPayPalJUnit.Interaction
.
-
addOrdersCaptureResponse
public AbstractPayPalJUnit.Interaction<com.paypal.orders.OrdersCaptureRequest> addOrdersCaptureResponse(com.paypal.orders.Order order, java.lang.String... headerNameValues)
Adds anOrdersCaptureRequest
AbstractPayPalJUnit.Interaction
.- Parameters:
order
-Order
.headerNameValues
-Headers
name/value pairs.- Returns:
AbstractPayPalJUnit.Interaction
.
-
addOrdersCaptureResponse
public AbstractPayPalJUnit.Interaction<com.paypal.orders.OrdersCaptureRequest> addOrdersCaptureResponse(java.util.function.Predicate<com.paypal.orders.OrdersCaptureRequest> matcher, int statusCode, com.paypal.orders.Order order, java.lang.String... headerNameValues)
Adds anOrdersCaptureRequest
AbstractPayPalJUnit.Interaction
.- Parameters:
matcher
-Predicate
to matchOrdersCaptureRequest
.statusCode
- Status code.order
-Order
.headerNameValues
-Headers
name/value pairs.- Returns:
AbstractPayPalJUnit.Interaction
.
-
addException
public void addException(java.io.IOException exception)
Adds a failureAbstractPayPalJUnit.Interaction
.- Parameters:
exception
-IOException
.
-
addException
public void addException(java.util.function.Predicate<com.paypal.http.HttpRequest<com.paypal.orders.Order>> matcher, java.io.IOException exception)
Adds a failureAbstractPayPalJUnit.Interaction
.- Parameters:
matcher
-Predicate
to matchHttpRequest
.exception
-IOException
.
-
getOrderId
public java.lang.String getOrderId(com.paypal.orders.OrdersCaptureRequest request)
Extracts theOrder
id from theOrdersCaptureRequest
.- Parameters:
request
-OrdersCaptureRequest
.- Returns:
Order
id.
-
assertInteractions
public void assertInteractions() throws java.lang.Exception
Asserts the interactions.- Throws:
java.lang.Exception
- If fails assertion.
-
setupMockPayPaylHttpClient
protected void setupMockPayPaylHttpClient()
Sets up the mock PayPal HTTP client.
-
tearDownMockPayPaylHttpClient
protected void tearDownMockPayPaylHttpClient() throws java.lang.Exception
Tears down the mock PayPal HTTP client.- Throws:
java.lang.Exception
-
-