use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentProductGroupsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GcSession method getBasicPaymentProductGroups.
/**
* Gets BasicPaymentProducts for the given PaymentRequest
*
* @param context, used for reading device metada which is send to the GC gateway
* @param paymentContext, C2sPaymentProductContext 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 getBasicPaymentProductGroups(Context context, PaymentContext paymentContext, OnBasicPaymentProductGroupsCallCompleteListener listener) {
if (context == null) {
throw new InvalidParameterException("Error getting paymentProductGroups, context may not be null");
}
if (paymentContext == null) {
throw new InvalidParameterException("Error getting paymentProductGroups, paymentContext may not be null");
}
if (listener == null) {
throw new InvalidParameterException("Error getting paymentProductGroups, listener may not be null");
}
this.paymentContext = paymentContext;
// Add OnBasicPaymentProductGroupsCallCompleteListener and this class to list of listeners so we can store the paymentProductGroups here
List<OnBasicPaymentProductGroupsCallCompleteListener> listeners = new ArrayList<>();
listeners.add(this);
listeners.add(listener);
// Start the task which gets paymentproducts
BasicPaymentProductGroupsAsyncTask task = new BasicPaymentProductGroupsAsyncTask(context, paymentContext, communicator, listeners);
task.execute();
}
use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentProductGroupsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GetBasicPaymentProductGroupsAsyncTaskTest method testGetBasicPaymentProductGroupsAsyncTaskWithValidRequestWithAccountOnFile.
/**
* Test that BasicPaymentProductGroups can be successfully retrieved by doing the required call
*/
@Test
public // Test that BasicPaymentProductGroups can be successfully retrieved by doing the required call
void testGetBasicPaymentProductGroupsAsyncTaskWithValidRequestWithAccountOnFile() throws InterruptedException, CommunicationException {
try {
initializeValidMocksAndSessionWithToken();
final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
// Create the BasicPaymentProductGroupsAsyncTask and then begin the test by calling execute.
List<BasicPaymentProductGroupsAsyncTask.OnBasicPaymentProductGroupsCallCompleteListener> listeners = new ArrayList<>();
Listener listener = new Listener(waitForAsyncCallBack);
listeners.add(listener);
BasicPaymentProductGroupsAsyncTask basicPaymentProductGroupsAsyncTask = new BasicPaymentProductGroupsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners);
basicPaymentProductGroupsAsyncTask.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
BasicPaymentProductGroups basicPaymentProductGroups = listener.getBasicPaymentProductGroups();
validateBasicPaymentProductGroupsList(basicPaymentProductGroups);
// Validate that the first paymentProductGroup in the returned list has the required fields
validateBasicPaymentProductGroup(basicPaymentProductGroups.getBasicPaymentProductGroups().get(0));
validateAccountOnFile(basicPaymentProductGroups);
} finally {
deleteToken();
}
}
use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentProductGroupsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GetBasicPaymentProductGroupsAsyncTaskTest method testGetBasicPaymentProductGroupsAsyncTaskWithInvalidRequest.
/**
* Test that an invalid request for BasicPaymentProductGroups will still return, but will not retrieve PaymentProductGroups
*/
@Test
public void testGetBasicPaymentProductGroupsAsyncTaskWithInvalidRequest() throws InterruptedException {
initializeInValidMocksAndSession();
final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
// Create the BasicPaymentProductsAsyncTask and then begin the test by calling execute.
List<BasicPaymentProductGroupsAsyncTask.OnBasicPaymentProductGroupsCallCompleteListener> listeners = new ArrayList<>();
Listener listener = new Listener(waitForAsyncCallBack);
listeners.add(listener);
BasicPaymentProductGroupsAsyncTask basicPaymentProductGroupsAsyncTask = new BasicPaymentProductGroupsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners);
basicPaymentProductGroupsAsyncTask.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
BasicPaymentProductGroups basicPaymentProductGroups = listener.getBasicPaymentProductGroups();
assertNull(basicPaymentProductGroups);
}
use of com.globalcollect.gateway.sdk.client.android.sdk.asynctask.BasicPaymentProductGroupsAsyncTask in project connect-sdk-client-android by Ingenico-ePayments.
the class GetBasicPaymentProductGroupsAsyncTaskTest method testGetBasicPaymentProductGroupsAsyncTaskWithValidRequest.
/**
* Test that BasicPaymentProductGroups can be successfully retrieved by doing the required call
*/
@Test
public // Test that BasicPaymentProductGroups can be successfully retrieved by doing the required call
void testGetBasicPaymentProductGroupsAsyncTaskWithValidRequest() throws InterruptedException, CommunicationException {
initializeValidMocksAndSession();
final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
// Create the BasicPaymentProductGroupsAsyncTask and then begin the test by calling execute.
List<BasicPaymentProductGroupsAsyncTask.OnBasicPaymentProductGroupsCallCompleteListener> listeners = new ArrayList<>();
Listener listener = new Listener(waitForAsyncCallBack);
listeners.add(listener);
BasicPaymentProductGroupsAsyncTask basicPaymentProductGroupsAsyncTask = new BasicPaymentProductGroupsAsyncTask(getContext(), minimalValidPaymentContext, getCommunicator(), listeners);
basicPaymentProductGroupsAsyncTask.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
BasicPaymentProductGroups basicPaymentProductGroups = listener.getBasicPaymentProductGroups();
validateBasicPaymentProductGroupsList(basicPaymentProductGroups);
// Validate that the first paymentProductGroup in the returned list has the required fields
validateBasicPaymentProductGroup(basicPaymentProductGroups.getBasicPaymentProductGroups().get(0));
}
Aggregations