Search in sources :

Example 36 with AccountApiException

use of org.killbill.billing.account.api.AccountApiException in project killbill by killbill.

the class TestAccountDao method testHandleDuplicateEmails.

@Test(groups = "slow", description = "Test Account DAO: duplicate emails throws an exception")
public void testHandleDuplicateEmails() throws AccountApiException {
    final UUID accountId = UUID.randomUUID();
    final AccountEmail email = new DefaultAccountEmail(accountId, "test@gmail.com");
    Assert.assertEquals(accountDao.getEmailsByAccountId(accountId, internalCallContext).size(), 0);
    final AccountEmailModelDao accountEmailModelDao = new AccountEmailModelDao(email);
    accountDao.addEmail(accountEmailModelDao, internalCallContext);
    Assert.assertEquals(accountDao.getEmailsByAccountId(accountId, internalCallContext).size(), 1);
    try {
        accountDao.addEmail(accountEmailModelDao, internalCallContext);
        Assert.fail();
    } catch (AccountApiException e) {
        Assert.assertEquals(e.getCode(), ErrorCode.ACCOUNT_EMAIL_ALREADY_EXISTS.getCode());
    }
}
Also used : DefaultAccountEmail(org.killbill.billing.account.api.DefaultAccountEmail) AccountEmail(org.killbill.billing.account.api.AccountEmail) DefaultAccountEmail(org.killbill.billing.account.api.DefaultAccountEmail) AccountApiException(org.killbill.billing.account.api.AccountApiException) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Aggregations

AccountApiException (org.killbill.billing.account.api.AccountApiException)36 UUID (java.util.UUID)17 Account (org.killbill.billing.account.api.Account)16 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)12 DefaultAccount (org.killbill.billing.account.api.DefaultAccount)10 ArrayList (java.util.ArrayList)7 ImmutableAccountData (org.killbill.billing.account.api.ImmutableAccountData)7 InvoiceApiException (org.killbill.billing.invoice.api.InvoiceApiException)7 PaymentApiException (org.killbill.billing.payment.api.PaymentApiException)6 SubscriptionBaseApiException (org.killbill.billing.subscription.api.user.SubscriptionBaseApiException)6 CallContext (org.killbill.billing.util.callcontext.CallContext)6 BigDecimal (java.math.BigDecimal)5 HashMap (java.util.HashMap)5 AccountModelDao (org.killbill.billing.account.dao.AccountModelDao)5 Invoice (org.killbill.billing.invoice.api.Invoice)5 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)4 Subscribe (com.google.common.eventbus.Subscribe)4 LocalDate (org.joda.time.LocalDate)4 DefaultMutableAccountData (org.killbill.billing.account.api.DefaultMutableAccountData)4 PaymentMethod (org.killbill.billing.payment.api.PaymentMethod)4