Search in sources :

Example 16 with LocalDate

use of org.joda.time.LocalDate in project killbill by killbill.

the class TestEffectiveDateForNewBCD method testPastEffectiveDateWithBCDEqualsComputedEffectiveDay.

@Test(groups = "fast")
public void testPastEffectiveDateWithBCDEqualsComputedEffectiveDay() throws Exception {
    // Set by test as : 2012-05-07T00:03:42.000Z
    final DateTime now = clock.getUTCNow();
    int newBCD = 3;
    // effectiveDate = 2012-05-07T00:03:42.000Z => ComputedEffectiveDay = 7
    LocalDate effectiveDate = new LocalDate(2012, 2, 3);
    // newBCD == ComputedEffectiveDay
    final DateTime result = ((DefaultSubscriptionInternalApi) subscriptionInternalApi).getEffectiveDateForNewBCD(newBCD, effectiveDate, internalCallContext);
    Assert.assertEquals(result, internalCallContext.toUTCDateTime(new LocalDate("2012-02-03")));
}
Also used : LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 17 with LocalDate

use of org.joda.time.LocalDate in project killbill by killbill.

the class TestEffectiveDateForNewBCD method testFutureEffectiveDateWithBCDEqualsComputedEffectiveDay.

@Test(groups = "fast")
public void testFutureEffectiveDateWithBCDEqualsComputedEffectiveDay() throws Exception {
    // Set by test as : 2012-05-07T00:03:42.000Z
    final DateTime now = clock.getUTCNow();
    int newBCD = 3;
    // effectiveDate = 2012-05-07T00:03:42.000Z => ComputedEffectiveDay = 7
    LocalDate effectiveDate = new LocalDate(2012, 7, 3);
    // newBCD == ComputedEffectiveDay
    final DateTime result = ((DefaultSubscriptionInternalApi) subscriptionInternalApi).getEffectiveDateForNewBCD(newBCD, effectiveDate, internalCallContext);
    Assert.assertEquals(result, internalCallContext.toUTCDateTime(new LocalDate("2012-07-03")));
}
Also used : LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 18 with LocalDate

use of org.joda.time.LocalDate in project killbill by killbill.

the class TestEffectiveDateForNewBCD method testFutureEffectiveDateWithBCDAfterEndOfTheMonth.

@Test(groups = "fast")
public void testFutureEffectiveDateWithBCDAfterEndOfTheMonth() throws Exception {
    // Set by test as : 2012-05-07T00:03:42.000Z
    final DateTime now = clock.getUTCNow();
    int newBCD = 31;
    // effectiveDate = 2012-06-03 => ComputedEffectiveDay = 3
    LocalDate effectiveDate = new LocalDate(2012, 6, 3);
    // newBCD > 30 (max day in June)
    final DateTime result = ((DefaultSubscriptionInternalApi) subscriptionInternalApi).getEffectiveDateForNewBCD(newBCD, effectiveDate, internalCallContext);
    Assert.assertEquals(result, internalCallContext.toUTCDateTime(new LocalDate("2012-06-30")));
}
Also used : LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 19 with LocalDate

use of org.joda.time.LocalDate in project killbill by killbill.

the class TestEffectiveDateForNewBCD method testPastEffectiveDateWithBCDPriorComputedEffectiveDay.

@Test(groups = "fast")
public void testPastEffectiveDateWithBCDPriorComputedEffectiveDay() throws Exception {
    // Set by test as : 2012-05-07T00:03:42.000Z
    final DateTime now = clock.getUTCNow();
    int newBCD = 3;
    // effectiveDate = 2012-05-07T00:03:42.000Z => ComputedEffectiveDay = 7
    LocalDate effectiveDate = new LocalDate(2012, 2, 7);
    // newBCD < ComputedEffectiveDay
    final DateTime result = ((DefaultSubscriptionInternalApi) subscriptionInternalApi).getEffectiveDateForNewBCD(newBCD, effectiveDate, internalCallContext);
    Assert.assertEquals(result, internalCallContext.toUTCDateTime(new LocalDate("2012-03-03")));
}
Also used : LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 20 with LocalDate

use of org.joda.time.LocalDate in project killbill by killbill.

the class TestEffectiveDateForNewBCD method testNullEffectiveDateWithBCDAfterEndOfTheMonth.

@Test(groups = "fast")
public void testNullEffectiveDateWithBCDAfterEndOfTheMonth() throws Exception {
    // Set by test as : 2012-05-07T00:03:42.000Z
    final DateTime now = clock.getUTCNow();
    int newBCD = 10;
    // effectiveDate = 2012-05-07T00:03:42.000Z => ComputedEffectiveDay = 7
    LocalDate effectiveDate = null;
    // newBCD < ComputedEffectiveDay
    final DateTime result = ((DefaultSubscriptionInternalApi) subscriptionInternalApi).getEffectiveDateForNewBCD(newBCD, effectiveDate, internalCallContext);
    Assert.assertEquals(result, internalCallContext.toUTCDateTime(new LocalDate("2012-05-10")));
}
Also used : LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Aggregations

LocalDate (org.joda.time.LocalDate)1025 Test (org.testng.annotations.Test)553 BigDecimal (java.math.BigDecimal)401 DateTime (org.joda.time.DateTime)230 ArrayList (java.util.ArrayList)211 Invoice (org.killbill.billing.invoice.api.Invoice)165 UUID (java.util.UUID)143 Account (org.killbill.billing.account.api.Account)139 Test (org.junit.Test)137 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)118 DefaultEntitlement (org.killbill.billing.entitlement.api.DefaultEntitlement)104 FixedPriceInvoiceItem (org.killbill.billing.invoice.model.FixedPriceInvoiceItem)101 RecurringInvoiceItem (org.killbill.billing.invoice.model.RecurringInvoiceItem)95 ExpectedInvoiceItemCheck (org.killbill.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck)85 DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)82 RepairAdjInvoiceItem (org.killbill.billing.invoice.model.RepairAdjInvoiceItem)71 ItemAdjInvoiceItem (org.killbill.billing.invoice.model.ItemAdjInvoiceItem)69 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)63 Date (java.util.Date)57 MockPlan (org.killbill.billing.catalog.MockPlan)52