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