From 229ed1c09d05b1c2903653e11d3f6cefced3d5cb Mon Sep 17 00:00:00 2001 From: Marc Egea i Sala Date: Fri, 20 Nov 2015 15:15:42 +0000 Subject: [PATCH 1/6] Try to download file if it's not in the git tree --- services/git-bridge/pom.xml | 5 + .../ic/wlgitbridge/data/model/DataStore.java | 3 +- .../data/model/ResourceFetcher.java | 10 +- .../data/model/db/PersistentStore.java | 68 ++------------ .../data/model/db/SqlitePersistentStore.java | 78 ++++++++++++++++ .../data/model/ResourceFetcherTest.java | 91 +++++++++++++++++++ services/git-bridge/writelatex-git-bridge.iml | 38 ++++++++ 7 files changed, 230 insertions(+), 63 deletions(-) create mode 100644 services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/SqlitePersistentStore.java create mode 100644 services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcherTest.java diff --git a/services/git-bridge/pom.xml b/services/git-bridge/pom.xml index 9377b85d79..56cd2d96a4 100644 --- a/services/git-bridge/pom.xml +++ b/services/git-bridge/pom.xml @@ -102,6 +102,11 @@ joda-time 2.7 + + org.mock-server + mockserver-netty + 3.10.1 + \ No newline at end of file diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/DataStore.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/DataStore.java index f81b4ddfdb..f9f217dd7d 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/DataStore.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/DataStore.java @@ -10,6 +10,7 @@ import uk.ac.ic.wlgitbridge.data.filestore.GitDirectoryContents; import uk.ac.ic.wlgitbridge.data.filestore.RawDirectory; import uk.ac.ic.wlgitbridge.data.filestore.RawFile; import uk.ac.ic.wlgitbridge.data.model.db.PersistentStore; +import uk.ac.ic.wlgitbridge.data.model.db.SqlitePersistentStore; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotAttachment; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException; @@ -31,7 +32,7 @@ public class DataStore { public DataStore(String rootGitDirectoryPath) { rootGitDirectory = initRootGitDirectory(rootGitDirectoryPath); - persistentStore = new PersistentStore(rootGitDirectory); + persistentStore = new SqlitePersistentStore(rootGitDirectory); List excludedFromDeletion = persistentStore.getProjectNames(); excludedFromDeletion.add(".wlgb"); Util.deleteInDirectoryApartFrom(rootGitDirectory, excludedFromDeletion.toArray(new String[] {})); diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java index 4bc0c277d9..6e31ac9de8 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java @@ -42,9 +42,15 @@ public class ResourceFetcher { if (contents == null) { RawFile rawFile = new RepositoryObjectTreeWalker(repository).getDirectoryContents().getFileTable().get(path); if (rawFile == null) { - throw new IllegalStateException("file was not in the current commit, or the git tree, yet path was not null"); + Util.sout( + "WARNING: " + + "File " + path + " was not in the current commit, or the git tree, yet path was not null. " + + "File url is: " + url + ); + contents = fetch(projectName, url, path); + } else { + contents = rawFile.getContents(); } - contents = rawFile.getContents(); } } return new RepositoryFile(newPath, contents); diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/PersistentStore.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/PersistentStore.java index 310a75f099..59cf8103c2 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/PersistentStore.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/PersistentStore.java @@ -1,72 +1,20 @@ package uk.ac.ic.wlgitbridge.data.model.db; -import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLiteWLDatabase; - -import java.io.File; -import java.sql.SQLException; import java.util.List; /** - * Created by Winston on 19/11/14. + * Created by m on 20/11/15. */ -public class PersistentStore { +public interface PersistentStore { + List getProjectNames(); - private final SQLiteWLDatabase database; + void setLatestVersionForProject(String project, int versionID); - public PersistentStore(File rootGitDirectory) { - try { - database = new SQLiteWLDatabase(rootGitDirectory); - } catch (SQLException e) { - throw new RuntimeException(e); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } + int getLatestVersionForProject(String project); - public List getProjectNames() { - try { - return database.getProjectNames(); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - public void setLatestVersionForProject(String project, int versionID) { - try { - database.setVersionIDForProject(project, versionID); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } + void addURLIndexForProject(String projectName, String url, String path); - public int getLatestVersionForProject(String project) { - try { - return database.getVersionIDForProjectName(project); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - - public void addURLIndexForProject(String projectName, String url, String path) { - try { - database.addURLIndex(projectName, url, path); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - - public void deleteFilesForProject(String project, String... files) { - try { - database.deleteFilesForProject(project, files); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - public String getPathForURLInProject(String projectName, String url) { - try { - return database.getPathForURLInProject(projectName, url); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } + void deleteFilesForProject(String project, String... files); + String getPathForURLInProject(String projectName, String url); } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/SqlitePersistentStore.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/SqlitePersistentStore.java new file mode 100644 index 0000000000..7a56d6111f --- /dev/null +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/SqlitePersistentStore.java @@ -0,0 +1,78 @@ +package uk.ac.ic.wlgitbridge.data.model.db; + +import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLiteWLDatabase; + +import java.io.File; +import java.sql.SQLException; +import java.util.List; + +/** + * Created by Winston on 19/11/14. + */ +public class SqlitePersistentStore implements PersistentStore { + + private final SQLiteWLDatabase database; + + public SqlitePersistentStore(File rootGitDirectory) { + try { + database = new SQLiteWLDatabase(rootGitDirectory); + } catch (SQLException e) { + throw new RuntimeException(e); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + @Override + public List getProjectNames() { + try { + return database.getProjectNames(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + @Override + public void setLatestVersionForProject(String project, int versionID) { + try { + database.setVersionIDForProject(project, versionID); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + @Override + public int getLatestVersionForProject(String project) { + try { + return database.getVersionIDForProjectName(project); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + @Override + public void addURLIndexForProject(String projectName, String url, String path) { + try { + database.addURLIndex(projectName, url, path); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + @Override + public void deleteFilesForProject(String project, String... files) { + try { + database.deleteFilesForProject(project, files); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + @Override + public String getPathForURLInProject(String projectName, String url) { + try { + return database.getPathForURLInProject(projectName, url); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + +} 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 new file mode 100644 index 0000000000..c88cc3712b --- /dev/null +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcherTest.java @@ -0,0 +1,91 @@ +package uk.ac.ic.wlgitbridge.data.model; + +import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.mockserver.model.HttpRequest.request; +import static org.mockserver.model.HttpResponse.response; + +import org.eclipse.jgit.lib.*; +import org.eclipse.jgit.storage.file.FileRepositoryBuilder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.mockserver.client.server.MockServerClient; +import org.mockserver.junit.MockServerRule; +import uk.ac.ic.wlgitbridge.data.model.db.PersistentStore; + + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by m on 20/11/15. + */ +public class ResourceFetcherTest { + @Rule + public MockServerRule mockServerRule = new MockServerRule(this); + + private MockServerClient mockServerClient; + + @Test + public void fetchesFilesThatAreMissingFromUrlStoreCache() throws IOException { + final String testProjectName = "123abc"; + final String testUrl = "http://localhost:" + mockServerRule.getHttpPort() + "/123abc"; + + mockServerClient.when( + request() + .withMethod("GET") + .withPath("/123abc") + ) + .respond( + response() + .withStatusCode(200) + .withBody("content") + ); + + final PersistentStore persistentStore = new PersistentStore() { + @Override + public List getProjectNames() { + return null; + } + + @Override + public void setLatestVersionForProject(String project, int versionID) { + + } + + @Override + public int getLatestVersionForProject(String project) { + return 0; + } + + @Override + public void addURLIndexForProject(String projectName, String url, String path) { + + } + + @Override + public void deleteFilesForProject(String project, String... files) { + + } + + @Override + public String getPathForURLInProject(String projectName, String url) { + assertEquals(testProjectName, projectName); + assertEquals(testUrl, url); + return "missingPath"; + } + }; + + ResourceFetcher resourceFetcher = new ResourceFetcher(persistentStore); + TemporaryFolder repositoryFolder = new TemporaryFolder(); + repositoryFolder.create(); + Repository repository = new FileRepositoryBuilder().setWorkTree(repositoryFolder.getRoot()).build(); + Map fetchedUrls = new HashMap(); + resourceFetcher.get(testProjectName, testUrl, "testPath", repository, fetchedUrls); + // public RawFile get(String projectName, String url, String newPath, Repository repository, Map fetchedUrls) throws IOException { + + } +} \ No newline at end of file diff --git a/services/git-bridge/writelatex-git-bridge.iml b/services/git-bridge/writelatex-git-bridge.iml index 2b9d1d4a93..9352c43918 100644 --- a/services/git-bridge/writelatex-git-bridge.iml +++ b/services/git-bridge/writelatex-git-bridge.iml @@ -44,5 +44,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 6a25132f0c2b27a7bdd0bf57814e93750b334486 Mon Sep 17 00:00:00 2001 From: Marc Egea i Sala Date: Mon, 23 Nov 2015 12:30:46 +0000 Subject: [PATCH 2/6] InteliJ IDEA project library files --- .../Maven__ch_qos_logback_logback_classic_1_1_3.xml | 13 +++++++++++++ .../Maven__ch_qos_logback_logback_core_1_1_3.xml | 13 +++++++++++++ ...erxml_jackson_core_jackson_annotations_2_5_3.xml | 13 +++++++++++++ ...om_fasterxml_jackson_core_jackson_core_2_5_3.xml | 13 +++++++++++++ ...asterxml_jackson_core_jackson_databind_2_5_3.xml | 13 +++++++++++++ .../libraries/Maven__com_github_fge_btf_1_2.xml | 13 +++++++++++++ .../Maven__com_github_fge_jackson_coreutils_1_8.xml | 13 +++++++++++++ ...Maven__com_github_fge_json_schema_core_1_2_5.xml | 13 +++++++++++++ ...__com_github_fge_json_schema_validator_2_2_6.xml | 13 +++++++++++++ .../Maven__com_github_fge_msg_simple_1_1.xml | 13 +++++++++++++ .../Maven__com_github_fge_uri_template_0_9.xml | 13 +++++++++++++ ...Maven__com_google_code_findbugs_jsr305_3_0_0.xml | 13 +++++++++++++ .../Maven__com_google_guava_guava_18_0.xml | 13 +++++++++++++ ...googlecode_libphonenumber_libphonenumber_6_2.xml | 13 +++++++++++++ .../libraries/Maven__com_jcraft_jzlib_1_1_3.xml | 13 +++++++++++++ .../Maven__commons_io_commons_io_1_3_2.xml | 13 +++++++++++++ .../Maven__io_netty_netty_buffer_4_0_31_Final.xml | 13 +++++++++++++ .../Maven__io_netty_netty_codec_4_0_31_Final.xml | 13 +++++++++++++ ...aven__io_netty_netty_codec_http_4_0_31_Final.xml | 13 +++++++++++++ ...ven__io_netty_netty_codec_socks_4_0_31_Final.xml | 13 +++++++++++++ .../Maven__io_netty_netty_common_4_0_31_Final.xml | 13 +++++++++++++ .../Maven__io_netty_netty_handler_4_0_31_Final.xml | 13 +++++++++++++ ...Maven__io_netty_netty_transport_4_0_31_Final.xml | 13 +++++++++++++ .../.idea/libraries/Maven__janino_janino_2_5_10.xml | 13 +++++++++++++ .../Maven__javax_activation_activation_1_1.xml | 13 +++++++++++++ .../libraries/Maven__javax_mail_mailapi_1_4_3.xml | 13 +++++++++++++ .../Maven__net_sf_jopt_simple_jopt_simple_4_6.xml | 13 +++++++++++++ .../Maven__org_apache_commons_commons_lang3_3_4.xml | 13 +++++++++++++ .../Maven__org_bouncycastle_bcmail_jdk15on_1_52.xml | 13 +++++++++++++ .../Maven__org_bouncycastle_bcpkix_jdk15on_1_52.xml | 13 +++++++++++++ .../Maven__org_bouncycastle_bcprov_jdk15on_1_52.xml | 13 +++++++++++++ .../libraries/Maven__org_json_json_20090211.xml | 13 +++++++++++++ ...rg_mock_server_mockserver_client_java_3_10_1.xml | 13 +++++++++++++ ...aven__org_mock_server_mockserver_core_3_10_1.xml | 13 +++++++++++++ ...n__org_mock_server_mockserver_logging_3_10_1.xml | 13 +++++++++++++ ...ven__org_mock_server_mockserver_netty_3_10_1.xml | 13 +++++++++++++ .../libraries/Maven__org_mozilla_rhino_1_7R4.xml | 13 +++++++++++++ .../Maven__org_skyscreamer_jsonassert_1_2_3.xml | 13 +++++++++++++ 38 files changed, 494 insertions(+) create mode 100644 services/git-bridge/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_3.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_3.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_5_3.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_5_3.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_5_3.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_github_fge_btf_1_2.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_github_fge_jackson_coreutils_1_8.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_github_fge_json_schema_core_1_2_5.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_github_fge_json_schema_validator_2_2_6.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_github_fge_msg_simple_1_1.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_github_fge_uri_template_0_9.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_0.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_google_guava_guava_18_0.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_googlecode_libphonenumber_libphonenumber_6_2.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__com_jcraft_jzlib_1_1_3.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__io_netty_netty_buffer_4_0_31_Final.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_4_0_31_Final.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_http_4_0_31_Final.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_socks_4_0_31_Final.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__io_netty_netty_common_4_0_31_Final.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__io_netty_netty_handler_4_0_31_Final.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__io_netty_netty_transport_4_0_31_Final.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__janino_janino_2_5_10.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__javax_activation_activation_1_1.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__javax_mail_mailapi_1_4_3.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__net_sf_jopt_simple_jopt_simple_4_6.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_4.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcmail_jdk15on_1_52.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_52.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcprov_jdk15on_1_52.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_json_json_20090211.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_client_java_3_10_1.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_core_3_10_1.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_logging_3_10_1.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_netty_3_10_1.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_mozilla_rhino_1_7R4.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_2_3.xml diff --git a/services/git-bridge/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_3.xml b/services/git-bridge/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_3.xml new file mode 100644 index 0000000000..6c9fc331cf --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_3.xml b/services/git-bridge/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_3.xml new file mode 100644 index 0000000000..fd35ca4525 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_5_3.xml b/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_5_3.xml new file mode 100644 index 0000000000..e59fa72af0 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_5_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_5_3.xml b/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_5_3.xml new file mode 100644 index 0000000000..186af6a4d6 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_5_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_5_3.xml b/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_5_3.xml new file mode 100644 index 0000000000..3b579b5203 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_5_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_github_fge_btf_1_2.xml b/services/git-bridge/.idea/libraries/Maven__com_github_fge_btf_1_2.xml new file mode 100644 index 0000000000..be485ed5dc --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_github_fge_btf_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_github_fge_jackson_coreutils_1_8.xml b/services/git-bridge/.idea/libraries/Maven__com_github_fge_jackson_coreutils_1_8.xml new file mode 100644 index 0000000000..b28d54b463 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_github_fge_jackson_coreutils_1_8.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_github_fge_json_schema_core_1_2_5.xml b/services/git-bridge/.idea/libraries/Maven__com_github_fge_json_schema_core_1_2_5.xml new file mode 100644 index 0000000000..6faeec933b --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_github_fge_json_schema_core_1_2_5.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_github_fge_json_schema_validator_2_2_6.xml b/services/git-bridge/.idea/libraries/Maven__com_github_fge_json_schema_validator_2_2_6.xml new file mode 100644 index 0000000000..6deb5e3fe5 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_github_fge_json_schema_validator_2_2_6.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_github_fge_msg_simple_1_1.xml b/services/git-bridge/.idea/libraries/Maven__com_github_fge_msg_simple_1_1.xml new file mode 100644 index 0000000000..0fefc8c94c --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_github_fge_msg_simple_1_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_github_fge_uri_template_0_9.xml b/services/git-bridge/.idea/libraries/Maven__com_github_fge_uri_template_0_9.xml new file mode 100644 index 0000000000..de219cb9c1 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_github_fge_uri_template_0_9.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_0.xml b/services/git-bridge/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_0.xml new file mode 100644 index 0000000000..6644d12ef8 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_google_guava_guava_18_0.xml b/services/git-bridge/.idea/libraries/Maven__com_google_guava_guava_18_0.xml new file mode 100644 index 0000000000..bbd71d77e9 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_google_guava_guava_18_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_googlecode_libphonenumber_libphonenumber_6_2.xml b/services/git-bridge/.idea/libraries/Maven__com_googlecode_libphonenumber_libphonenumber_6_2.xml new file mode 100644 index 0000000000..9e81cf42b5 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_googlecode_libphonenumber_libphonenumber_6_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__com_jcraft_jzlib_1_1_3.xml b/services/git-bridge/.idea/libraries/Maven__com_jcraft_jzlib_1_1_3.xml new file mode 100644 index 0000000000..897f365a3f --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__com_jcraft_jzlib_1_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml b/services/git-bridge/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml new file mode 100644 index 0000000000..7b5b3b7580 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__io_netty_netty_buffer_4_0_31_Final.xml b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_buffer_4_0_31_Final.xml new file mode 100644 index 0000000000..9fcfff811e --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_buffer_4_0_31_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_4_0_31_Final.xml b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_4_0_31_Final.xml new file mode 100644 index 0000000000..05d2d1330b --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_4_0_31_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_http_4_0_31_Final.xml b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_http_4_0_31_Final.xml new file mode 100644 index 0000000000..31741c0f5c --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_http_4_0_31_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_socks_4_0_31_Final.xml b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_socks_4_0_31_Final.xml new file mode 100644 index 0000000000..7623350309 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_codec_socks_4_0_31_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__io_netty_netty_common_4_0_31_Final.xml b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_common_4_0_31_Final.xml new file mode 100644 index 0000000000..35e0542627 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_common_4_0_31_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__io_netty_netty_handler_4_0_31_Final.xml b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_handler_4_0_31_Final.xml new file mode 100644 index 0000000000..f74684fc17 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_handler_4_0_31_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__io_netty_netty_transport_4_0_31_Final.xml b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_transport_4_0_31_Final.xml new file mode 100644 index 0000000000..2fccd23dbb --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__io_netty_netty_transport_4_0_31_Final.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__janino_janino_2_5_10.xml b/services/git-bridge/.idea/libraries/Maven__janino_janino_2_5_10.xml new file mode 100644 index 0000000000..7f72f578c9 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__janino_janino_2_5_10.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__javax_activation_activation_1_1.xml b/services/git-bridge/.idea/libraries/Maven__javax_activation_activation_1_1.xml new file mode 100644 index 0000000000..180d587561 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__javax_activation_activation_1_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__javax_mail_mailapi_1_4_3.xml b/services/git-bridge/.idea/libraries/Maven__javax_mail_mailapi_1_4_3.xml new file mode 100644 index 0000000000..74617052b5 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__javax_mail_mailapi_1_4_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__net_sf_jopt_simple_jopt_simple_4_6.xml b/services/git-bridge/.idea/libraries/Maven__net_sf_jopt_simple_jopt_simple_4_6.xml new file mode 100644 index 0000000000..18ea23b96c --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__net_sf_jopt_simple_jopt_simple_4_6.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_4.xml b/services/git-bridge/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_4.xml new file mode 100644 index 0000000000..78cfcd37a1 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcmail_jdk15on_1_52.xml b/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcmail_jdk15on_1_52.xml new file mode 100644 index 0000000000..cc4ce0a512 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcmail_jdk15on_1_52.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_52.xml b/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_52.xml new file mode 100644 index 0000000000..cfcf4f2c1c --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_52.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcprov_jdk15on_1_52.xml b/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcprov_jdk15on_1_52.xml new file mode 100644 index 0000000000..4b942f167a --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_bouncycastle_bcprov_jdk15on_1_52.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_json_json_20090211.xml b/services/git-bridge/.idea/libraries/Maven__org_json_json_20090211.xml new file mode 100644 index 0000000000..e57dc0ae98 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_json_json_20090211.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_client_java_3_10_1.xml b/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_client_java_3_10_1.xml new file mode 100644 index 0000000000..2162d5effc --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_client_java_3_10_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_core_3_10_1.xml b/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_core_3_10_1.xml new file mode 100644 index 0000000000..e898afa710 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_core_3_10_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_logging_3_10_1.xml b/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_logging_3_10_1.xml new file mode 100644 index 0000000000..cd8560af6c --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_logging_3_10_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_netty_3_10_1.xml b/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_netty_3_10_1.xml new file mode 100644 index 0000000000..42398ab9b9 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_mock_server_mockserver_netty_3_10_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_mozilla_rhino_1_7R4.xml b/services/git-bridge/.idea/libraries/Maven__org_mozilla_rhino_1_7R4.xml new file mode 100644 index 0000000000..82eb241284 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_mozilla_rhino_1_7R4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_2_3.xml b/services/git-bridge/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_2_3.xml new file mode 100644 index 0000000000..ed116b8a15 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file From 624c3e6af1bb2ae8d4631060ed47bee6d338d26c Mon Sep 17 00:00:00 2001 From: John Lees-Miller Date: Tue, 24 Nov 2015 12:05:24 +0000 Subject: [PATCH 3/6] update to junit 4.12 to get jmock working Also moved junit to the test scope. --- .../Maven__cglib_cglib_nodep_2_1_3.xml | 13 --- .../libraries/Maven__junit_junit_4_10.xml | 13 --- .../libraries/Maven__junit_junit_4_12.xml | 13 +++ ...Maven__org_hamcrest_hamcrest_core_1_3.xml} | 8 +- .../Maven__org_jmock_jmock_legacy_2_6_0.xml | 13 --- .../Maven__org_objenesis_objenesis_1_0.xml | 13 --- services/git-bridge/pom.xml | 9 +- services/git-bridge/writelatex-git-bridge.iml | 91 +++++++++---------- 8 files changed, 64 insertions(+), 109 deletions(-) delete mode 100644 services/git-bridge/.idea/libraries/Maven__cglib_cglib_nodep_2_1_3.xml delete mode 100644 services/git-bridge/.idea/libraries/Maven__junit_junit_4_10.xml create mode 100644 services/git-bridge/.idea/libraries/Maven__junit_junit_4_12.xml rename services/git-bridge/.idea/libraries/{Maven__org_hamcrest_hamcrest_core_1_1.xml => Maven__org_hamcrest_hamcrest_core_1_3.xml} (64%) delete mode 100644 services/git-bridge/.idea/libraries/Maven__org_jmock_jmock_legacy_2_6_0.xml delete mode 100644 services/git-bridge/.idea/libraries/Maven__org_objenesis_objenesis_1_0.xml diff --git a/services/git-bridge/.idea/libraries/Maven__cglib_cglib_nodep_2_1_3.xml b/services/git-bridge/.idea/libraries/Maven__cglib_cglib_nodep_2_1_3.xml deleted file mode 100644 index 55692b94d6..0000000000 --- a/services/git-bridge/.idea/libraries/Maven__cglib_cglib_nodep_2_1_3.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__junit_junit_4_10.xml b/services/git-bridge/.idea/libraries/Maven__junit_junit_4_10.xml deleted file mode 100644 index ed8bf5fe7f..0000000000 --- a/services/git-bridge/.idea/libraries/Maven__junit_junit_4_10.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__junit_junit_4_12.xml b/services/git-bridge/.idea/libraries/Maven__junit_junit_4_12.xml new file mode 100644 index 0000000000..d411041745 --- /dev/null +++ b/services/git-bridge/.idea/libraries/Maven__junit_junit_4_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml b/services/git-bridge/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml similarity index 64% rename from services/git-bridge/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml rename to services/git-bridge/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml index acdf44300b..f58bbc1127 100644 --- a/services/git-bridge/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml +++ b/services/git-bridge/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_jmock_jmock_legacy_2_6_0.xml b/services/git-bridge/.idea/libraries/Maven__org_jmock_jmock_legacy_2_6_0.xml deleted file mode 100644 index d1371a2a99..0000000000 --- a/services/git-bridge/.idea/libraries/Maven__org_jmock_jmock_legacy_2_6_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/services/git-bridge/.idea/libraries/Maven__org_objenesis_objenesis_1_0.xml b/services/git-bridge/.idea/libraries/Maven__org_objenesis_objenesis_1_0.xml deleted file mode 100644 index c79fa27d22..0000000000 --- a/services/git-bridge/.idea/libraries/Maven__org_objenesis_objenesis_1_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/services/git-bridge/pom.xml b/services/git-bridge/pom.xml index 56cd2d96a4..c403314a66 100644 --- a/services/git-bridge/pom.xml +++ b/services/git-bridge/pom.xml @@ -49,18 +49,14 @@ junit junit - 4.10 + 4.12 test org.jmock jmock-junit4 2.6.0 - - - org.jmock - jmock-legacy - 2.6.0 + test org.eclipse.jetty.aggregate @@ -106,6 +102,7 @@ org.mock-server mockserver-netty 3.10.1 + test diff --git a/services/git-bridge/writelatex-git-bridge.iml b/services/git-bridge/writelatex-git-bridge.iml index 9352c43918..8ffc696701 100644 --- a/services/git-bridge/writelatex-git-bridge.iml +++ b/services/git-bridge/writelatex-git-bridge.iml @@ -17,15 +17,12 @@ - - - - - - - - - + + + + + + @@ -44,43 +41,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 62749a0dabb7b2ff302302386b5cbdb4cd14ec56 Mon Sep 17 00:00:00 2001 From: John Lees-Miller Date: Tue, 24 Nov 2015 12:05:54 +0000 Subject: [PATCH 4/6] update to IDEA 15 --- services/git-bridge/.idea/compiler.xml | 5 ++--- services/git-bridge/.idea/encodings.xml | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/services/git-bridge/.idea/compiler.xml b/services/git-bridge/.idea/compiler.xml index 8d3613cc8b..0ad16f8d1b 100644 --- a/services/git-bridge/.idea/compiler.xml +++ b/services/git-bridge/.idea/compiler.xml @@ -17,7 +17,7 @@ - + @@ -29,5 +29,4 @@ - - + \ No newline at end of file diff --git a/services/git-bridge/.idea/encodings.xml b/services/git-bridge/.idea/encodings.xml index 74c0d0a52b..8ffd759b0f 100644 --- a/services/git-bridge/.idea/encodings.xml +++ b/services/git-bridge/.idea/encodings.xml @@ -2,6 +2,6 @@ + - - + \ No newline at end of file From e2574ab1639a0eb7cf4de6a4799e7e0f4417833a Mon Sep 17 00:00:00 2001 From: John Lees-Miller Date: Tue, 24 Nov 2015 12:06:05 +0000 Subject: [PATCH 5/6] fix whitespace --- .../java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java | 1 - 1 file changed, 1 deletion(-) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java index 6e31ac9de8..836bc2f42f 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java @@ -89,5 +89,4 @@ public class ResourceFetcher { persistentStore.addURLIndexForProject(projectName, url, path); return contents; } - } From 318e11deeb035a89566bc1504a590483f21a594a Mon Sep 17 00:00:00 2001 From: John Lees-Miller Date: Tue, 24 Nov 2015 12:06:43 +0000 Subject: [PATCH 6/6] mock the persistent store with jmock --- .../data/model/ResourceFetcherTest.java | 51 +++++++------------ 1 file changed, 17 insertions(+), 34 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 c88cc3712b..66bd4c87db 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 @@ -7,6 +7,9 @@ import static org.mockserver.model.HttpResponse.response; import org.eclipse.jgit.lib.*; import org.eclipse.jgit.storage.file.FileRepositoryBuilder; +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.hamcrest.TypeSafeMatcher; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -33,6 +36,8 @@ public class ResourceFetcherTest { public void fetchesFilesThatAreMissingFromUrlStoreCache() throws IOException { final String testProjectName = "123abc"; final String testUrl = "http://localhost:" + mockServerRule.getHttpPort() + "/123abc"; + final String oldTestPath = "testPath"; + final String newTestPath = "missingPath"; mockServerClient.when( request() @@ -45,47 +50,25 @@ public class ResourceFetcherTest { .withBody("content") ); - final PersistentStore persistentStore = new PersistentStore() { - @Override - public List getProjectNames() { - return null; - } + final Mockery context = new Mockery(); + final PersistentStore persistentStore = context.mock(PersistentStore.class); + context.checking(new Expectations() {{ + // It should fetch the file once it finds it is missing. + oneOf(persistentStore).getPathForURLInProject(testProjectName, testUrl); + will(returnValue(oldTestPath)); - @Override - public void setLatestVersionForProject(String project, int versionID) { - - } - - @Override - public int getLatestVersionForProject(String project) { - return 0; - } - - @Override - public void addURLIndexForProject(String projectName, String url, String path) { - - } - - @Override - public void deleteFilesForProject(String project, String... files) { - - } - - @Override - public String getPathForURLInProject(String projectName, String url) { - assertEquals(testProjectName, projectName); - assertEquals(testUrl, url); - return "missingPath"; - } - }; + // It should update the URL index store once it has fetched; at present, it does not actually change the stored path. + oneOf(persistentStore).addURLIndexForProject(testProjectName, testUrl, oldTestPath); + }}); ResourceFetcher resourceFetcher = new ResourceFetcher(persistentStore); TemporaryFolder repositoryFolder = new TemporaryFolder(); repositoryFolder.create(); Repository repository = new FileRepositoryBuilder().setWorkTree(repositoryFolder.getRoot()).build(); Map fetchedUrls = new HashMap(); - resourceFetcher.get(testProjectName, testUrl, "testPath", repository, fetchedUrls); - // public RawFile get(String projectName, String url, String newPath, Repository repository, Map fetchedUrls) throws IOException { + resourceFetcher.get(testProjectName, testUrl, newTestPath, repository, fetchedUrls); + // We don't bother caching in this case, at present. + assertEquals(0, fetchedUrls.size()); } } \ No newline at end of file