Skip to content

Commit

Permalink
apm: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlejoux committed Oct 31, 2019
1 parent 11a6e20 commit b53a5b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.json.JSONObject;
import org.junit.Test;

import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;

import androidx.test.core.app.ApplicationProvider;
Expand Down Expand Up @@ -54,7 +55,7 @@ public void onSuccess(String token) {
}

@Test
public void listAlternativePaymentGateways() {
public void listPaymentGateways() {
final CountDownLatch signal = new CountDownLatch(1);

Invoice invoice = new Invoice("test", "123.0", "EUR", new Device("android"));
Expand All @@ -68,7 +69,25 @@ public void onError(Exception error) {

@Override
public void onSuccess(JSONObject json) {
signal.countDown();
Invoice invoiceResult = null;
try {
invoiceResult = gson.fromJson(json.getJSONObject("invoice").toString(), Invoice.class);
} catch (JSONException e) {
fail("Unhandled exception");
e.printStackTrace();
return;
}
p.fetchGatewayConfigurations(invoiceResult.getId(), ProcessOut.GatewaysListingFilter.AlternativePaymentMethodWithTokenization, new FetchGatewaysConfigurationsCallback() {
@Override
public void onSuccess(ArrayList<GatewayConfiguration> gateways) {
signal.countDown();
}

@Override
public void onError(Exception e) {
fail("Error while fetching gateways");
}
});
}
});
} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,29 +661,4 @@ public void onError(Exception error) {
fail("Could not run test");
}
}

@Test
public void testAPMTokenization() {
final CountDownLatch signal = new CountDownLatch(1);

final Activity withActivity = activityRule.getActivity();
final ProcessOut p = new ProcessOut(withActivity, "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x");
p.listAlternativeMethods("iv_SuD6GUamoeLgYmRnDlEzM0wqamxW4WeY", new FetchGatewaysConfigurationsCallback() {
@Override
public void onSuccess(ArrayList<GatewayConfiguration> gateways) {
p.makeAPMToken(gateways.get(0), "cust_EiSdjbzbOPDMdFe0SFpe127T7eRcmLqK", "tok_ugUzL4AMG4ThOYOf2r12LKHFvlRyiEmV");
}

@Override
public void onError(Exception e) {
fail("Failed listing APM methods.");
}
});

try {
signal.await();// wait for callback
} catch (InterruptedException e) {
fail("Could not run test");
}
}
}

0 comments on commit b53a5b2

Please sign in to comment.