Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions src/test/java/net/authorize/cim/functional_test/CIMTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Transaction> result = (Result<Transaction>) merchant.postTransaction(transaction);
net.authorize.cim.Transaction transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS);
Result<Transaction> result = (Result<Transaction>) zeroCIMMerchant.postTransaction(transaction);
ArrayList<String> 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<Transaction>) merchant.postTransaction(transaction);
result = (Result<Transaction>) zeroCIMMerchant.postTransaction(transaction);
}

// test for getCustomerProfileIds request
transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS);
result = (Result<Transaction>) merchant.postTransaction(transaction);
transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE_IDS);
result = (Result<Transaction>) 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<Transaction>) 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<Transaction>) zeroCIMMerchant.postTransaction(transaction);
Assert.assertNotNull(result);
result.printMessages();
Assert.assertTrue(result.isError());
Expand Down