killbill-uncached

Details

bin/db-helper 15(+13 -2)

diff --git a/bin/db-helper b/bin/db-helper
index 4f5130c..c642b1c 100755
--- a/bin/db-helper
+++ b/bin/db-helper
@@ -43,6 +43,17 @@ CLEAN_FILE=
 # Egrep like for skipping some modules until they are ready
 SKIP="(server)"
 
+
+# test if user is running gnu-getopt
+TEST=`getopt -o "a:" -l "action:" -- --action dump`
+if [ "$TEST" != " --action 'dump' --" ]; then
+    echo "You are not using gnu-getopt or latest getopt."
+    echo "For Mac OS X, please upgrade 'getopt' to 'gnu-getopt',"
+    echo "For Linux, please upgrade 'getopt'."
+    exit
+fi
+
+
 ARGS=`getopt -o "a:d:h:u:p:t:f:" -l "action:,driver:,database:,host:,user:,password:,test:,file:,port:,help" -n "db-helper" -- "$@"`
 eval set -- "${ARGS}"
 
@@ -99,7 +110,7 @@ function create_clean_file() {
     local tables=`cat $ddl_file | grep -i "create table" | awk ' { print $3 } '`
 
     local tmp="/tmp/clean-$DATABASE.$$"
-    echo "/*! use $DATABASE; */" >> $tmp
+    echo "/*! USE $DATABASE */;" >> $tmp
     echo "" >> $tmp
     for t in $tables; do
         echo "truncate $t;" >> $tmp
@@ -121,7 +132,7 @@ function create_ddl_file() {
     if [ $DRIVER == "postgres" ]; then
         cat util/src/main/resources/org/killbill/billing/util/ddl-postgresql.sql > $tmp
     fi
-    echo "/*! use $DATABASE; */" >> $tmp
+    echo "/*! USE $DATABASE */;" >> $tmp
     echo "" >> $tmp
     for d in $ddls; do
         cat $d >> $tmp
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/ComboPaymentResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/ComboPaymentResource.java
index a372150..e308641 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/ComboPaymentResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/ComboPaymentResource.java
@@ -23,6 +23,7 @@ import java.util.UUID;
 import javax.annotation.Nullable;
 import javax.inject.Inject;
 
+import org.killbill.billing.ErrorCode;
 import org.killbill.billing.account.api.Account;
 import org.killbill.billing.account.api.AccountApiException;
 import org.killbill.billing.account.api.AccountUserApi;
@@ -93,6 +94,7 @@ public abstract class ComboPaymentResource extends JaxRsResourceBase {
             })) {
                 return match;
             }
+            throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_PAYMENT_METHOD, match);
         }
 
         // If we were specified a paymentMethod externalKey and we find it, we return it
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestPayment.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestPayment.java
index 1cfdb15..22a5996 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestPayment.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestPayment.java
@@ -193,6 +193,24 @@ public class TestPayment extends TestJaxrsBase {
                                  voidTransactionExternalKey, null, "VOID", "SUCCESS");
     }
 
+    @Test(groups = "slow")
+    public void testComboAuthorizationInvalidPaymentMethod() throws Exception {
+        final Account accountJson = getAccount();
+        accountJson.setAccountId(null);
+
+        final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
+        info.setProperties(null);
+
+        final UUID paymentMethodId = UUID.randomUUID();
+        final PaymentMethod paymentMethodJson = new PaymentMethod(paymentMethodId, null, null, true, PLUGIN_NAME, info);
+
+        final ComboPaymentTransaction comboPaymentTransaction = new ComboPaymentTransaction(accountJson, paymentMethodJson, null, ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of());
+
+        final Payment payment = killBillClient.createPayment(comboPaymentTransaction, ImmutableMap.<String, String>of(), createdBy, reason, comment);
+        // Client returns null in case of a 404
+        Assert.assertNull(payment);
+    }
+
     private void testCreateRetrievePayment(final Account account, @Nullable final UUID paymentMethodId,
                                            final String paymentExternalKey, final int paymentNb) throws Exception {
         // Authorization