Search in sources :

Example 81 with Account

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);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) RequestOptions(org.killbill.billing.client.RequestOptions) Test(org.testng.annotations.Test)

Example 82 with Account

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");
}
Also used : Account(org.killbill.billing.client.model.gen.Account) AuditLog(org.killbill.billing.client.model.gen.AuditLog) LinkedHashMap(java.util.LinkedHashMap) Test(org.testng.annotations.Test)

Example 83 with Account

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);
}
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 84 with Account

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;
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Subscription(org.killbill.billing.client.model.gen.Subscription)

Example 85 with Account

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;
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Subscription(org.killbill.billing.client.model.gen.Subscription)

Aggregations

Account (org.killbill.billing.client.model.gen.Account)153 Test (org.testng.annotations.Test)139 DateTime (org.joda.time.DateTime)43 UUID (java.util.UUID)38 InvoicePayment (org.killbill.billing.client.model.gen.InvoicePayment)37 Subscription (org.killbill.billing.client.model.gen.Subscription)34 Invoice (org.killbill.billing.client.model.gen.Invoice)33 BigDecimal (java.math.BigDecimal)29 Payment (org.killbill.billing.client.model.gen.Payment)28 PaymentTransaction (org.killbill.billing.client.model.gen.PaymentTransaction)21 KillBillClientException (org.killbill.billing.client.KillBillClientException)19 Invoices (org.killbill.billing.client.model.Invoices)19 ComboPaymentTransaction (org.killbill.billing.client.model.gen.ComboPaymentTransaction)19 InvoiceItem (org.killbill.billing.client.model.gen.InvoiceItem)19 LocalDate (org.joda.time.LocalDate)13 InvoicePayments (org.killbill.billing.client.model.InvoicePayments)13 Tags (org.killbill.billing.client.model.Tags)13 PaymentMethod (org.killbill.billing.client.model.gen.PaymentMethod)12 InvoicePaymentTransaction (org.killbill.billing.client.model.gen.InvoicePaymentTransaction)11 Payments (org.killbill.billing.client.model.Payments)10