use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestAccount method testEncodedHeaders.
@Test(groups = "slow", description = "Verify encoded headers")
public void testEncodedHeaders() throws Exception {
final String comment = "マリオありがとう! しかし、私たちの王女は別の城にいます!";
final RequestOptions requestOptions = RequestOptions.builder().withCreatedBy(createdBy).withReason(reason).withComment(Base64.getEncoder().encodeToString(comment.getBytes(StandardCharsets.UTF_8))).withHeader("X-Killbill-Encoding", "base64").withFollowLocation(true).withQueryParamsForFollow(ImmutableMultimap.of(JaxrsResource.QUERY_AUDIT, AuditLevel.MINIMAL.name())).build();
final Account emptyAccount = new Account();
final Account account = accountApi.createAccount(emptyAccount, requestOptions);
Assert.assertNotNull(account.getExternalKey());
Assert.assertEquals(account.getAuditLogs().get(0).getComments(), comment);
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestAccount method testGetAccountAuditLogsWithHistory.
@Test(groups = "slow", description = "retrieve account logs")
public void testGetAccountAuditLogsWithHistory() throws Exception {
final Account accountJson = createAccount();
assertNotNull(accountJson);
// Update Account
final Account newInput = new Account().setAccountId(accountJson.getAccountId()).setExternalKey(accountJson.getExternalKey()).setName("zozo");
accountApi.updateAccount(accountJson.getAccountId(), newInput, requestOptions);
final List<AuditLog> auditLogWithHistories = accountApi.getAccountAuditLogsWithHistory(accountJson.getAccountId(), requestOptions);
assertEquals(auditLogWithHistories.size(), 2);
assertEquals(auditLogWithHistories.get(0).getChangeType(), ChangeType.INSERT.toString());
assertEquals(auditLogWithHistories.get(0).getObjectType(), ObjectType.ACCOUNT);
assertEquals(auditLogWithHistories.get(0).getObjectId(), accountJson.getAccountId());
final LinkedHashMap<String, Object> history1 = (LinkedHashMap<String, Object>) auditLogWithHistories.get(0).getHistory();
assertNotNull(history1);
assertEquals(history1.get("externalKey"), accountJson.getExternalKey());
assertEquals(history1.get("name"), accountJson.getName());
final LinkedHashMap history2 = (LinkedHashMap) auditLogWithHistories.get(1).getHistory();
assertNotNull(history2);
assertEquals(history2.get("externalKey"), accountJson.getExternalKey());
assertNotEquals(history2.get("name"), accountJson.getName());
assertEquals(history2.get("name"), "zozo");
}
use of org.killbill.billing.client.model.gen.Account 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.Account in project killbill by killbill.
the class KillbillClient method createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice.
protected Account createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(final String productName, final boolean invoicePaymentSuccess, final boolean paymentSuccess) throws Exception {
final Account accountJson = createAccountWithDefaultPaymentMethod();
assertNotNull(accountJson);
// Add a bundle, subscription and move the clock to get the first invoice
final Subscription subscriptionJson = createSubscription(accountJson.getAccountId(), UUID.randomUUID().toString(), productName, ProductCategory.BASE, BillingPeriod.MONTHLY);
assertNotNull(subscriptionJson);
callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.INVOICE_CREATION);
if (invoicePaymentSuccess) {
callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_PAYMENT_SUCCESS);
} else {
callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_PAYMENT_FAILED);
}
if (paymentSuccess) {
callbackServlet.pushExpectedEvents(ExtBusEventType.PAYMENT_SUCCESS);
} else {
callbackServlet.pushExpectedEvents(ExtBusEventType.PAYMENT_FAILED);
}
clock.addDays(32);
callbackServlet.assertListenerStatus();
return accountJson;
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class KillbillClient method createAccountNoPMBundleAndSubscription.
protected Account createAccountNoPMBundleAndSubscription() throws Exception {
// Create an account with no payment method
final Account accountJson = createAccount();
assertNotNull(accountJson);
// Add a bundle, subscription and move the clock to get the first invoice
final Subscription subscriptionJson = createSubscription(accountJson.getAccountId(), UUID.randomUUID().toString(), "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY);
assertNotNull(subscriptionJson);
return accountJson;
}
Aggregations