killbill-aplcache

Minor change to payment api tests

2/7/2012 4:38:52 AM

Details

diff --git a/payment/src/main/java/com/ning/billing/payment/PaymentAttempt.java b/payment/src/main/java/com/ning/billing/payment/PaymentAttempt.java
index 353587d..aa0ccc5 100644
--- a/payment/src/main/java/com/ning/billing/payment/PaymentAttempt.java
+++ b/payment/src/main/java/com/ning/billing/payment/PaymentAttempt.java
@@ -59,9 +59,9 @@ public class PaymentAttempt {
             return paymentAttemptDate;
     }
 
-    @Override
-    public String toString() {
-        return "PaymentAttempt [paymentAttemptId=" + paymentAttemptId + ", accountId=" + accountId + ", invoiceId=" + invoiceId + ", paymentAttemptAmount=" + paymentAttemptAmount + "]";
-    }
+        @Override
+        public String toString() {
+            return "PaymentAttempt [paymentAttemptId=" + paymentAttemptId + ", accountId=" + accountId + ", invoiceId=" + invoiceId + ", paymentAttemptAmount=" + paymentAttemptAmount + ", paymentAttemptDate=" + paymentAttemptDate + "]";
+        }
 
 }
diff --git a/payment/src/test/java/com/ning/billing/payment/api/TestPaymentApi.java b/payment/src/test/java/com/ning/billing/payment/api/TestPaymentApi.java
index 748a447..896ffcc 100644
--- a/payment/src/test/java/com/ning/billing/payment/api/TestPaymentApi.java
+++ b/payment/src/test/java/com/ning/billing/payment/api/TestPaymentApi.java
@@ -62,10 +62,10 @@ public abstract class TestPaymentApi {
         eventBus.stop();
     }
 
-    @Test
-    public void testCreatePayment() throws AccountApiException {
+    @Test(enabled=true)
+    public void testCreateCreditCardPayment() throws AccountApiException {
         final DateTime now = new DateTime(DateTimeZone.UTC);
-        final Account account = testHelper.createTestAccount();
+        final Account account = testHelper.createTestCreditCardAccount();
         final Invoice invoice = testHelper.createTestInvoice(account, now, Currency.USD);
         final BigDecimal amount = new BigDecimal("10.00");
         final UUID subscriptionId = UUID.randomUUID();
@@ -103,7 +103,7 @@ public abstract class TestPaymentApi {
     }
 
     private PaymentProviderAccount setupAccountWithPaymentMethod() throws AccountApiException {
-        final Account account = testHelper.createTestAccount();
+        final Account account = testHelper.createTestPayPalAccount();
         paymentApi.createPaymentProviderAccount(account);
 
         String accountKey = account.getExternalKey();
@@ -130,15 +130,15 @@ public abstract class TestPaymentApi {
         return accountOrError.getRight();
     }
 
-    @Test
+    @Test(enabled=true)
     public void testCreatePaymentMethod() throws AccountApiException {
         PaymentProviderAccount account = setupAccountWithPaymentMethod();
         assertNotNull(account);
     }
 
-    @Test
+    @Test(enabled=true)
     public void testUpdatePaymentProviderAccountContact() throws AccountApiException {
-        final Account account = testHelper.createTestAccount();
+        final Account account = testHelper.createTestPayPalAccount();
         paymentApi.createPaymentProviderAccount(account);
 
         String newName = "Tester " + RandomStringUtils.randomAlphanumeric(10);
@@ -158,7 +158,7 @@ public abstract class TestPaymentApi {
         assertTrue(voidOrError.isRight());
     }
 
-    @Test
+    @Test(enabled=true)
     public void testCannotDeleteDefaultPaymentMethod() throws AccountApiException {
         PaymentProviderAccount account = setupAccountWithPaymentMethod();
 
@@ -167,9 +167,9 @@ public abstract class TestPaymentApi {
         assertTrue(errorOrVoid.isLeft());
     }
 
-    @Test
+    @Test(enabled=true)
     public void testDeleteNonDefaultPaymentMethod() throws AccountApiException {
-        final Account account = testHelper.createTestAccount();
+        final Account account = testHelper.createTestPayPalAccount();
         paymentApi.createPaymentProviderAccount(account);
 
         String accountKey = account.getExternalKey();
diff --git a/payment/src/test/java/com/ning/billing/payment/TestHelper.java b/payment/src/test/java/com/ning/billing/payment/TestHelper.java
index 2a1ce91..0d9789c 100644
--- a/payment/src/test/java/com/ning/billing/payment/TestHelper.java
+++ b/payment/src/test/java/com/ning/billing/payment/TestHelper.java
@@ -45,14 +45,30 @@ public class TestHelper {
         this.invoiceDao = invoiceDao;
     }
 
-    public Account createTestAccount() throws AccountApiException {
+    // These helper methods can be overridden in a plugin implementation
+    public Account createTestCreditCardAccount() throws AccountApiException {
         final String name = "First" + RandomStringUtils.randomAlphanumeric(5) + " " + "Last" + RandomStringUtils.randomAlphanumeric(5);
         final String externalKey = RandomStringUtils.randomAlphanumeric(10);
         final Account account = new AccountBuilder(UUID.randomUUID()).name(name)
                                                                      .firstNameLength(name.length())
                                                                      .externalKey(externalKey)
                                                                      .phone("123-456-7890")
-                                                                     .email("user@example.com")
+                                                                     .email("ccuser@example.com")
+                                                                     .currency(Currency.USD)
+                                                                     .billingCycleDay(1)
+                                                                     .build();
+        accountDao.create(account);
+        return account;
+    }
+
+    public Account createTestPayPalAccount() throws AccountApiException {
+        final String name = "First" + RandomStringUtils.randomAlphanumeric(5) + " " + "Last" + RandomStringUtils.randomAlphanumeric(5);
+        final String externalKey = RandomStringUtils.randomAlphanumeric(10);
+        final Account account = new AccountBuilder(UUID.randomUUID()).name(name)
+                                                                     .firstNameLength(name.length())
+                                                                     .externalKey(externalKey)
+                                                                     .phone("123-456-7890")
+                                                                     .email("ppuser@example.com")
                                                                      .currency(Currency.USD)
                                                                      .billingCycleDay(1)
                                                                      .build();
diff --git a/payment/src/test/java/com/ning/billing/payment/TestNotifyInvoicePaymentApi.java b/payment/src/test/java/com/ning/billing/payment/TestNotifyInvoicePaymentApi.java
index e6d1334..c486c2b 100644
--- a/payment/src/test/java/com/ning/billing/payment/TestNotifyInvoicePaymentApi.java
+++ b/payment/src/test/java/com/ning/billing/payment/TestNotifyInvoicePaymentApi.java
@@ -63,7 +63,7 @@ public class TestNotifyInvoicePaymentApi {
 
     @Test
     public void testNotifyPaymentSuccess() throws AccountApiException {
-        final Account account = testHelper.createTestAccount();
+        final Account account = testHelper.createTestCreditCardAccount();
         final Invoice invoice = testHelper.createTestInvoice(account);
 
         PaymentAttempt paymentAttempt = new PaymentAttempt(UUID.randomUUID(), invoice);
@@ -81,7 +81,7 @@ public class TestNotifyInvoicePaymentApi {
 
     @Test
     public void testNotifyPaymentFailure() throws AccountApiException {
-        final Account account = testHelper.createTestAccount();
+        final Account account = testHelper.createTestCreditCardAccount();
         final Invoice invoice = testHelper.createTestInvoice(account);
 
         PaymentAttempt paymentAttempt = new PaymentAttempt(UUID.randomUUID(), invoice);
diff --git a/payment/src/test/java/com/ning/billing/payment/TestPaymentInvoiceIntegration.java b/payment/src/test/java/com/ning/billing/payment/TestPaymentInvoiceIntegration.java
index 1027abe..4f83f50 100644
--- a/payment/src/test/java/com/ning/billing/payment/TestPaymentInvoiceIntegration.java
+++ b/payment/src/test/java/com/ning/billing/payment/TestPaymentInvoiceIntegration.java
@@ -120,7 +120,7 @@ public class TestPaymentInvoiceIntegration {
 
     @Test
     public void testInvoiceIntegration() throws Exception {
-        final Account account = testHelper.createTestAccount();
+        final Account account = testHelper.createTestCreditCardAccount();
         final Invoice invoice = testHelper.createTestInvoice(account);
 
         await().atMost(1, MINUTES).until(new Callable<Boolean>() {
diff --git a/payment/src/test/java/com/ning/billing/payment/TestPaymentProvider.java b/payment/src/test/java/com/ning/billing/payment/TestPaymentProvider.java
index 9f9720c..3395421 100644
--- a/payment/src/test/java/com/ning/billing/payment/TestPaymentProvider.java
+++ b/payment/src/test/java/com/ning/billing/payment/TestPaymentProvider.java
@@ -69,7 +69,7 @@ public class TestPaymentProvider {
 
     @Test
     public void testSimpleInvoice() throws Exception {
-        final Account account = testHelper.createTestAccount();
+        final Account account = testHelper.createTestCreditCardAccount();
 
         testHelper.createTestInvoice(account);