// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/RepoStore.java
// public interface RepoStore {
// 
//     /* Still need to get rid of these two methods.
//        Main dependency: GitRepoStore needs a Repository which needs a directory.
//        Instead, use a visitor or something. */
//     String getRepoStorePath();
// 
//     File getRootDirectory();
// 
//     ProjectRepo initRepo(String project) throws IOException;
// 
//     ProjectRepo getExistingRepo(String project) throws IOException;
// 
//     ProjectRepo useJGitRepo(Repository repo, ObjectId commitId);
// 
//     void purgeNonexistentProjects(
//             Collection<String> existingProjectNames
//     );
// 
//     long totalSize();
// 
//     /**
//      * Tars and bzip2s the .git directory of the given project. Throws an
//      * IOException if the project doesn't exist. The returned stream is a copy
//      * of the original .git directory, which must be deleted using remove().
//      */
//     InputStream bzip2Project(
//             String projectName,
//             long[] sizePtr
//     ) throws IOException;
// 
//     default InputStream bzip2Project(
//             String projectName
//     ) throws IOException {
//         return bzip2Project(projectName, null);
//     }
// 
//     /**
//      * Called after {@link #bzip2Project(String, long[])}'s has been safely
//      * uploaded to the swap store. Removes all traces of the project from disk,
//      * i.e. not just its .git, but the whole project's git directory.
//      * @param projectName
//      * @throws IOException
//      */
//     void remove(String projectName) throws IOException;
// 
//     /**
//      * Unbzip2s the given data stream into a .git directory for projectName.
//      * Creates the project's git directory.
//      * If projectName already exists, throws an IOException.
//      * @param projectName the name of the project, e.g. abc123
//      * @param dataStream the data stream containing the bzipped contents.
//      */
//     void unbzip2Project(
//             String projectName,
//             InputStream dataStream
//     ) throws IOException;
// 
// }
// 
// Path: src/main/java/uk/ac/ic/wlgitbridge/data/ProjectLockImpl.java
// public class ProjectLockImpl implements ProjectLock {
// 
//     private final Map<String, Lock> projectLocks;
//     private final ReentrantReadWriteLock rwlock;
//     private final Lock rlock;
//     private final ReentrantReadWriteLock.WriteLock wlock;
//     private LockAllWaiter waiter;
//     private boolean waiting;
// 
//     public ProjectLockImpl() {
//         projectLocks = new HashMap<String, Lock>();
//         rwlock = new ReentrantReadWriteLock();
//         rlock = rwlock.readLock();
//         wlock = rwlock.writeLock();
//         waiting = false;
//     }
// 
//     public ProjectLockImpl(LockAllWaiter waiter) {
//         this();
//         setWaiter(waiter);
//     }
// 
//     @Override
//     public void lockForProject(String projectName) {
//         getLockForProjectName(projectName).lock();
//         rlock.lock();
//     }
// 
//     @Override
//     public void unlockForProject(String projectName) {
//         getLockForProjectName(projectName).unlock();
//         rlock.unlock();
//         if (waiting) {
//             trySignal();
//         }
//     }
// 
//     private void trySignal() {
//         int threads = rwlock.getReadLockCount();
//         if (waiter != null && threads > 0) {
//             waiter.threadsRemaining(threads);
//         }
//     }
// 
//     public void lockAll() {
//         waiting = true;
//         trySignal();
//         wlock.lock();
//     }
// 
//     private synchronized Lock getLockForProjectName(String projectName) {
//         Lock lock = projectLocks.get(projectName);
//         if (lock == null) {
//             lock = new ReentrantLock();
//             projectLocks.put(projectName, lock);
//         }
//         return lock;
//     }
// 
//     public void setWaiter(LockAllWaiter waiter) {
//         this.waiter = waiter;
//     }
// 
// }


import org.junit.Test;
import org.mockito.stubbing.OngoingStubbing;
import uk.ac.ic.wlgitbridge.bridge.lock.LockGuard;
import uk.ac.ic.wlgitbridge.bridge.lock.ProjectLock;
import uk.ac.ic.wlgitbridge.bridge.repo.ProjectRepo;
import uk.ac.ic.wlgitbridge.bridge.repo.RepoStore;
import uk.ac.ic.wlgitbridge.data.ProjectLockImpl;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.*;
package uk.ac.ic.wlgitbridge.bridge.gc;




/**
 * Created by winston on 16/02/2017.
 */
public class GcJobImplTest {

    RepoStore repoStore = mock(RepoStore.class);

// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/RepoStore.java
// public interface RepoStore {
// 
//     /* Still need to get rid of these two methods.
//        Main dependency: GitRepoStore needs a Repository which needs a directory.
//        Instead, use a visitor or something. */
//     String getRepoStorePath();
// 
//     File getRootDirectory();
// 
//     ProjectRepo initRepo(String project) throws IOException;
// 
//     ProjectRepo getExistingRepo(String project) throws IOException;
// 
//     ProjectRepo useJGitRepo(Repository repo, ObjectId commitId);
// 
//     void purgeNonexistentProjects(
//             Collection<String> existingProjectNames
//     );
// 
//     long totalSize();
// 
//     /**
//      * Tars and bzip2s the .git directory of the given project. Throws an
//      * IOException if the project doesn't exist. The returned stream is a copy
//      * of the original .git directory, which must be deleted using remove().
//      */
//     InputStream bzip2Project(
//             String projectName,
//             long[] sizePtr
//     ) throws IOException;
// 
//     default InputStream bzip2Project(
//             String projectName
//     ) throws IOException {
//         return bzip2Project(projectName, null);
//     }
// 
//     /**
//      * Called after {@link #bzip2Project(String, long[])}'s has been safely
//      * uploaded to the swap store. Removes all traces of the project from disk,
//      * i.e. not just its .git, but the whole project's git directory.
//      * @param projectName
//      * @throws IOException
//      */
//     void remove(String projectName) throws IOException;
// 
//     /**
//      * Unbzip2s the given data stream into a .git directory for projectName.
//      * Creates the project's git directory.
//      * If projectName already exists, throws an IOException.
//      * @param projectName the name of the project, e.g. abc123
//      * @param dataStream the data stream containing the bzipped contents.
//      */
//     void unbzip2Project(
//             String projectName,
//             InputStream dataStream
//     ) throws IOException;
// 
// }
// 
// Path: src/main/java/uk/ac/ic/wlgitbridge/data/ProjectLockImpl.java
// public class ProjectLockImpl implements ProjectLock {
// 
//     private final Map<String, Lock> projectLocks;
//     private final ReentrantReadWriteLock rwlock;
//     private final Lock rlock;
//     private final ReentrantReadWriteLock.WriteLock wlock;
//     private LockAllWaiter waiter;
//     private boolean waiting;
// 
//     public ProjectLockImpl() {
//         projectLocks = new HashMap<String, Lock>();
//         rwlock = new ReentrantReadWriteLock();
//         rlock = rwlock.readLock();
//         wlock = rwlock.writeLock();
//         waiting = false;
//     }
// 
//     public ProjectLockImpl(LockAllWaiter waiter) {
//         this();
//         setWaiter(waiter);
//     }
// 
//     @Override
//     public void lockForProject(String projectName) {
//         getLockForProjectName(projectName).lock();
//         rlock.lock();
//     }
// 
//     @Override
//     public void unlockForProject(String projectName) {
//         getLockForProjectName(projectName).unlock();
//         rlock.unlock();
//         if (waiting) {
//             trySignal();
//         }
//     }
// 
//     private void trySignal() {
//         int threads = rwlock.getReadLockCount();
//         if (waiter != null && threads > 0) {
//             waiter.threadsRemaining(threads);
//         }
//     }
// 
//     public void lockAll() {
//         waiting = true;
//         trySignal();
//         wlock.lock();
//     }
// 
//     private synchronized Lock getLockForProjectName(String projectName) {
//         Lock lock = projectLocks.get(projectName);
//         if (lock == null) {
//             lock = new ReentrantLock();
//             projectLocks.put(projectName, lock);
//         }
//         return lock;
//     }
// 
//     public void setWaiter(LockAllWaiter waiter) {
//         this.waiter = waiter;
//     }
// 
// }


// Path: src/test/java/uk/ac/ic/wlgitbridge/bridge/gc/GcJobImplTest.java
import org.junit.Test;
import org.mockito.stubbing.OngoingStubbing;
import uk.ac.ic.wlgitbridge.bridge.lock.LockGuard;
import uk.ac.ic.wlgitbridge.bridge.lock.ProjectLock;
import uk.ac.ic.wlgitbridge.bridge.repo.ProjectRepo;
import uk.ac.ic.wlgitbridge.bridge.repo.RepoStore;
import uk.ac.ic.wlgitbridge.data.ProjectLockImpl;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.*;

package uk.ac.ic.wlgitbridge.bridge.gc;




/**
 * Created by winston on 16/02/2017.
 */
public class GcJobImplTest {

    RepoStore repoStore = mock(RepoStore.class);

    ProjectLock locks = new ProjectLockImpl();