killbill-memoizeit

Fix minor API Kill Bill weirness that were highlighted when

6/19/2013 7:25:11 PM

Details

diff --git a/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java b/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
index 40f09f4..3553f4b 100644
--- a/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
+++ b/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
@@ -416,6 +416,6 @@ public class DefaultAccount extends EntityBase implements Account {
 
     @Override
     public BlockingState getBlockingState() {
-        throw new UnsupportedOperationException();
+        return null;
     }
 }
diff --git a/api/src/main/java/com/ning/billing/payment/api/PaymentMethodPlugin.java b/api/src/main/java/com/ning/billing/payment/api/PaymentMethodPlugin.java
index af52dd3..5085b50 100644
--- a/api/src/main/java/com/ning/billing/payment/api/PaymentMethodPlugin.java
+++ b/api/src/main/java/com/ning/billing/payment/api/PaymentMethodPlugin.java
@@ -41,13 +41,6 @@ public interface PaymentMethodPlugin {
 
     /**
      *
-     * @param key the key for which to get the value
-     * @return the value associated with the key
-     */
-    public String getValueString(String key);
-
-    /**
-     *
      * @return the payment method type name if applicable
      */
     public String getType();
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
index d95f497..20396bc 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestJrubyPaymentPlugin.java
@@ -40,6 +40,8 @@ import com.ning.billing.payment.plugin.api.PaymentPluginApi;
 import com.ning.billing.payment.plugin.api.RefundInfoPlugin;
 import com.ning.billing.payment.plugin.api.RefundPluginStatus;
 
+import static org.testng.Assert.assertEquals;
+
 public class TestJrubyPaymentPlugin extends TestOSGIBase {
 
     private final String BUNDLE_TEST_RESOURCE_PREFIX = "killbill-payment-test";
@@ -50,7 +52,7 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
     @Inject
     private OSGIServiceRegistration<PaymentPluginApi> paymentPluginApiOSGIServiceRegistration;
 
-    @BeforeClass(groups = "slow", enabled = true)
+    @BeforeClass(groups = "slow")
     public void beforeClass() throws Exception {
 
 
@@ -84,10 +86,10 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
         Assert.assertTrue(res.getEffectiveDate().compareTo(beforeCall) >= 0);
         Assert.assertTrue(res.getEffectiveDate().compareTo(afterCall) <= 0);
 
-        Assert.assertEquals(res.getGatewayError(), "gateway_error");
-        Assert.assertEquals(res.getGatewayErrorCode(), "gateway_error_code");
+        assertEquals(res.getGatewayError(), "gateway_error");
+        assertEquals(res.getGatewayErrorCode(), "gateway_error_code");
 
-        Assert.assertEquals(res.getStatus(), PaymentPluginStatus.PROCESSED);
+        assertEquals(res.getStatus(), PaymentPluginStatus.PROCESSED);
     }
 
     @Test(groups = "slow", enabled = true)
@@ -107,10 +109,10 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
         Assert.assertTrue(res.getEffectiveDate().compareTo(beforeCall) >= 0);
         Assert.assertTrue(res.getEffectiveDate().compareTo(afterCall) <= 0);
 
-        Assert.assertEquals(res.getGatewayError(), "gateway_error");
-        Assert.assertEquals(res.getGatewayErrorCode(), "gateway_error_code");
+        assertEquals(res.getGatewayError(), "gateway_error");
+        assertEquals(res.getGatewayErrorCode(), "gateway_error_code");
 
-        Assert.assertEquals(res.getStatus(), PaymentPluginStatus.PROCESSED);
+        assertEquals(res.getStatus(), PaymentPluginStatus.PROCESSED);
     }
 
 
@@ -131,10 +133,10 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
         Assert.assertTrue(res.getEffectiveDate().compareTo(beforeCall) >= 0);
         Assert.assertTrue(res.getEffectiveDate().compareTo(afterCall) <= 0);
 
-        Assert.assertEquals(res.getGatewayError(), "gateway_error");
-        Assert.assertEquals(res.getGatewayErrorCode(), "gateway_error_code");
+        assertEquals(res.getGatewayError(), "gateway_error");
+        assertEquals(res.getGatewayErrorCode(), "gateway_error_code");
 
-        Assert.assertEquals(res.getStatus(), RefundPluginStatus.PROCESSED);
+        assertEquals(res.getStatus(), RefundPluginStatus.PROCESSED);
     }
 
     @Test(groups = "slow", enabled = true)
@@ -162,9 +164,13 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
         PaymentPluginApi api = getTestPluginPaymentApi();
         final PaymentMethodPlugin res = api.getPaymentMethodDetail(UUID.randomUUID(), UUID.randomUUID(), callContext);
 
-        Assert.assertEquals(res.getExternalPaymentMethodId(), "foo");
+        assertEquals(res.getExternalPaymentMethodId(), "external_payment_method_id");
         Assert.assertTrue(res.isDefaultPaymentMethod());
-        Assert.assertEquals(res.getProperties().size(), 0);
+        assertEquals(res.getProperties().size(), 2);
+        assertEquals(res.getProperties().get(0).getKey(), "key1");
+        assertEquals(res.getProperties().get(0).getValue(), "value1");
+        assertEquals(res.getProperties().get(1).getKey(), "key2");
+        assertEquals(res.getProperties().get(1).getValue(), "value2");
     }
 
     @Test(groups = "slow", enabled = true)
@@ -179,13 +185,16 @@ public class TestJrubyPaymentPlugin extends TestOSGIBase {
     public void testGetPaymentMethods() throws Exception {
 
         PaymentPluginApi api = getTestPluginPaymentApi();
-        final List<PaymentMethodInfoPlugin> res = api.getPaymentMethods(UUID.randomUUID(), true, callContext);
+        final UUID kbAccountId = UUID.randomUUID();
+        final List<PaymentMethodInfoPlugin> res = api.getPaymentMethods(kbAccountId, true, callContext);
 
-        Assert.assertEquals(res.size(), 1);
+        assertEquals(res.size(), 1);
 
         final PaymentMethodInfoPlugin res0 = res.get(0);
         Assert.assertTrue(res0.isDefault());
-        Assert.assertEquals(res0.getExternalPaymentMethodId(), "external_payment_method_id");
+        assertEquals(res0.getExternalPaymentMethodId(), "external_payment_method_id");
+        assertEquals(res0.getAccountId(), kbAccountId);
+        assertEquals(res0.getPaymentMethodId(), kbAccountId);
     }
 
 
diff --git a/beatrix/src/test/resources/killbill-notification-test.tar.gz b/beatrix/src/test/resources/killbill-notification-test.tar.gz
index 4ac6e1b..61a8162 100644
Binary files a/beatrix/src/test/resources/killbill-notification-test.tar.gz and b/beatrix/src/test/resources/killbill-notification-test.tar.gz differ
diff --git a/beatrix/src/test/resources/killbill-payment-test.tar.gz b/beatrix/src/test/resources/killbill-payment-test.tar.gz
index 6d5f91a..b3b12fe 100644
Binary files a/beatrix/src/test/resources/killbill-payment-test.tar.gz and b/beatrix/src/test/resources/killbill-payment-test.tar.gz differ
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentMethodJson.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentMethodJson.java
index eac7785..ebc4c8a 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentMethodJson.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/PaymentMethodJson.java
@@ -129,12 +129,6 @@ public class PaymentMethodJson {
                     }
 
                     @Override
-                    public String getValueString(final String key) {
-                        // N/A
-                        return null;
-                    }
-
-                    @Override
                     public String getType() {
                         // N/A
                         return null;
diff --git a/osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyActivator.java b/osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyActivator.java
index 8746b18..6cf5652 100644
--- a/osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyActivator.java
+++ b/osgi-bundles/bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyActivator.java
@@ -172,20 +172,12 @@ public class JRubyActivator extends KillbillActivatorBase {
         // See killbill/plugin.rb for the naming convention magic
         killbillUserApis.put("account_user_api", killbillAPI.getAccountUserApi());
         killbillUserApis.put("catalog_user_api", killbillAPI.getCatalogUserApi());
-        killbillUserApis.put("entitlement_migration_api", killbillAPI.getEntitlementMigrationApi());
-        killbillUserApis.put("entitlement_timeline_api", killbillAPI.getEntitlementTimelineApi());
-        killbillUserApis.put("entitlement_transfer_api", killbillAPI.getEntitlementTransferApi());
         killbillUserApis.put("entitlement_user_api", killbillAPI.getEntitlementUserApi());
-        killbillUserApis.put("invoice_migration_api", killbillAPI.getInvoiceMigrationApi());
         killbillUserApis.put("invoice_payment_api", killbillAPI.getInvoicePaymentApi());
         killbillUserApis.put("invoice_user_api", killbillAPI.getInvoiceUserApi());
         killbillUserApis.put("overdue_user_api", killbillAPI.getOverdueUserApi());
         killbillUserApis.put("payment_api", killbillAPI.getPaymentApi());
-        killbillUserApis.put("tenant_user_api", killbillAPI.getTenantUserApi());
-        killbillUserApis.put("usage_user_api", killbillAPI.getUsageUserApi());
-        killbillUserApis.put("audit_user_api", killbillAPI.getAuditUserApi());
         killbillUserApis.put("custom_field_user_api", killbillAPI.getCustomFieldUserApi());
-        killbillUserApis.put("export_user_api", killbillAPI.getExportUserApi());
         killbillUserApis.put("tag_user_api", killbillAPI.getTagUserApi());
         return killbillUserApis;
     }
diff --git a/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java b/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java
index bc7120d..89fc2d1 100644
--- a/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java
+++ b/payment/src/main/java/com/ning/billing/payment/provider/DefaultNoOpPaymentMethodPlugin.java
@@ -61,21 +61,6 @@ public class DefaultNoOpPaymentMethodPlugin implements PaymentMethodPlugin {
     }
 
     @Override
-    public String getValueString(final String key) {
-        if (props == null) {
-            return null;
-        }
-
-        for (final PaymentMethodKVInfo cur : props) {
-            if (cur.getKey().equals(key)) {
-                return cur.getValue().toString();
-            }
-        }
-
-        return null;
-    }
-
-    @Override
     public String getType() {
         return "noop";
     }
diff --git a/payment/src/test/java/com/ning/billing/payment/api/TestPaymentMethodPlugin.java b/payment/src/test/java/com/ning/billing/payment/api/TestPaymentMethodPlugin.java
index 288d691..d0ae14b 100644
--- a/payment/src/test/java/com/ning/billing/payment/api/TestPaymentMethodPlugin.java
+++ b/payment/src/test/java/com/ning/billing/payment/api/TestPaymentMethodPlugin.java
@@ -45,13 +45,4 @@ public class TestPaymentMethodPlugin extends TestPaymentMethodPluginBase impleme
         return properties;
     }
 
-    @Override
-    public String getValueString(final String key) {
-        for (PaymentMethodKVInfo cur : properties) {
-            if (cur.getKey().equals(key)) {
-                return cur.getValue() != null ? cur.getValue().toString() : null;
-            }
-        }
-        return null;
-    }
 }
diff --git a/util/src/test/java/com/ning/billing/payment/api/TestPaymentMethodPluginBase.java b/util/src/test/java/com/ning/billing/payment/api/TestPaymentMethodPluginBase.java
index 4dcee8b..118303b 100644
--- a/util/src/test/java/com/ning/billing/payment/api/TestPaymentMethodPluginBase.java
+++ b/util/src/test/java/com/ning/billing/payment/api/TestPaymentMethodPluginBase.java
@@ -34,11 +34,6 @@ public class TestPaymentMethodPluginBase implements PaymentMethodPlugin {
     }
 
     @Override
-    public String getValueString(final String key) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public String getType() {
         return "CreditCard";
     }