use of org.killbill.billing.client.model.AccountTimeline in project killbill by killbill.
the class TestAccountTimeline method verifyCredits.
private void verifyCredits(final UUID accountId, final DateTime startTime, final DateTime endTime, final BigDecimal creditAmount) throws Exception {
for (final AuditLevel auditLevel : AuditLevel.values()) {
final AccountTimeline timeline = getAccountTimeline(accountId, auditLevel);
// Verify credits
final List<Credit> credits = timeline.getInvoices().get(1).getCredits();
Assert.assertEquals(credits.size(), 1);
Assert.assertEquals(credits.get(0).getCreditAmount().compareTo(creditAmount.negate()), 0);
// Verify audits
final List<AuditLog> creditAuditLogs = credits.get(0).getAuditLogs();
if (AuditLevel.NONE.equals(auditLevel)) {
Assert.assertEquals(creditAuditLogs.size(), 0);
} else {
Assert.assertEquals(creditAuditLogs.size(), 1);
verifyAuditLog(creditAuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
}
}
}
use of org.killbill.billing.client.model.AccountTimeline in project killbill by killbill.
the class TestAccountTimeline method verifyInvoices.
private void verifyInvoices(final UUID accountId, final DateTime startTime, final DateTime endTime) throws Exception {
for (final AuditLevel auditLevel : AuditLevel.values()) {
final AccountTimeline timeline = getAccountTimeline(accountId, auditLevel);
// Verify invoices
Assert.assertEquals(timeline.getInvoices().size(), 3);
// Verify audits
final List<AuditLog> firstInvoiceAuditLogs = timeline.getInvoices().get(0).getAuditLogs();
final List<AuditLog> secondInvoiceAuditLogs = timeline.getInvoices().get(1).getAuditLogs();
final List<AuditLog> thirdInvoiceAuditLogs = timeline.getInvoices().get(2).getAuditLogs();
if (AuditLevel.NONE.equals(auditLevel)) {
Assert.assertEquals(firstInvoiceAuditLogs.size(), 0);
Assert.assertEquals(secondInvoiceAuditLogs.size(), 0);
Assert.assertEquals(thirdInvoiceAuditLogs.size(), 0);
} else {
Assert.assertEquals(firstInvoiceAuditLogs.size(), 1);
verifyAuditLog(firstInvoiceAuditLogs.get(0), ChangeType.INSERT, null, null, TRANSITION, startTime, endTime);
Assert.assertEquals(secondInvoiceAuditLogs.size(), 1);
verifyAuditLog(secondInvoiceAuditLogs.get(0), ChangeType.INSERT, null, null, TRANSITION, startTime, endTime);
Assert.assertEquals(thirdInvoiceAuditLogs.size(), 1);
verifyAuditLog(thirdInvoiceAuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
}
}
}
use of org.killbill.billing.client.model.AccountTimeline in project killbill by killbill.
the class TestAccountTimeline method verifyBundles.
private void verifyBundles(final UUID accountId, final DateTime startTime, final DateTime endTime) throws Exception {
for (final AuditLevel auditLevel : AuditLevel.values()) {
final AccountTimeline timeline = getAccountTimeline(accountId, auditLevel);
// Verify bundles
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);
// Verify audits
final List<AuditLog> bundleAuditLogs = timeline.getBundles().get(0).getAuditLogs();
final List<AuditLog> subscriptionAuditLogs = timeline.getBundles().get(0).getSubscriptions().get(0).getAuditLogs();
final List<AuditLog> subscriptionEvent1AuditLogs = timeline.getBundles().get(0).getSubscriptions().get(0).getEvents().get(0).getAuditLogs();
final List<AuditLog> subscriptionEvent2AuditLogs = timeline.getBundles().get(0).getSubscriptions().get(0).getEvents().get(1).getAuditLogs();
if (AuditLevel.NONE.equals(auditLevel)) {
// Audits for bundles
Assert.assertEquals(bundleAuditLogs.size(), 0);
// Audits for subscriptions
Assert.assertEquals(subscriptionAuditLogs.size(), 0);
// Audit for subscription events
Assert.assertEquals(subscriptionEvent1AuditLogs.size(), 0);
Assert.assertEquals(subscriptionEvent2AuditLogs.size(), 0);
} else if (AuditLevel.MINIMAL.equals(auditLevel)) {
// Audits for bundles
Assert.assertEquals(bundleAuditLogs.size(), 1);
verifyAuditLog(bundleAuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
// Audits for subscriptions
Assert.assertEquals(subscriptionAuditLogs.size(), 1);
verifyAuditLog(subscriptionAuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
// Audit for subscription events
Assert.assertEquals(subscriptionEvent1AuditLogs.size(), 1);
verifyAuditLog(subscriptionEvent1AuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
Assert.assertEquals(subscriptionEvent2AuditLogs.size(), 1);
verifyAuditLog(subscriptionEvent2AuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
} else {
// Audits for bundles
Assert.assertEquals(bundleAuditLogs.size(), 3);
verifyAuditLog(bundleAuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
verifyAuditLog(bundleAuditLogs.get(1), ChangeType.UPDATE, null, null, TRANSITION, startTime, endTime);
verifyAuditLog(bundleAuditLogs.get(2), ChangeType.UPDATE, null, null, TRANSITION, startTime, endTime);
// Audits for subscriptions
Assert.assertEquals(subscriptionAuditLogs.size(), 3);
verifyAuditLog(subscriptionAuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
verifyAuditLog(subscriptionAuditLogs.get(1), ChangeType.UPDATE, null, null, TRANSITION, startTime, endTime);
verifyAuditLog(subscriptionAuditLogs.get(2), ChangeType.UPDATE, null, null, TRANSITION, startTime, endTime);
// Audit for subscription events
Assert.assertEquals(subscriptionEvent1AuditLogs.size(), 1);
verifyAuditLog(subscriptionEvent1AuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
Assert.assertEquals(subscriptionEvent2AuditLogs.size(), 1);
verifyAuditLog(subscriptionEvent2AuditLogs.get(0), ChangeType.INSERT, reason, comment, createdBy, startTime, endTime);
}
}
}
use of org.killbill.billing.client.model.AccountTimeline in project killbill by killbill.
the class TestAccountTimeline method getAccountTimeline.
private AccountTimeline getAccountTimeline(final UUID accountId, final AuditLevel auditLevel) throws KillBillClientException {
final AccountTimeline accountTimeline = killBillClient.getAccountTimeline(accountId, auditLevel, RequestOptions.empty());
// Verify also the parallel path
final HashMultimap<String, String> queryParams = HashMultimap.<String, String>create();
queryParams.put(QUERY_PARALLEL, "true");
final RequestOptions requestOptions = RequestOptions.builder().withQueryParams(queryParams).build();
final AccountTimeline accountTimelineInParallel = killBillClient.getAccountTimeline(accountId, auditLevel, requestOptions);
Assert.assertEquals(accountTimelineInParallel, accountTimeline);
return accountTimeline;
}
use of org.killbill.billing.client.model.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);
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(), "START_ENTITLEMENT");
Assert.assertEquals(events.get(1).getEffectiveDate(), new LocalDate(2012, 4, 25));
Assert.assertEquals(events.get(1).getEventType(), "START_BILLING");
Assert.assertEquals(events.get(2).getEffectiveDate(), new LocalDate(2012, 5, 25));
Assert.assertEquals(events.get(2).getEventType(), "PHASE");
}
Aggregations