Search in sources :

Example 6 with AccountTimeline

use of org.killbill.billing.client.model.gen.AccountTimeline in project killbill by killbill.

the class TestAccountTimeline method testAccountTimeline.

@Test(groups = "slow", description = "Can retrieve the timeline without audits")
public void testAccountTimeline() throws Exception {
    clock.setTime(new DateTime(2012, 4, 25, 0, 3, 42, 0));
    final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
    final AccountTimeline timeline = getAccountTimeline(accountJson.getAccountId(), AuditLevel.NONE);
    Assert.assertEquals(timeline.getPayments().size(), 1);
    Assert.assertEquals(timeline.getInvoices().size(), 2);
    Assert.assertEquals(timeline.getBundles().size(), 1);
    Assert.assertEquals(timeline.getBundles().get(0).getSubscriptions().size(), 1);
    Assert.assertEquals(timeline.getBundles().get(0).getSubscriptions().get(0).getEvents().size(), 3);
    Assert.assertNotNull(timeline.getInvoices().get(0).getBundleKeys());
    final List<EventSubscription> events = timeline.getBundles().get(0).getSubscriptions().get(0).getEvents();
    Assert.assertEquals(events.get(0).getEffectiveDate(), new LocalDate(2012, 4, 25));
    Assert.assertEquals(events.get(0).getEventType(), SubscriptionEventType.START_ENTITLEMENT);
    Assert.assertEquals(events.get(1).getEffectiveDate(), new LocalDate(2012, 4, 25));
    Assert.assertEquals(events.get(1).getEventType(), SubscriptionEventType.START_BILLING);
    Assert.assertEquals(events.get(2).getEffectiveDate(), new LocalDate(2012, 5, 25));
    Assert.assertEquals(events.get(2).getEventType(), SubscriptionEventType.PHASE);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) EventSubscription(org.killbill.billing.client.model.gen.EventSubscription) AccountTimeline(org.killbill.billing.client.model.gen.AccountTimeline) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 7 with AccountTimeline

use of org.killbill.billing.client.model.gen.AccountTimeline in project killbill by killbill.

the class TestEntitlement method testOverwriteEntitlementBCDOnCreate.

@Test(groups = "slow", description = "Verify we can move the BCD associated with the subscription")
public void testOverwriteEntitlementBCDOnCreate() throws Exception {
    final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
    clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
    final Account accountJson = createAccountWithDefaultPaymentMethod();
    callbackServlet.pushExpectedEvents(ExtBusEventType.ACCOUNT_CHANGE, ExtBusEventType.ENTITLEMENT_CREATION, ExtBusEventType.SUBSCRIPTION_CREATION, ExtBusEventType.SUBSCRIPTION_CREATION, ExtBusEventType.SUBSCRIPTION_BCD_CHANGE, ExtBusEventType.INVOICE_CREATION);
    final Subscription input = new Subscription();
    input.setAccountId(accountJson.getAccountId());
    input.setPlanName("shotgun-monthly");
    input.setBillCycleDayLocal(28);
    final Subscription subscription = subscriptionApi.createSubscription(input, null, null, true, false, null, true, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, NULL_PLUGIN_PROPERTIES, requestOptions);
    Assert.assertEquals(subscription.getBillCycleDayLocal().intValue(), 28);
    callbackServlet.assertListenerStatus();
    final AccountTimeline timeline = accountApi.getAccountTimeline(accountJson.getAccountId(), false, AuditLevel.FULL, requestOptions);
    Assert.assertEquals(timeline.getBundles().size(), 1);
    Assert.assertEquals(timeline.getBundles().get(0).getSubscriptions().size(), 1);
    final Subscription subscriptionT = timeline.getBundles().get(0).getSubscriptions().get(0);
    Assert.assertEquals(subscriptionT.getBillCycleDayLocal().intValue(), 28);
    // Note that we are START_ENTITLEMENT, START_BILLING, PHASE
    // TODO : we should add the BCD_CHANGE event in the timeline (does not exist in SubscriptionEventType)
    Assert.assertEquals(subscriptionT.getEvents().size(), 3);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) AccountTimeline(org.killbill.billing.client.model.gen.AccountTimeline) Subscription(org.killbill.billing.client.model.gen.Subscription) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Aggregations

AccountTimeline (org.killbill.billing.client.model.gen.AccountTimeline)7 AuditLog (org.killbill.billing.client.model.gen.AuditLog)4 AuditLevel (org.killbill.billing.util.api.AuditLevel)4 DateTime (org.joda.time.DateTime)2 Account (org.killbill.billing.client.model.gen.Account)2 Test (org.testng.annotations.Test)2 LocalDate (org.joda.time.LocalDate)1 EventSubscription (org.killbill.billing.client.model.gen.EventSubscription)1 InvoiceItem (org.killbill.billing.client.model.gen.InvoiceItem)1 InvoicePayment (org.killbill.billing.client.model.gen.InvoicePayment)1 InvoicePaymentTransaction (org.killbill.billing.client.model.gen.InvoicePaymentTransaction)1 PaymentTransaction (org.killbill.billing.client.model.gen.PaymentTransaction)1 Subscription (org.killbill.billing.client.model.gen.Subscription)1