Search in sources :

Example 21 with Account

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

the class TestAccount method testAccountOk.

@Test(groups = "slow", description = "Can create, retrieve, search and update accounts")
public void testAccountOk() throws Exception {
    final Account input = createAccount();
    // Create a second account (https://github.com/killbill/killbill/issues/1422 regression testing)
    final Account secondAccount = createAccount();
    final Account retrievedSecondAccount = accountApi.getAccountByKey(secondAccount.getExternalKey(), requestOptions);
    Assert.assertEquals(secondAccount, retrievedSecondAccount);
    // Retrieves by external key
    final Account retrievedAccount = accountApi.getAccountByKey(input.getExternalKey(), requestOptions);
    Assert.assertEquals(input, retrievedAccount);
    // Try search endpoint
    searchAccount(input, retrievedAccount);
    // Force limit=1 (https://github.com/killbill/killbill/issues/1422 regression testing)
    final Accounts allAccounts = accountApi.searchAccounts(input.getCompany(), 0L, 1L, false, false, AuditLevel.NONE, requestOptions);
    // Company name is the same for both accounts
    Assert.assertEquals(allAccounts.size(), 1);
    Assert.assertEquals(allAccounts.get(0).getExternalKey(), retrievedAccount.getExternalKey());
    final Accounts secondPage = allAccounts.getNext();
    Assert.assertEquals(secondPage.size(), 1);
    Assert.assertEquals(secondPage.get(0).getExternalKey(), retrievedSecondAccount.getExternalKey());
    // Update Account
    final Account newInput = new Account(input.getAccountId(), "zozo", 4, input.getExternalKey(), "rr@google.com", 18, Currency.USD, null, false, null, null, "UTC", "bl1", "bh2", "", "", "ca", "San Francisco", "usa", "en", "415-255-2991", "notes", false, null, null, EMPTY_AUDIT_LOGS);
    accountApi.updateAccount(input.getAccountId(), newInput, requestOptions);
    final Account updatedAccount = accountApi.getAccount(input.getAccountId(), requestOptions);
    // referenceTime is set automatically by system, no way to guess it
    newInput.setReferenceTime(updatedAccount.getReferenceTime());
    Assert.assertTrue(updatedAccount.equals(newInput));
    // Try search endpoint
    searchAccount(input, null);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Accounts(org.killbill.billing.client.model.Accounts) Test(org.testng.annotations.Test)

Example 22 with Account

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

the class TestAccount method testGetChildrenAccounts.

@Test(groups = "slow", description = "retrieve children accounts by parent account id")
public void testGetChildrenAccounts() throws Exception {
    final Account parentAccount = createAccount();
    final Account childInput = getAccount();
    childInput.setParentAccountId(parentAccount.getAccountId());
    childInput.setIsPaymentDelegatedToParent(true);
    Account childAccount = accountApi.createAccount(childInput, requestOptions);
    childAccount = accountApi.getAccount(childAccount.getAccountId(), true, true, AuditLevel.NONE, requestOptions);
    final Account childInput2 = getAccount();
    childInput2.setParentAccountId(parentAccount.getAccountId());
    childInput2.setIsPaymentDelegatedToParent(true);
    Account childAccount2 = accountApi.createAccount(childInput2, requestOptions);
    childAccount2 = accountApi.getAccount(childAccount2.getAccountId(), true, true, AuditLevel.NONE, requestOptions);
    // Retrieves children accounts by parent account id
    final Accounts childrenAccounts = accountApi.getChildrenAccounts(parentAccount.getAccountId(), true, true, AuditLevel.NONE, requestOptions);
    Assert.assertEquals(childrenAccounts.size(), 2);
    Assert.assertTrue(childrenAccounts.get(0).equals(childAccount));
    Assert.assertTrue(childrenAccounts.get(1).equals(childAccount2));
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Accounts(org.killbill.billing.client.model.Accounts) Test(org.testng.annotations.Test)

Example 23 with Account

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

the class TestAccount method testAccountPaymentsWithRefund.

@Test(groups = "slow")
public void testAccountPaymentsWithRefund() throws Exception {
    final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
    // Verify payments
    final InvoicePayments objFromJson = accountApi.getInvoicePayments(accountJson.getAccountId(), NULL_PLUGIN_PROPERTIES, requestOptions);
    Assert.assertEquals(objFromJson.size(), 1);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) InvoicePayments(org.killbill.billing.client.model.InvoicePayments) Test(org.testng.annotations.Test)

Example 24 with Account

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

the class TestAccount method testEmptyAccount.

@Test(groups = "slow", description = "Verify no PII data is required")
public void testEmptyAccount() throws Exception {
    final Account emptyAccount = new Account();
    final Account account = accountApi.createAccount(emptyAccount, requestOptions);
    Assert.assertNotNull(account.getExternalKey());
    Assert.assertNull(account.getName());
    Assert.assertNull(account.getEmail());
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Test(org.testng.annotations.Test)

Example 25 with Account

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

the class TestAccount method testAccountWithBalance.

@Test(groups = "slow", description = "Can retrieve the account balance")
public void testAccountWithBalance() throws Exception {
    final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
    final Account accountWithBalance = accountApi.getAccount(accountJson.getAccountId(), true, false, AuditLevel.NONE, requestOptions);
    final BigDecimal accountBalance = accountWithBalance.getAccountBalance();
    Assert.assertTrue(accountBalance.compareTo(BigDecimal.ZERO) > 0);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

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