### Question:
FolderSnapshotService { public FolderSnapshot findFolderSnapshot(UserDataRequest udr, FolderSyncKey folderSyncKey) { try { if (folderSyncKey.isInitialFolderSync()) { return FolderSnapshot.empty(); } return folderSnapshotDao.get(udr.getUser(), udr.getDevice(), folderSyncKey); } catch (FolderSnapshotNotFoundException e) { throw new InvalidFolderSyncKeyException(folderSyncKey, e); } } @Inject protected  FolderSnapshotService(FolderSnapshotDao folderSnapshotDao); FolderSnapshot findFolderSnapshot(UserDataRequest udr, FolderSyncKey folderSyncKey); FolderSnapshot snapshot(UserDataRequest udr, FolderSyncKey outgoingSyncKey,
			FolderSnapshot knownSnapshot, BackendFolders currentFolders); CollectionId createSnapshotAddingFolder(UserDataRequest udr, FolderSyncKey outgoingSyncKey,
			FolderSnapshot knownSnapshot, BackendFolder backendFolder); HierarchyCollectionChanges buildDiff(final FolderSnapshot knownSnapshot, final FolderSnapshot currentSnapshot);  }### Answer:
@Test public void findFolderSnapshotShouldReturnEmptyWhenInitialSyncKey() { FolderSyncKey key = FolderSyncKey.INITIAL_FOLDER_SYNC_KEY; mocks.replay(); assertThat(testee.findFolderSnapshot(udr, key)).isEqualTo(FolderSnapshot.empty()); mocks.verify(); }
@Test public void findFolderSnapshotShouldReturnFromDaoWhenFound() throws Exception { FolderSyncKey key = new FolderSyncKey("1234"); FolderSnapshot snapshot = FolderSnapshot.nextId(34).folders(ImmutableSet.<Folder>of()); expect(folderSnapshotDao.get(user, device, key)).andReturn(snapshot); mocks.replay(); assertThat(testee.findFolderSnapshot(udr, key)).isEqualTo(snapshot); mocks.verify(); }
@Test(expected=InvalidFolderSyncKeyException.class) public void findFolderSnapshotShouldTriggerInvalidSyncKeyWhenNotFound() throws Exception { FolderSyncKey key = new FolderSyncKey("1234"); expect(folderSnapshotDao.get(user, device, key)).andThrow(new FolderSnapshotNotFoundException()); mocks.replay(); try { testee.findFolderSnapshot(udr, key); } finally { mocks.verify(); } }
@Test(expected=DaoException.class) public void findFolderSnapshotShouldPropagateWhenOtherException() throws Exception { FolderSyncKey key = new FolderSyncKey("1234"); expect(folderSnapshotDao.get(user, device, key)).andThrow(new DaoException("message")); mocks.replay(); try { testee.findFolderSnapshot(udr, key); } finally { mocks.verify(); } }