@Test public void testGetLocalAuthor() throws DbException { context.checking(new Expectations() {{ oneOf(db).startTransaction(true); will(returnValue(txn)); oneOf(db).getLocalAuthors(txn); will(returnValue(localAuthors)); oneOf(db).commitTransaction(txn); oneOf(db).endTransaction(txn); }}); assertEquals(localAuthor, identityManager.getLocalAuthor()); }
@Override public LocalAuthor getLocalAuthor() throws DbException { if (cachedAuthor == null) { Transaction txn = db.startTransaction(true); try { cachedAuthor = loadLocalAuthor(txn); LOG.info("Local author loaded"); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } LocalAuthor cached = cachedAuthor; if (cached == null) throw new AssertionError(); return cached; }
IdentityManagerImpl implements IdentityManager { @Override public LocalAuthor getLocalAuthor() throws DbException { if (cachedAuthor == null) { Transaction txn = db.startTransaction(true); try { cachedAuthor = loadLocalAuthor(txn); LOG.info("Local author loaded"); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } LocalAuthor cached = cachedAuthor; if (cached == null) throw new AssertionError(); return cached; } }
IdentityManagerImpl implements IdentityManager { @Override public LocalAuthor getLocalAuthor() throws DbException { if (cachedAuthor == null) { Transaction txn = db.startTransaction(true); try { cachedAuthor = loadLocalAuthor(txn); LOG.info("Local author loaded"); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } LocalAuthor cached = cachedAuthor; if (cached == null) throw new AssertionError(); return cached; } @Inject  IdentityManagerImpl(DatabaseComponent db, CryptoComponent crypto,
			AuthorFactory authorFactory); }
IdentityManagerImpl implements IdentityManager { @Override public LocalAuthor getLocalAuthor() throws DbException { if (cachedAuthor == null) { Transaction txn = db.startTransaction(true); try { cachedAuthor = loadLocalAuthor(txn); LOG.info("Local author loaded"); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } LocalAuthor cached = cachedAuthor; if (cached == null) throw new AssertionError(); return cached; } @Inject  IdentityManagerImpl(DatabaseComponent db, CryptoComponent crypto,
			AuthorFactory authorFactory); @Override LocalAuthor createLocalAuthor(String name); @Override void registerLocalAuthor(LocalAuthor a); @Override void storeLocalAuthor(); @Override LocalAuthor getLocalAuthor(); @Override LocalAuthor getLocalAuthor(Transaction txn); @Override Status getAuthorStatus(AuthorId authorId); @Override Status getAuthorStatus(Transaction txn, AuthorId authorId); }
IdentityManagerImpl implements IdentityManager { @Override public LocalAuthor getLocalAuthor() throws DbException { if (cachedAuthor == null) { Transaction txn = db.startTransaction(true); try { cachedAuthor = loadLocalAuthor(txn); LOG.info("Local author loaded"); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } LocalAuthor cached = cachedAuthor; if (cached == null) throw new AssertionError(); return cached; } @Inject  IdentityManagerImpl(DatabaseComponent db, CryptoComponent crypto,
			AuthorFactory authorFactory); @Override LocalAuthor createLocalAuthor(String name); @Override void registerLocalAuthor(LocalAuthor a); @Override void storeLocalAuthor(); @Override LocalAuthor getLocalAuthor(); @Override LocalAuthor getLocalAuthor(Transaction txn); @Override Status getAuthorStatus(AuthorId authorId); @Override Status getAuthorStatus(Transaction txn, AuthorId authorId);  }