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);
}
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);
}
Aggregations