EntryStorage implements ISchedulerEntryStorage { @Override public ISchedulerEntry getEntry(final String id) throws EntryStorageAccessException, EntryNotFoundException { try { ISchedulerEntry localEntry = getLocalEntry(id); if (null != localEntry) { return localEntry; } IObject savedEntryState = remoteEntryStorage.querySingleEntry(id); return IOC.resolve(Keys.getOrAdd("restore scheduler entry"), savedEntryState, this); } catch (ResolutionException e) { throw new EntryStorageAccessException("Error occurred restoring required entry from state saved in remote storage."); } catch (CancelledLocalEntryRequestException e) { throw new EntryNotFoundException("The entry was not found as it was cancelled recently."); } } EntryStorage(final IRemoteEntryStorage remoteEntryStorage, final ISchedulerEntryStorageObserver observer, final ITimer timer);  EntryStorage(final IRemoteEntryStorage remoteEntryStorage, final ISchedulerEntryStorageObserver observer); @Override void save(final ISchedulerEntry entry); @Override void notifyActive(final ISchedulerEntry entry); @Override void notifyInactive(final ISchedulerEntry entry, final boolean keepReference); @Override void delete(final ISchedulerEntry entry); @Override List<ISchedulerEntry> listLocalEntries(); @Override int countLocalEntries(); @Override ISchedulerEntry getEntry(final String id); @Override ITimer getTimer(); @Override ISchedulerEntryFilter getFilter(); @Override void setFilter(final ISchedulerEntryFilter filter); void refresh(final long awakeUntil, final long suspendAfter); ISchedulerEntry getLocalEntry(final String id);  }
@Test public void Should_restoreRemoteEntryWhenItIsRequired() throws Exception { EntryStorage storage = new EntryStorage(remoteEntryStorage, null); assertSame(entries[0], storage.getEntry("0")); }
@Test(expected = EntryNotFoundException.class) public void Should_throwWhenRequiredEntryIsNotFoundInBothRemoteAndLocalStorage() throws Exception { EntryStorage storage = new EntryStorage(remoteEntryStorage, null); assertNull(storage.getEntry("666")); }