Skip to content

Commit 5137d87

Browse files
committed
Merge pull request #58 from kikmak42/master
Zero CIM Test Added
2 parents 22a663f + f3054af commit 5137d87

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

src/test/java/net/authorize/cim/functional_test/CIMTest.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import static org.junit.Assert.fail;
44

55
import java.util.ArrayList;
6+
import net.authorize.Environment;
7+
import net.authorize.Merchant;
68

79
import net.authorize.ResponseField;
810
import net.authorize.Transaction;
@@ -881,30 +883,42 @@ private MyReturnValuesTest createCustomerProfileWithAuthOnly(
881883
@SuppressWarnings("unchecked")
882884
@Test
883885
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+
884893
// 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);
887896
ArrayList<String> customerProfileIds = result.getCustomerProfileIdList();
888897

889898
// delete all existing customer profile
890899
for (int i = 0; i < customerProfileIds.size(); i++) {
891-
transaction = merchant.createCIMTransaction(TransactionType.DELETE_CUSTOMER_PROFILE);
900+
transaction = zeroCIMMerchant.createCIMTransaction(TransactionType.DELETE_CUSTOMER_PROFILE);
892901
transaction.setCustomerProfileId(customerProfileIds.get(i));
893-
result = (Result<Transaction>) merchant.postTransaction(transaction);
902+
result = (Result<Transaction>) zeroCIMMerchant.postTransaction(transaction);
894903
}
895904

896905
// 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);
899908
Assert.assertNotNull(result);
900909
result.printMessages();
901910
Assert.assertTrue(result.isOk());
902911
Assert.assertTrue(result.getCustomerProfileIdList().isEmpty());
903912

904913
// 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);
908922
Assert.assertNotNull(result);
909923
result.printMessages();
910924
Assert.assertTrue(result.isError());

0 commit comments

Comments
 (0)