DbStorage extends AbstractIdleService implements Storage { @Timed("db_storage_read_operation") @Override @Transactional public <T, E extends Exception> T read(Work<T, E> work) throws StorageException, E { try { return work.apply(storeProvider); } catch (PersistenceException e) { throw new StorageException(e.getMessage(), e); } } @Inject  DbStorage(
      SqlSessionFactory sessionFactory,
      EnumValueMapper enumValueMapper,
      @AsyncExecutor GatedWorkQueue gatedWorkQueue,
      final CronJobStore.Mutable cronJobStore,
      final TaskStore.Mutable taskStore,
      final SchedulerStore.Mutable schedulerStore,
      final AttributeStore.Mutable attributeStore,
      final LockStore.Mutable lockStore,
      final QuotaStore.Mutable quotaStore,
      final JobUpdateStore.Mutable jobUpdateStore,
      StatsProvider statsProvider); @Timed("db_storage_read_operation") @Override @Transactional T read(Work<T, E> work); @Timed("db_storage_write_operation") @Override T write(MutateWork<T, E> work); @Override void prepare();  }
@Test(expected = StorageException.class) public void testReadFails() { expect(readWork.apply(EasyMock.anyObject())) .andThrow(new PersistenceException()); control.replay(); storage.read(readWork); }
@Test public void testRead() { expect(readWork.apply(EasyMock.anyObject())).andReturn("hi"); control.replay(); assertEquals("hi", storage.read(readWork)); }