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();
}
}
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);
}
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);
}
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);
}
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();
}
}
Aggregations