Search in sources :

Example 1 with IinDetailsResponse

use of com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskUNKNOWNWithValidRequest.

@Test
public void testGetIinDetailsAsyncTaskUNKNOWNWithValidRequest() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Invalid number
    "123456", getCommunicator(), listeners, minimalValidPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the IinLookup returns with status UNKNOW 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 its status
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    validateResponseStatusUNKNOWN(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 2 with IinDetailsResponse

use of com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskSUPPORTEDWithInValidRequest.

@Test
public void testGetIinDetailsAsyncTaskSUPPORTEDWithInValidRequest() throws InterruptedException {
    initializeInValidMocksAndSession();
    final CountDownLatch waitForAsyncTaskCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute.
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncTaskCallBack);
    listeners.add(listener);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Visa number
    "401200", getCommunicator(), listeners, minimalValidPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the response is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncTaskCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the iin details response from the listener
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    // Test that the status assigned to response is UNKNOWN as it should be since the lookup failed
    validateResponseStatusUNKNOWN(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 3 with IinDetailsResponse

use of com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskEXISTING_BUT_NOT_ALLOWEDWithValidRequest.

@Test
public void testGetIinDetailsAsyncTaskEXISTING_BUT_NOT_ALLOWEDWithValidRequest() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    PaymentContext customPaymentContext = new PaymentContext(new AmountOfMoney(1000L, CurrencyCode.USD), CountryCode.US, false);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Number that is valid, but not allowed in the customPaymentContext
    "653598", getCommunicator(), listeners, customPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the IinLookup returns with status EXISTING_BUT_NOT_ALLOWED wiithin 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the response from the callback and validate its status
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    validateResponseStatusEXISTING_BUT_NOT_ALLOWED(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) PaymentContext(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentContext) AmountOfMoney(com.globalcollect.gateway.sdk.client.android.sdk.model.AmountOfMoney) Test(org.junit.Test)

Example 4 with IinDetailsResponse

use of com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskNOT_ENOUGH_DIGITSWithValidRequest.

@Test
public void testGetIinDetailsAsyncTaskNOT_ENOUGH_DIGITSWithValidRequest() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Number that is too short
    "1", getCommunicator(), listeners, minimalValidPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the IinLookup returns with status NOT_ENOUGH_DIGITS wiithin 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the response from the callback and validate its status
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    validateResponseStatusNOT_ENOUGH_DIGITS(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 5 with IinDetailsResponse

use of com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse in project connect-sdk-client-android by Ingenico-ePayments.

the class GetIinDetailsAsyncTaskTest method testGetIinDetailsAsyncTaskSUPPORTEDWithValidRequest.

@Test
public void testGetIinDetailsAsyncTaskSUPPORTEDWithValidRequest() throws InterruptedException, CommunicationException {
    initializeValidMocksAndSession();
    final CountDownLatch waitForAsyncTaskCallBack = new CountDownLatch(1);
    // Create the IinLookupAsyncTask and then begin the test by calling execute.
    List<IinLookupAsyncTask.OnIinLookupCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncTaskCallBack);
    listeners.add(listener);
    IinLookupAsyncTask iinLookupAsyncTask = new IinLookupAsyncTask(getContext(), // Visa number
    "401200", getCommunicator(), listeners, minimalValidPaymentContext);
    iinLookupAsyncTask.execute();
    // Test that the response is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncTaskCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve the iin details response from the listener
    IinDetailsResponse iinDetailsResponse = listener.getIinDetailsResponse();
    validateResponseStatusSUPPORTED(iinDetailsResponse);
}
Also used : IinDetailsResponse(com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

IinDetailsResponse (com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsResponse)8 IinLookupAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask)5 ArrayList (java.util.ArrayList)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Test (org.junit.Test)5 IOException (java.io.IOException)3 InvalidParameterException (java.security.InvalidParameterException)3 File (java.io.File)2 StreamCorruptedException (java.io.StreamCorruptedException)2 CommunicationException (com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException)1 AmountOfMoney (com.globalcollect.gateway.sdk.client.android.sdk.model.AmountOfMoney)1 PaymentContext (com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentContext)1 IinDetailsRequest (com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetailsRequest)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1