diff --git a/src/test/java/net/authorize/cim/functional_test/CIMTest.java b/src/test/java/net/authorize/cim/functional_test/CIMTest.java index 21dfb297..43e223fa 100644 --- a/src/test/java/net/authorize/cim/functional_test/CIMTest.java +++ b/src/test/java/net/authorize/cim/functional_test/CIMTest.java @@ -3,6 +3,8 @@ import static org.junit.Assert.fail; import java.util.ArrayList; +import net.authorize.Environment; +import net.authorize.Merchant; import net.authorize.ResponseField; import net.authorize.Transaction; @@ -880,30 +882,42 @@ private MyReturnValuesTest createCustomerProfileWithAuthOnly( @SuppressWarnings("unchecked") @Test public void testZeroCustomerProfile() { + + // Merchent credientials with zero CIM profiles (should be different from the credentials used for other tests) + // warn: all customer profiles will be deleated for this account for testing purpose + String zeroCIMApiLoginID = "ZERO_CIM_API_LOGIN_ID"; + String zeroCIMTransactionKey = "ZERO_CIM_TRANSACTION_KEY"; + Merchant zeroCIMMerchant = Merchant.createMerchant( Environment.SANDBOX, zeroCIMApiLoginID, zeroCIMTransactionKey); + // get all existing customer profile ids - net.authorize.cim.Transaction transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS); - Result result = (Result) merchant.postTransaction(transaction); + net.authorize.cim.Transaction transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS); + Result result = (Result) zeroCIMMerchant.postTransaction(transaction); ArrayList customerProfileIds = result.getCustomerProfileIdList(); // delete all existing customer profile for (int i = 0; i < customerProfileIds.size(); i++) { - transaction = merchant.createCIMTransaction(TransactionType.DELETE_CUSTOMER_PROFILE); + transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.DELETE_CUSTOMER_PROFILE); transaction.setCustomerProfileId(customerProfileIds.get(i)); - result = (Result) merchant.postTransaction(transaction); + result = (Result) zeroCIMMerchant.postTransaction(transaction); } // test for getCustomerProfileIds request - transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS); - result = (Result) merchant.postTransaction(transaction); + transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS); + result = (Result) zeroCIMMerchant.postTransaction(transaction); Assert.assertNotNull(result); result.printMessages(); Assert.assertTrue(result.isOk()); Assert.assertTrue(result.getCustomerProfileIdList().isEmpty()); // test for getCustomerProfile request - transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE); - transaction.setCustomerProfileId(customerProfileIds.get(customerProfileIds.size() - 1)); - result = (Result) merchant.postTransaction(transaction); + transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE); + if(customerProfileIds.size() > 0){ + transaction.setCustomerProfileId(customerProfileIds.get(0)); + } + else{ + transaction.setCustomerProfileId("1001"); + } + result = (Result) zeroCIMMerchant.postTransaction(transaction); Assert.assertNotNull(result); result.printMessages(); Assert.assertTrue(result.isError());