diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
index 886beb1..fb33ba6 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
@@ -21,9 +21,11 @@ package org.killbill.billing.beatrix.integration;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
import org.joda.time.Interval;
import org.joda.time.LocalDate;
import org.killbill.billing.ErrorCode;
@@ -47,9 +49,12 @@ import org.killbill.billing.invoice.api.DryRunType;
import org.killbill.billing.invoice.api.Invoice;
import org.killbill.billing.invoice.api.InvoiceApiException;
import org.killbill.billing.invoice.api.InvoiceItemType;
+import org.killbill.billing.mock.MockAccountBuilder;
import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.payment.api.TransactionStatus;
import org.killbill.billing.subscription.api.user.DefaultSubscriptionBase;
+import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.tweak.HandleCallback;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -928,4 +933,74 @@ public class TestIntegration extends TestIntegrationBase {
startDateBase = endDateBase;
}
}
+
+
+ @Test(groups = "slow")
+ public void testWithDayLightSaving() throws Exception {
+ clock.setTime(new DateTime("2015-09-01T08:01:01.000Z"));
+
+ final DateTimeZone tz = DateTimeZone.forID("America/Juneau");
+ final AccountData accountData = new MockAccountBuilder().name(UUID.randomUUID().toString().substring(1, 8))
+ .firstNameLength(6)
+ .email(UUID.randomUUID().toString().substring(1, 8))
+ .phone(UUID.randomUUID().toString().substring(1, 8))
+ .migrated(false)
+ .isNotifiedForInvoices(false)
+ .externalKey(UUID.randomUUID().toString().substring(1, 8))
+ .billingCycleDayLocal(1)
+ .currency(Currency.USD)
+ .paymentMethodId(UUID.randomUUID())
+ .referenceTime(clock.getUTCNow())
+ .timeZone(tz)
+ .build();
+ final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
+ accountChecker.checkAccount(account.getId(), accountData, callContext);
+
+ //
+ // CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE, NextEvent.BLOCK NextEvent.INVOICE
+ //
+ final DefaultEntitlement bpSubscription = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.ANNUAL, NextEvent.CREATE, NextEvent.BLOCK, NextEvent.INVOICE);
+ // Check bundle after BP got created otherwise we get an error from auditApi.
+ subscriptionChecker.checkSubscriptionCreated(bpSubscription.getId(), internalCallContext);
+ invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2015, 9, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
+ assertListenerStatus();
+
+ //
+ // ADD ADD_ON ON THE SAME DAY
+ //
+ final DefaultEntitlement aoSubscription = addAOEntitlementAndCheckForCompletion(bpSubscription.getBundleId(), "Bullets", ProductCategory.ADD_ON, BillingPeriod.NO_BILLING_PERIOD, NextEvent.CREATE, NextEvent.BLOCK, NextEvent.NULL_INVOICE);
+ assertListenerStatus();
+
+ busHandler.pushExpectedEvents(NextEvent.PHASE, NextEvent.NULL_INVOICE, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT);
+ clock.addDays(30);
+ assertListenerStatus();
+ invoiceChecker.checkInvoice(account.getId(), 2, callContext,
+ new ExpectedInvoiceItemCheck(new LocalDate(2015, 10, 1), new LocalDate(2016, 10, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
+
+ // 2015-11-1
+ busHandler.pushExpectedEvent(NextEvent.NULL_INVOICE);
+ clock.addMonths(1);
+ assertListenerStatus();
+
+ // 2015-12-1
+ busHandler.pushExpectedEvent(NextEvent.NULL_INVOICE);
+ clock.addMonths(1);
+ assertListenerStatus();
+
+ // We sleep to let system creates lots of notification if an infinite loop was indeed happening
+ Thread.sleep(3000);
+ // And then we check that we only have the expected number of notifications in the history table.
+ final Integer countNotifications = dbi.withHandle(new HandleCallback<Integer>() {
+ @Override
+ public Integer withHandle(final Handle handle) throws Exception {
+
+ List<Map<String, Object>> res = handle.select("select count(*) as count from notifications_history;");
+ final Integer count = Integer.valueOf(res.get(0).get("count").toString());
+ return count;
+ }
+ }
+ );
+ Assert.assertEquals(countNotifications.intValue(), 4);
+ }
+
}
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/usage/TestConsumableInArrear.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/usage/TestConsumableInArrear.java
index b67a99a..2aa28b5 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/usage/TestConsumableInArrear.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/usage/TestConsumableInArrear.java
@@ -174,74 +174,6 @@ public class TestConsumableInArrear extends TestIntegrationBase {
assertListenerStatus();
}
- @Test(groups = "slow")
- public void testWithDayLightSaving() throws Exception {
- clock.setTime(new DateTime("2015-09-01T08:01:01.000Z"));
-
- final DateTimeZone tz = DateTimeZone.forID("America/Juneau");
- final AccountData accountData = new MockAccountBuilder().name(UUID.randomUUID().toString().substring(1, 8))
- .firstNameLength(6)
- .email(UUID.randomUUID().toString().substring(1, 8))
- .phone(UUID.randomUUID().toString().substring(1, 8))
- .migrated(false)
- .isNotifiedForInvoices(false)
- .externalKey(UUID.randomUUID().toString().substring(1, 8))
- .billingCycleDayLocal(1)
- .currency(Currency.USD)
- .paymentMethodId(UUID.randomUUID())
- .referenceTime(clock.getUTCNow())
- .timeZone(tz)
- .build();
- final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
- accountChecker.checkAccount(account.getId(), accountData, callContext);
-
- //
- // CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE, NextEvent.BLOCK NextEvent.INVOICE
- //
- final DefaultEntitlement bpSubscription = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.ANNUAL, NextEvent.CREATE, NextEvent.BLOCK, NextEvent.INVOICE);
- // Check bundle after BP got created otherwise we get an error from auditApi.
- subscriptionChecker.checkSubscriptionCreated(bpSubscription.getId(), internalCallContext);
- invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2015, 9, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- assertListenerStatus();
-
- //
- // ADD ADD_ON ON THE SAME DAY
- //
- final DefaultEntitlement aoSubscription = addAOEntitlementAndCheckForCompletion(bpSubscription.getBundleId(), "Bullets", ProductCategory.ADD_ON, BillingPeriod.NO_BILLING_PERIOD, NextEvent.CREATE, NextEvent.BLOCK, NextEvent.NULL_INVOICE);
- assertListenerStatus();
-
- busHandler.pushExpectedEvents(NextEvent.PHASE, NextEvent.NULL_INVOICE, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT);
- clock.addDays(30);
- assertListenerStatus();
- invoiceChecker.checkInvoice(account.getId(), 2, callContext,
- new ExpectedInvoiceItemCheck(new LocalDate(2015, 10, 1), new LocalDate(2016, 10, 1), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
-
- // 2015-11-1
- busHandler.pushExpectedEvent(NextEvent.NULL_INVOICE);
- clock.addMonths(1);
- assertListenerStatus();
-
- // 2015-12-1
- busHandler.pushExpectedEvent(NextEvent.NULL_INVOICE);
- clock.addMonths(1);
- assertListenerStatus();
-
- // We sleep to let system creates lots of notification if an infinite loop was indeed happening
- Thread.sleep(3000);
- // And then we check that we only have the expected number of notifications in the history table.
- final Integer countNotifications = dbi.withHandle(new HandleCallback<Integer>() {
- @Override
- public Integer withHandle(final Handle handle) throws Exception {
-
- List<Map<String, Object>> res = handle.select("select count(*) as count from notifications_history;");
- final Integer count = Integer.valueOf(res.get(0).get("count").toString());
- return count;
- }
- }
- );
- Assert.assertEquals(countNotifications.intValue(), 4);
- }
-
private void setUsage(final UUID subscriptionId, final String unitType, final LocalDate startDate, final Long amount, final CallContext context) throws UsageApiException {
final List<UsageRecord> usageRecords = new ArrayList<UsageRecord>();
usageRecords.add(new UsageRecord(startDate, amount));