Search in sources :

Example 1 with BasicPaymentItemsAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetBasicPaymentItemsAsyncTaskTest method testGetBasicPaymentItemsAsyncTaskWithoutGroupingWithAccountOnFile.

/**
 * Test that BasicPaymentItems can be successfully retrieved, not containing groups.
 * Also test that an account on file is returned
 */
@Test
public void testGetBasicPaymentItemsAsyncTaskWithoutGroupingWithAccountOnFile() throws InterruptedException, CommunicationException {
    try {
        initializeValidMocksAndSessionWithToken();
        final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
        // Create the BasicPaymentItemsAsyncTask and then begin the test by calling execute.
        List<BasicPaymentItemsAsyncTask.OnBasicPaymentItemsCallCompleteListener> listeners = new ArrayList<>();
        Listener listener = new Listener(waitForAsyncCallBack);
        listeners.add(listener);
        BasicPaymentItemsAsyncTask basicPaymentItemsAsyncTask = new BasicPaymentItemsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners, false);
        basicPaymentItemsAsyncTask.execute();
        // Test that the request for the call is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds.
        assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
        // Retrieve the response from the callback and validate that it has the correct fields
        BasicPaymentItems basicPaymentItems = listener.getBasicPaymentItems();
        // Validate the returned object
        validateBasicPaymentItemsList(basicPaymentItems);
        validateOnlyProducts(basicPaymentItems);
        validateAccountOnFile(basicPaymentItems);
    } finally {
        deleteToken();
    }
}
Also used : BasicPaymentItems(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItems) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) BasicPaymentItemsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask) Test(org.junit.Test)

Example 2 with BasicPaymentItemsAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetBasicPaymentItemsAsyncTaskTest method testGetBasicPaymentItemsAsyncTaskWithoutGrouping.

/**
 * Test that BasicPaymentItems can be successfully retrieved, not containing groups.
 */
@Test
public void testGetBasicPaymentItemsAsyncTaskWithoutGrouping() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the BasicPaymentItemsAsyncTask and then begin the test by calling execute.
    List<BasicPaymentItemsAsyncTask.OnBasicPaymentItemsCallCompleteListener> listeners = new ArrayList<>();
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    BasicPaymentItemsAsyncTask basicPaymentItemsAsyncTask = new BasicPaymentItemsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners, false);
    basicPaymentItemsAsyncTask.execute();
    // Test that the request for the call is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds.
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the response from the callback and validate that it has the correct fields
    BasicPaymentItems basicPaymentItems = listener.getBasicPaymentItems();
    // Validate the returned object
    validateBasicPaymentItemsList(basicPaymentItems);
    validateOnlyProducts(basicPaymentItems);
}
Also used : BasicPaymentItems(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItems) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) BasicPaymentItemsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask) Test(org.junit.Test)

Example 3 with BasicPaymentItemsAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetBasicPaymentItemsAsyncTaskTest method testGetBasicPaymentItemsAsyncTaskWithGrouping.

/**
 * Test that BasicPaymentItems can be successfully retrieved
 * Also test that the response contains products as well as groups
 */
@Test
public void testGetBasicPaymentItemsAsyncTaskWithGrouping() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the BasicPaymentItemsAsyncTask and then begin the test by calling execute.
    List<BasicPaymentItemsAsyncTask.OnBasicPaymentItemsCallCompleteListener> listeners = new ArrayList<>();
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    BasicPaymentItemsAsyncTask basicPaymentItemsAsyncTask = new BasicPaymentItemsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners, true);
    basicPaymentItemsAsyncTask.execute();
    // Test that the request for the call is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds.
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the response from the callback and validate that it has the correct fields
    BasicPaymentItems basicPaymentItems = listener.getBasicPaymentItems();
    // Validate the returned object
    validateBasicPaymentItemsList(basicPaymentItems);
    validateProductsAndGroups(basicPaymentItems);
}
Also used : BasicPaymentItems(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItems) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) BasicPaymentItemsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask) Test(org.junit.Test)

Example 4 with BasicPaymentItemsAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetBasicPaymentItemsAsyncTaskTest method testGetBasicPaymentItemsAsyncTaskWithInvalidRequest.

/**
 * Test that an invalid request for BasicPaymentProducts will still return, but will not retrieve PaymentItems
 */
@Test
public void testGetBasicPaymentItemsAsyncTaskWithInvalidRequest() throws InterruptedException {
    initializeInValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the BasicPaymentItemsAsyncTask and then begin the test by calling execute.
    List<BasicPaymentItemsAsyncTask.OnBasicPaymentItemsCallCompleteListener> listeners = new ArrayList<>();
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    BasicPaymentItemsAsyncTask basicPaymentItemsAsyncTask = new BasicPaymentItemsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners, true);
    basicPaymentItemsAsyncTask.execute();
    // Test that the request for the call is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds.
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the response from the callback and validate that it is indeed null
    BasicPaymentItems basicPaymentItems = listener.getBasicPaymentItems();
    assertNull(basicPaymentItems);
}
Also used : BasicPaymentItems(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItems) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) BasicPaymentItemsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask) Test(org.junit.Test)

Example 5 with BasicPaymentItemsAsyncTask

use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.

the class GetBasicPaymentItemsAsyncTaskTest method testGetBasicPaymentItemsAsyncTaskWithGroupingAndAccountsOnFile.

/**
 * Test that BasicPaymentItems can be successfully retrieved as well as AccountsOnFile
 * Also test that the response contains products as well as groups
 */
@Test
public void testGetBasicPaymentItemsAsyncTaskWithGroupingAndAccountsOnFile() throws InterruptedException, CommunicationException {
    try {
        initializeValidMocksAndSessionWithToken();
        final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
        // Create the BasicPaymentItemsAsyncTask and then begin the test by calling execute.
        List<BasicPaymentItemsAsyncTask.OnBasicPaymentItemsCallCompleteListener> listeners = new ArrayList<>();
        Listener listener = new Listener(waitForAsyncCallBack);
        listeners.add(listener);
        BasicPaymentItemsAsyncTask basicPaymentItemsAsyncTask = new BasicPaymentItemsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners, true);
        basicPaymentItemsAsyncTask.execute();
        // Test that the request for the call is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds.
        assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
        // Retrieve the response from the callback and test that it has the correct fields
        BasicPaymentItems basicPaymentItems = listener.getBasicPaymentItems();
        // Validate the returned object
        validateBasicPaymentItemsList(basicPaymentItems);
        validateProductsAndGroups(basicPaymentItems);
        validateAccountOnFile(basicPaymentItems);
    } finally {
        deleteToken();
    }
}
Also used : BasicPaymentItems(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItems) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) BasicPaymentItemsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask) Test(org.junit.Test)

Aggregations

BasicPaymentItemsAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask)6 ArrayList (java.util.ArrayList)6 BasicPaymentItems (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItems)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Test (org.junit.Test)5 OnBasicPaymentItemsCallCompleteListener (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentItemsAsyncTask.OnBasicPaymentItemsCallCompleteListener)1 InvalidParameterException (java.security.InvalidParameterException)1