From e437c14d7237bf3caa6c5f475466087b80949fb0 Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Fri, 12 Jan 2018 16:21:56 +0000 Subject: [PATCH] Refactor ResourceFetcherTest --- .../data/model/ResourceFetcherTest.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcherTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcherTest.java index 488b861253..9ee9282c44 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcherTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcherTest.java @@ -1,7 +1,5 @@ package uk.ac.ic.wlgitbridge.data.model; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.storage.file.FileRepositoryBuilder; import org.jmock.Expectations; import org.jmock.Mockery; import org.junit.Rule; @@ -10,11 +8,14 @@ import org.junit.rules.TemporaryFolder; import org.mockserver.client.server.MockServerClient; import org.mockserver.junit.MockServerRule; import uk.ac.ic.wlgitbridge.bridge.db.DBStore; +import uk.ac.ic.wlgitbridge.bridge.repo.FSGitRepoStore; +import uk.ac.ic.wlgitbridge.bridge.repo.GitProjectRepo; +import uk.ac.ic.wlgitbridge.bridge.repo.ProjectRepo; +import uk.ac.ic.wlgitbridge.bridge.repo.RepoStore; import uk.ac.ic.wlgitbridge.bridge.resource.ResourceCache; import uk.ac.ic.wlgitbridge.bridge.resource.UrlResourceCache; import uk.ac.ic.wlgitbridge.data.filestore.RawFile; import uk.ac.ic.wlgitbridge.git.exception.GitUserException; -import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker; import java.io.IOException; import java.util.HashMap; @@ -65,12 +66,15 @@ public class ResourceFetcherTest { ResourceCache resources = new UrlResourceCache(dbStore); TemporaryFolder repositoryFolder = new TemporaryFolder(); repositoryFolder.create(); - Repository repository = new FileRepositoryBuilder().setWorkTree(repositoryFolder.getRoot()).build(); - Map fileTable = new RepositoryObjectTreeWalker(repository).getDirectoryContents().getFileTable(); + String repoStorePath = repositoryFolder.getRoot().getAbsolutePath(); + RepoStore repoStore = new FSGitRepoStore(repoStorePath); + ProjectRepo repo = new GitProjectRepo("repo"); + repo.initRepo(repoStore); + Map fileTable = repo.getFiles(); Map fetchedUrls = new HashMap(); resources.get(testProjectName, testUrl, newTestPath, fileTable, fetchedUrls); // We don't bother caching in this case, at present. assertEquals(0, fetchedUrls.size()); } -} \ No newline at end of file +}