|
3 | 3 | import static org.junit.Assert.fail; |
4 | 4 |
|
5 | 5 | import java.util.ArrayList; |
| 6 | +import net.authorize.Environment; |
| 7 | +import net.authorize.Merchant; |
6 | 8 |
|
7 | 9 | import net.authorize.ResponseField; |
8 | 10 | import net.authorize.Transaction; |
@@ -881,30 +883,42 @@ private MyReturnValuesTest createCustomerProfileWithAuthOnly( |
881 | 883 | @SuppressWarnings("unchecked") |
882 | 884 | @Test |
883 | 885 | public void testZeroCustomerProfile() { |
| 886 | + |
| 887 | + // Merchent credientials with zero CIM profiles (should be different from the credentials used for other tests) |
| 888 | + // warn: all customer profiles will be deleated for this account for testing purpose |
| 889 | + String zeroCIMApiLoginID = "ZERO_CIM_API_LOGIN_ID"; |
| 890 | + String zeroCIMTransactionKey = "ZERO_CIM_TRANSACTION_KEY"; |
| 891 | + Merchant zeroCIMMerchant = Merchant.createMerchant( Environment.SANDBOX, zeroCIMApiLoginID, zeroCIMTransactionKey); |
| 892 | + |
884 | 893 | // get all existing customer profile ids |
885 | | - net.authorize.cim.Transaction transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS); |
886 | | - Result<Transaction> result = (Result<Transaction>) merchant.postTransaction(transaction); |
| 894 | + net.authorize.cim.Transaction transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS); |
| 895 | + Result<Transaction> result = (Result<Transaction>) zeroCIMMerchant.postTransaction(transaction); |
887 | 896 | ArrayList<String> customerProfileIds = result.getCustomerProfileIdList(); |
888 | 897 |
|
889 | 898 | // delete all existing customer profile |
890 | 899 | for (int i = 0; i < customerProfileIds.size(); i++) { |
891 | | - transaction = merchant.createCIMTransaction(TransactionType.DELETE_CUSTOMER_PROFILE); |
| 900 | + transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.DELETE_CUSTOMER_PROFILE); |
892 | 901 | transaction.setCustomerProfileId(customerProfileIds.get(i)); |
893 | | - result = (Result<Transaction>) merchant.postTransaction(transaction); |
| 902 | + result = (Result<Transaction>) zeroCIMMerchant.postTransaction(transaction); |
894 | 903 | } |
895 | 904 |
|
896 | 905 | // test for getCustomerProfileIds request |
897 | | - transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS); |
898 | | - result = (Result<Transaction>) merchant.postTransaction(transaction); |
| 906 | + transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS); |
| 907 | + result = (Result<Transaction>) zeroCIMMerchant.postTransaction(transaction); |
899 | 908 | Assert.assertNotNull(result); |
900 | 909 | result.printMessages(); |
901 | 910 | Assert.assertTrue(result.isOk()); |
902 | 911 | Assert.assertTrue(result.getCustomerProfileIdList().isEmpty()); |
903 | 912 |
|
904 | 913 | // test for getCustomerProfile request |
905 | | - transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE); |
906 | | - transaction.setCustomerProfileId(customerProfileIds.get(customerProfileIds.size() - 1)); |
907 | | - result = (Result<Transaction>) merchant.postTransaction(transaction); |
| 914 | + transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE); |
| 915 | + if(customerProfileIds.size() > 0){ |
| 916 | + transaction.setCustomerProfileId(customerProfileIds.get(0)); |
| 917 | + } |
| 918 | + else{ |
| 919 | + transaction.setCustomerProfileId("1001"); |
| 920 | + } |
| 921 | + result = (Result<Transaction>) zeroCIMMerchant.postTransaction(transaction); |
908 | 922 | Assert.assertNotNull(result); |
909 | 923 | result.printMessages(); |
910 | 924 | Assert.assertTrue(result.isError()); |
|
0 commit comments