Class AbstractPayPalJUnit

  • Direct Known Subclasses:
    PayPalExtension, PayPalRule

    public class AbstractPayPalJUnit
    extends java.lang.Object
    Abstract JUnit functionality to mock PayPalHttpClient interaction.
    Author:
    Daniel Sagenschneider
    • Constructor Detail

      • AbstractPayPalJUnit

        public AbstractPayPalJUnit()
    • 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)
        Parameters:
        matcher - Predicate to match HttpRequest.
        statusCode - Status code.
        result - Result.
        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 an OrdersCreateRequest AbstractPayPalJUnit.Interaction.
        Parameters:
        matcher - Predicate to match OrdersCreateRequest.
        statusCode - Status code.
        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 an OrdersCaptureRequest AbstractPayPalJUnit.Interaction.
        Parameters:
        matcher - Predicate to match OrdersCaptureRequest.
        statusCode - Status code.
        order - Order.
        headerNameValues - Headers name/value pairs.
        Returns:
        AbstractPayPalJUnit.Interaction.
      • addException

        public void addException​(java.io.IOException exception)
        Parameters:
        exception - IOException.
      • addException

        public void addException​(java.util.function.Predicate<com.paypal.http.HttpRequest<com.paypal.orders.Order>> matcher,
                                 java.io.IOException exception)
        Parameters:
        matcher - Predicate to match HttpRequest.
        exception - IOException.
      • getOrderId

        public java.lang.String getOrderId​(com.paypal.orders.OrdersCaptureRequest request)
        Extracts the Order id from the OrdersCaptureRequest.
        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