Details
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
index b90caf0..9139a3e 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
@@ -21,7 +21,6 @@ import java.util.List;
import java.util.UUID;
import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
import org.joda.time.Interval;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
@@ -44,56 +43,67 @@ import static org.testng.Assert.assertTrue;
@Guice(modules = {BeatrixModule.class})
public class TestIntegration extends TestIntegrationBase {
- @Test(groups = "slow", enabled = true)
+ @Test(groups = "slow")
public void testBasePlanCompleteWithBillingDayInPast() throws Exception {
log.info("Starting testBasePlanCompleteWithBillingDayInPast");
final DateTime startDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
testBasePlanComplete(startDate, 31, false);
}
- @Test(groups = "slow", enabled = true)
+ @Test(groups = "slow")
public void testBasePlanCompleteWithBillingDayPresent() throws Exception {
log.info("Starting testBasePlanCompleteWithBillingDayPresent");
final DateTime startDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
testBasePlanComplete(startDate, 1, false);
}
- @Test(groups = "slow", enabled = true)
+ @Test(groups = "slow")
public void testBasePlanCompleteWithBillingDayAlignedWithTrial() throws Exception {
log.info("Starting testBasePlanCompleteWithBillingDayAlignedWithTrial");
final DateTime startDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
testBasePlanComplete(startDate, 2, false);
}
- @Test(groups = "slow", enabled = true)
+ @Test(groups = "slow")
public void testBasePlanCompleteWithBillingDayInFuture() throws Exception {
log.info("Starting testBasePlanCompleteWithBillingDayInFuture");
final DateTime startDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
testBasePlanComplete(startDate, 3, true);
}
- @Test(groups = {"slow", "stress"}, enabled = false)
+ @Test(groups = {"stress"})
public void stressTest() throws Exception {
- final int maxIterations = 7;
+ final int maxIterations = 100;
for (int curIteration = 0; curIteration < maxIterations; curIteration++) {
+ if (curIteration != 0) {
+ setupTest();
+ }
+
log.info("################################ ITERATION " + curIteration + " #########################");
Thread.sleep(1000);
- setupTest();
testBasePlanCompleteWithBillingDayPresent();
Thread.sleep(1000);
+ cleanupTest();
setupTest();
testBasePlanCompleteWithBillingDayInPast();
Thread.sleep(1000);
+ cleanupTest();
setupTest();
testBasePlanCompleteWithBillingDayAlignedWithTrial();
Thread.sleep(1000);
+ cleanupTest();
setupTest();
testBasePlanCompleteWithBillingDayInFuture();
+ if (curIteration < maxIterations - 1) {
+ cleanupTest();
+ Thread.sleep(1000);
+ }
+
}
}
- @Test(groups = {"stress"}, enabled = true)
+ @Test(groups = {"stress"})
public void stressTestDebug() throws Exception {
final int maxIterations = 100;
for (int curIteration = 0; curIteration < maxIterations; curIteration++) {
@@ -110,7 +120,7 @@ public class TestIntegration extends TestIntegrationBase {
}
- @Test(groups = "slow", enabled = true)
+ @Test(groups = "slow")
public void testAddonsWithMultipleAlignments() throws Exception {
log.info("Starting testRepairChangeBPWithAddonIncluded");
@@ -226,7 +236,7 @@ public class TestIntegration extends TestIntegrationBase {
// TODO: Jeff implement repair
}
- @Test(groups = "slow", enabled = true)
+ @Test(groups = "slow")
public void testWithRecreatePlan() throws Exception {
log.info("Starting testWithRecreatePlan");
diff --git a/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java b/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
index 92c4544..a7768c2 100644
--- a/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
+++ b/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
@@ -42,8 +42,6 @@ import com.ning.billing.payment.api.DefaultRefund;
import com.ning.billing.payment.api.PaymentApiException;
import com.ning.billing.payment.api.PaymentStatus;
import com.ning.billing.payment.api.Refund;
-import com.ning.billing.payment.core.ProcessorBase.WithAccountLock;
-import com.ning.billing.payment.core.ProcessorBase.WithAccountLockCallback;
import com.ning.billing.payment.dao.PaymentAttemptModelDao;
import com.ning.billing.payment.dao.PaymentDao;
import com.ning.billing.payment.dao.RefundModelDao;
@@ -91,7 +89,6 @@ public class RefundProcessor extends ProcessorBase {
public Refund doOperation() throws PaymentApiException {
try {
-
final PaymentAttemptModelDao successfulAttempt = getPaymentAttempt(paymentId);
if (successfulAttempt == null) {
throw new PaymentApiException(ErrorCode.PAYMENT_NO_SUCH_SUCCESS_PAYMENT, paymentId);
@@ -130,7 +127,7 @@ public class RefundProcessor extends ProcessorBase {
}
paymentDao.updateRefundStatus(refundInfo.getId(), RefundStatus.PLUGIN_COMPLETED, context);
- invoicePaymentApi.createRefund(successfulAttempt.getId(), refundAmount, isAdjusted, refundInfo.getId(), context);
+ invoicePaymentApi.createRefund(paymentId, refundAmount, isAdjusted, refundInfo.getId(), context);
paymentDao.updateRefundStatus(refundInfo.getId(), RefundStatus.COMPLETED, context);
@@ -223,11 +220,8 @@ public class RefundProcessor extends ProcessorBase {
try {
final CallContext context = factory.createCallContext("RefundProcessor", CallOrigin.INTERNAL, UserType.SYSTEM);
for (RefundModelDao cur : refundsToBeFixed) {
- final PaymentAttemptModelDao successfulAttempt = getPaymentAttempt(cur.getPaymentId());
- if (successfulAttempt != null) {
- invoicePaymentApi.createRefund(successfulAttempt.getId(), cur.getAmount(), cur.isAdjsuted(), cur.getId(), context);
- paymentDao.updateRefundStatus(cur.getId(), RefundStatus.COMPLETED, context);
- }
+ invoicePaymentApi.createRefund(cur.getPaymentId(), cur.getAmount(), cur.isAdjsuted(), cur.getId(), context);
+ paymentDao.updateRefundStatus(cur.getId(), RefundStatus.COMPLETED, context);
}
} catch (InvoiceApiException e) {
throw new PaymentApiException(e);
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java b/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
index 54ecd11..6ccdce6 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestAccount.java
@@ -298,13 +298,17 @@ public class TestAccount extends TestJaxrsBase {
@Test(groups = "slow", enabled = true)
public void testCustomFields() throws Exception {
+
+ final AccountJson accountJson = createAccount("yoyoq", "gfgrqe", "yoyoq@yahoo.com");
+ assertNotNull(accountJson);
+
final List<CustomFieldJson> customFields = new LinkedList<CustomFieldJson>();
customFields.add(new CustomFieldJson("1", "value1"));
customFields.add(new CustomFieldJson("2", "value2"));
customFields.add(new CustomFieldJson("3", "value3"));
final String baseJson = mapper.writeValueAsString(customFields);
- final String uri = JaxrsResource.ACCOUNTS_PATH + "/" + UUID.randomUUID().toString() + "/" + JaxrsResource.CUSTOM_FIELDS;
+ final String uri = JaxrsResource.ACCOUNTS_PATH + "/" + accountJson.getAccountId() + "/" + JaxrsResource.CUSTOM_FIELDS;
Response response = doPost(uri, baseJson, DEFAULT_EMPTY_QUERY, DEFAULT_HTTP_TIMEOUT_SEC);
assertEquals(response.getStatusCode(), Status.CREATED.getStatusCode());
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestChargeback.java b/server/src/test/java/com/ning/billing/jaxrs/TestChargeback.java
index 9dc8d51..34cf968 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestChargeback.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestChargeback.java
@@ -47,7 +47,7 @@ import static org.testng.Assert.assertTrue;
public class TestChargeback extends TestJaxrsBase {
@Test(groups = "slow")
public void testAddChargeback() throws Exception {
- final PaymentJsonSimple payment = createInvoicePayment();
+ final PaymentJsonSimple payment = createAccountWithInvoiceAndPayment();
final ChargebackJson input = new ChargebackJson(null, null, BigDecimal.TEN, payment.getPaymentId(), null);
final String jsonInput = mapper.writeValueAsString(input);
@@ -124,12 +124,12 @@ public class TestChargeback extends TestJaxrsBase {
//assertEquals(response.getStatusCode(), javax.ws.rs.core.Response.Status.NO_CONTENT.getStatusCode(), response.getResponseBody());
}
- private PaymentJsonSimple createInvoicePayment() throws Exception {
- final InvoiceJsonSimple invoice = createInvoice();
+ private PaymentJsonSimple createAccountWithInvoiceAndPayment() throws Exception {
+ final InvoiceJsonSimple invoice = createAccountWithInvoice();
return getPayment(invoice);
}
- private InvoiceJsonSimple createInvoice() throws Exception {
+ private InvoiceJsonSimple createAccountWithInvoice() throws Exception {
// Create account
final AccountJson accountJson = createAccountWithDefaultPaymentMethod(UUID.randomUUID().toString(), UUID.randomUUID().toString(), "nohup@yahoo.com");
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestInvoice.java b/server/src/test/java/com/ning/billing/jaxrs/TestInvoice.java
index 36f7b53..3d93c6d 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestInvoice.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestInvoice.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2010-2011 Ning, Inc.
*
* Ning licenses this file to you under the Apache License, version 2.0
@@ -51,7 +51,7 @@ public class TestInvoice extends TestJaxrsBase {
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
- final AccountJson accountJson = createAccount("poupou", "qhddffrwe", "poupou@yahoo.com");
+ final AccountJson accountJson = createAccountWithDefaultPaymentMethod("poupou", "qhddffrwe", "poupou@yahoo.com");
assertNotNull(accountJson);
final BundleJsonNoSubscriptions bundleJson = createBundle(accountJson.getAccountId(), "9967599");
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestInvoiceNotification.java b/server/src/test/java/com/ning/billing/jaxrs/TestInvoiceNotification.java
index 370ce77..d1aa37f 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestInvoiceNotification.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestInvoiceNotification.java
@@ -56,7 +56,7 @@ public class TestInvoiceNotification extends TestJaxrsBase {
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
- final AccountJson accountJson = createAccount(UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
+ final AccountJson accountJson = createAccountWithDefaultPaymentMethod(UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
Assert.assertNotNull(accountJson);
final BundleJsonNoSubscriptions bundleJson = createBundle(accountJson.getAccountId(), UUID.randomUUID().toString());
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestSubscription.java b/server/src/test/java/com/ning/billing/jaxrs/TestSubscription.java
index 4997c96..9e2d92f 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestSubscription.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestSubscription.java
@@ -52,7 +52,7 @@ public class TestSubscription extends TestJaxrsBase {
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
- final AccountJson accountJson = createAccount("xil", "shdxilhkkl", "xil@yahoo.com");
+ final AccountJson accountJson = createAccountWithDefaultPaymentMethod("xil", "shdxilhkkl", "xil@yahoo.com");
final BundleJsonNoSubscriptions bundleJson = createBundle(accountJson.getAccountId(), "99999");
final String productName = "Shotgun";
@@ -60,7 +60,7 @@ public class TestSubscription extends TestJaxrsBase {
final SubscriptionJsonNoEvents subscriptionJson = createSubscription(bundleJson.getBundleId(), productName, ProductCategory.BASE.toString(), term.toString(), true);
Assert.assertNotNull(subscriptionJson.getChargedThroughDate());
- Assert.assertEquals(subscriptionJson.getChargedThroughDate(), subscriptionJson.getStartDate().plusDays(30));
+ Assert.assertEquals(subscriptionJson.getChargedThroughDate().toString(), "2012-05-25T00:00:00.000Z");
String uri = JaxrsResource.SUBSCRIPTIONS_PATH + "/" + subscriptionJson.getSubscriptionId().toString();