@Override public Object execute() throws Throwable { Assert.assertEquals(subscriptionDao.getSubscriptionBundleForAccount(accountId, internalCallContext).size(), 0); Mockito.verify(dbiSpy, Mockito.times(0)).open(); Mockito.verify(roDbiSpy, Mockito.times(1)).open(); Assert.assertEquals(subscriptionDao.getSubscriptionBundleForAccount(accountId, internalCallContext).size(), 0); Mockito.verify(dbiSpy, Mockito.times(0)).open(); Mockito.verify(roDbiSpy, Mockito.times(2)).open(); final String externalKey = UUID.randomUUID().toString(); final DateTime startDate = clock.getUTCNow(); final DateTime createdDate = startDate.plusSeconds(10); final DefaultSubscriptionBaseBundle bundleDef = new DefaultSubscriptionBaseBundle(externalKey, accountId, startDate, startDate, createdDate, createdDate); final SubscriptionBaseBundle bundle = subscriptionDao.createSubscriptionBundle(bundleDef, catalog, false, internalCallContext); Mockito.verify(dbiSpy, Mockito.times(1)).open(); Mockito.verify(roDbiSpy, Mockito.times(2)).open(); Assert.assertEquals(subscriptionDao.getSubscriptionBundleForAccount(accountId, internalCallContext).size(), 1); Mockito.verify(dbiSpy, Mockito.times(2)).open(); Mockito.verify(roDbiSpy, Mockito.times(2)).open(); Assert.assertEquals(subscriptionDao.getSubscriptionBundleForAccount(accountId, internalCallContext).size(), 1); Mockito.verify(dbiSpy, Mockito.times(3)).open(); Mockito.verify(roDbiSpy, Mockito.times(2)).open(); return null; } });
@Test(groups = "slow") public void testRetrieveAuditsDirectly() throws Exception { addTag(); // Verify we get an audit entry for the tag_history table final Handle handle = dbi.open(); final String tagHistoryString = (String) handle.select("select id from tag_history limit 1").get(0).get("id"); handle.close(); for (final AuditLevel level : AuditLevel.values()) { final List<AuditLog> auditLogs = auditDao.getAuditLogsForId(TableName.TAG_HISTORY, UUID.fromString(tagHistoryString), level, internalCallContext); verifyAuditLogsForTag(auditLogs, level); } }
newCancelEvent.setId(UUID.randomUUID()); final Handle handle = dbi.open(); final SubscriptionEventSqlDao sqlDao = handle.attach(SubscriptionEventSqlDao.class); try {
@Bean(destroyMethod = "close") Handle handle(IDBI dbi) { return dbi.open(); } }
@Override public <SqlObjectType> SqlObjectType open(final Class<SqlObjectType> sqlObjectType) { if (delegate == null) { throw new IllegalStateException("No delegate has been set!"); } return wrapping ? SqlObjectBuilder.open(this, sqlObjectType) : delegate.open(sqlObjectType); }
@Override @Suspendable public Handle open() { return jdbi.open(); }
@Override @Suspendable public <SqlObjectType> SqlObjectType open(Class<SqlObjectType> sqlObjectType) { return jdbi.open(sqlObjectType); }
@Override public Handle open() { return augmentHandle(delegate.open()); }
@Override public Handle getHandle() { if (threadDing.get() == null) { threadDing.set(new LocalDing(dbi.open())); } return threadDing.get().getHandle(); }
public Handle getHandle() { if (threadDing.get() == null) { threadDing.set(new LocalDing(dbi.open())); } return threadDing.get().getHandle(); }
@BeforeMethod public void setup() { dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime()); dummyHandle = dbi.open(); dao = dbi.onDemand(TestingShardDao.class); createTablesWithRetry(dbi); }
@BeforeMethod public void setup() { IDBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime()); dummyHandle = dbi.open(); dao = dbi.onDemand(MetadataDao.class); createTablesWithRetry(dbi); }
@BeforeMethod public void setup() { dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime()); dummyHandle = dbi.open(); createTablesWithRetry(dbi); shardManager = createShardManager(dbi); dataDir = createTempDir(); storageService = new FileStorageService(dataDir); storageService.start(); }
@Test(groups = "slow") public void testRetrieveAuditsDirectly() throws Exception { addTag(); // Verify we get an audit entry for the tag_history table final Handle handle = dbi.open(); final String tagHistoryString = (String) handle.select("select id from tag_history limit 1").get(0).get("id"); handle.close(); for (final AuditLevel level : AuditLevel.values()) { final List<AuditLog> auditLogs = auditDao.getAuditLogsForId(TableName.TAG_HISTORY, UUID.fromString(tagHistoryString), level, internalCallContext); verifyAuditLogsForTag(auditLogs, level); } }
@Test(groups = "slow") public void testRetrieveAuditsDirectly() throws Exception { addTag(); // Verify we get an audit entry for the tag_history table final Handle handle = dbi.open(); final String tagHistoryString = (String) handle.select("select id from tag_history limit 1").get(0).get("id"); handle.close(); for (final AuditLevel level : AuditLevel.values()) { final List<AuditLog> auditLogs = auditDao.getAuditLogsForId(TableName.TAG_HISTORY, UUID.fromString(tagHistoryString), level, internalCallContext); verifyAuditLogsForTag(auditLogs, level); } }