use of org.killbill.billing.tenant.dao.TenantModelDao in project killbill by killbill.
the class TestKillbillJdbcTenantRealm method beforeMethod.
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
// Create the tenant
final DefaultTenantDao tenantDao = new DefaultTenantDao(dbi, clock, cacheControllerDispatcher, new DefaultNonEntityDao(dbi), Mockito.mock(InternalCallContextFactory.class), securityConfig);
tenant = new DefaultTenant(UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
tenantDao.create(new TenantModelDao(tenant), internalCallContext);
// Setup the security manager
final HikariConfig dbConfig = new HikariConfig();
dbConfig.setJdbcUrl(helper.getJdbcConnectionString());
dbConfig.setUsername(helper.getUsername());
dbConfig.setPassword(helper.getPassword());
final KillbillJdbcTenantRealm jdbcRealm = new KillbillJdbcTenantRealm(shiroDataSource, securityConfig);
jdbcRealm.setDataSource(new HikariDataSource(dbConfig));
securityManager = new DefaultSecurityManager(jdbcRealm);
}
use of org.killbill.billing.tenant.dao.TenantModelDao in project killbill by killbill.
the class TestDefaultAccountUserApi method testCreateAccountWithSameExternalKeyInDifferentTenants.
@Test(groups = "slow", description = "Test Account creation with same External Key in different tenants")
public void testCreateAccountWithSameExternalKeyInDifferentTenants() throws Exception {
final AccountData accountData = createAccountData();
final Account account1 = accountUserApi.createAccount(accountData, callContext);
try {
// Same tenant
accountUserApi.createAccount(accountData, callContext);
Assert.fail();
} catch (final AccountApiException e) {
assertEquals(e.getCode(), ErrorCode.ACCOUNT_ALREADY_EXISTS.getCode());
}
final TenantSqlDao tenantSqlDao = dbi.onDemand(TenantSqlDao.class);
final TenantModelDao tenant2 = new TenantModelDao();
tenantSqlDao.create(tenant2, internalCallContext);
final CallContext callContext2 = new DefaultCallContext(tenant2.getId(), callContext.getUserName(), callContext.getCallOrigin(), callContext.getUserType(), callContext.getUserToken(), clock);
final Account account2 = accountUserApi.createAccount(accountData, callContext2);
Assert.assertEquals(account1.getExternalKey(), account2.getExternalKey());
Assert.assertNotEquals(account1.getId(), account2.getId());
}
Aggregations