use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentProductsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GetBasicPaymentProductsAsyncTaskTest method testGetBasicPaymentProductsAsyncTaskWithInvalidRequest.
/**
* Test that an invalid request for BasicPaymentProducts will still return, but will not retrieve PaymentProducts
*/
@Test
public void testGetBasicPaymentProductsAsyncTaskWithInvalidRequest() throws InterruptedException {
initializeInValidMocksAndSession();
final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
// Create the BasicPaymentProductsAsyncTask and then begin the test by calling execute.
List<BasicPaymentProductsAsyncTask.OnBasicPaymentProductsCallCompleteListener> listeners = new ArrayList<>();
Listener listener = new Listener(waitForAsyncCallBack);
listeners.add(listener);
BasicPaymentProductsAsyncTask basicPaymentProductsAsyncTask = new BasicPaymentProductsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners);
basicPaymentProductsAsyncTask.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
BasicPaymentProducts basicPaymentProducts = listener.getBasicPaymentProducts();
assertNull(basicPaymentProducts);
}
use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentProductsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GetBasicPaymentProductsAsyncTaskTest method testGetBasicPaymentProductsAsyncTaskWithValidRequest.
/**
* Test that BasicPaymentProducts can be successfully retrieved and have the minimal fields
*/
@Test
public void testGetBasicPaymentProductsAsyncTaskWithValidRequest() throws InterruptedException, CommunicationException {
initializeValidMocksAndSession();
final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
// Create the BasicPaymentProductsAsyncTask and then begin the test by calling execute.
List<BasicPaymentProductsAsyncTask.OnBasicPaymentProductsCallCompleteListener> listeners = new ArrayList<>(1);
Listener listener = new Listener(waitForAsyncCallBack);
listeners.add(listener);
BasicPaymentProductsAsyncTask basicPaymentProductsAsyncTask = new BasicPaymentProductsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners);
basicPaymentProductsAsyncTask.execute();
// Test that the response 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
BasicPaymentProducts basicPaymentProducts = listener.getBasicPaymentProducts();
validateBasicPaymentProductsList(basicPaymentProducts);
// Validate that the first paymentProduct in the returned list has the required fields
validateBasicPaymentProduct(basicPaymentProducts.getBasicPaymentProducts().get(0));
}
use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentProductsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GetBasicPaymentProductsAsyncTaskTest method testGetBasicPaymentProductsAsyncTaskWithValidRequestAndAccountsOnFile.
/**
* Test that BasicPaymentProducts can be successfully retrieved including AccountOnFiles and that they both have the minimal fields
*/
@Test
public void testGetBasicPaymentProductsAsyncTaskWithValidRequestAndAccountsOnFile() throws InterruptedException, CommunicationException {
try {
initializeValidMocksAndSessionWithToken();
final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
// Create the BasicPaymentProductsAsyncTask and then begin the test by calling execute.
List<BasicPaymentProductsAsyncTask.OnBasicPaymentProductsCallCompleteListener> listeners = new ArrayList<>();
Listener listener = new Listener(waitForAsyncCallBack);
listeners.add(listener);
BasicPaymentProductsAsyncTask basicPaymentProductsAsyncTask = new BasicPaymentProductsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners);
basicPaymentProductsAsyncTask.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
BasicPaymentProducts basicPaymentProducts = listener.getBasicPaymentProducts();
validateBasicPaymentProductsList(basicPaymentProducts);
// Test that the first paymentProduct in the returned list has the required fields
validateBasicPaymentProduct(basicPaymentProducts.getBasicPaymentProducts().get(0));
validateAccountOnFile(basicPaymentProducts);
} finally {
deleteToken();
}
}
use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentProductsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GcSession method getBasicPaymentProducts.
/**
* Gets BasicPaymentProducts for the given PaymentRequest
*
* @param context, used for reading device metadata which is send to the GC gateway
* @param paymentContext, PaymentContext which contains all neccesary data for doing call to the GC gateway to retrieve paymentproducts
* @param listener, OnPaymentProductsCallComplete which will be called by the BasicPaymentProductsAsyncTask when the BasicPaymentProducts are loaded
*/
public void getBasicPaymentProducts(Context context, PaymentContext paymentContext, OnBasicPaymentProductsCallCompleteListener listener) {
if (context == null) {
throw new InvalidParameterException("Error getting paymentproduct, context may not be null");
}
if (paymentContext == null) {
throw new InvalidParameterException("Error getting paymentproducts, paymentContext may not be null");
}
if (listener == null) {
throw new InvalidParameterException("Error getting paymentproducts, listener may not be null");
}
this.paymentContext = paymentContext;
// Add OnBasicPaymentProductsCallCompleteListener and this class to list of listeners so we can store the paymentproducts here
List<OnBasicPaymentProductsCallCompleteListener> listeners = new ArrayList<OnBasicPaymentProductsCallCompleteListener>();
listeners.add(this);
listeners.add(listener);
// Start the task which gets paymentproducts
BasicPaymentProductsAsyncTask task = new BasicPaymentProductsAsyncTask(context, paymentContext, communicator, listeners);
task.execute();
}
Aggregations