From ae5a55747e1f99976d3723e028bcb2ef2fb03aa5 Mon Sep 17 00:00:00 2001 From: Winston Li Date: Wed, 12 Nov 2014 11:54:09 +0000 Subject: [PATCH] Refactored test package names and added FileIndexStore and BlobHash classes. --- .../writelatex/filestore/BlobHash.java | 35 +++++++++++++++++++ .../writelatex/filestore/FileIndexStore.java | 21 +++++++++++ .../{db => filestore}/WLDirectoryNode.java | 10 ++++-- .../{db => filestore}/WLFileStore.java | 2 +- .../writelatex/model/WLDataModel.java | 2 +- .../writelatex/model/WLProject.java | 1 - .../ic/wlgitbridge/{test => }/MainTests.java | 2 +- .../WLGitBridgeApplicationTests.java | 2 +- .../application/WLGitBridgeServerTests.java | 2 +- ...InvalidProgramArgumentsExceptionTests.java | 2 +- .../application/jetty/NullLoggerTests.java | 2 +- .../bridge/WLBridgedProjectTests.java | 2 +- .../git/WLGitServletConfigTests.java | 2 +- .../{test => }/git/WLGitServletTests.java | 2 +- .../InvalidRootDirectoryPathException.java | 2 +- .../handler/WLReceivePackFactoryTests.java | 2 +- .../handler/WLRepositoryResolverTests.java | 2 +- .../git/handler/WLUploadPackTests.java | 2 +- .../hook/CheckNonFastForwardHookTests.java | 2 +- .../SnapshotRepositoryBuilderTests.java | 2 +- .../api/request/base/RequestTests.java | 3 +- .../request/base/SnapshotAPIRequestTests.java | 2 +- .../getdoc/SnapshotGetDocRequestTests.java | 2 +- .../SnapshotGetForVersionRequestTests.java | 4 +-- .../SnapshotGetSavedVersRequestTests.java | 3 +- .../writelatex/filestore/BlobHashTest.java | 15 ++++++++ .../writelatex/model/SnapshotTests.java | 2 +- .../writelatex/model/WLDataModelTests.java | 2 +- .../writelatex/model/WLProjectTests.java | 6 +--- 29 files changed, 103 insertions(+), 35 deletions(-) create mode 100644 services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/BlobHash.java create mode 100644 services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/FileIndexStore.java rename services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/{db => filestore}/WLDirectoryNode.java (71%) rename services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/{db => filestore}/WLFileStore.java (94%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/MainTests.java (80%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/application/WLGitBridgeApplicationTests.java (89%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/application/WLGitBridgeServerTests.java (77%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/application/exception/InvalidProgramArgumentsExceptionTests.java (75%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/application/jetty/NullLoggerTests.java (74%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/bridge/WLBridgedProjectTests.java (83%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/git/WLGitServletConfigTests.java (80%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/git/WLGitServletTests.java (80%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/git/exception/InvalidRootDirectoryPathException.java (77%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/git/handler/WLReceivePackFactoryTests.java (77%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/git/handler/WLRepositoryResolverTests.java (78%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/git/handler/WLUploadPackTests.java (76%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/git/handler/hook/CheckNonFastForwardHookTests.java (76%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/SnapshotRepositoryBuilderTests.java (78%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/api/request/base/RequestTests.java (89%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/api/request/base/SnapshotAPIRequestTests.java (72%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/api/request/getdoc/SnapshotGetDocRequestTests.java (71%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/api/request/getforversion/SnapshotGetForVersionRequestTests.java (64%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/api/request/getsavedvers/SnapshotGetSavedVersRequestTests.java (73%) create mode 100644 services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/filestore/BlobHashTest.java rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/model/SnapshotTests.java (74%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/model/WLDataModelTests.java (74%) rename services/git-bridge/test/uk/ac/ic/wlgitbridge/{test => }/writelatex/model/WLProjectTests.java (76%) diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/BlobHash.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/BlobHash.java new file mode 100644 index 0000000000..eeaf8771fe --- /dev/null +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/BlobHash.java @@ -0,0 +1,35 @@ +package uk.ac.ic.wlgitbridge.writelatex.filestore; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; + +/** + * Created by Winston on 08/11/14. + */ +public class BlobHash { + + private byte[] hash; + + public BlobHash(byte[] blob) { + MessageDigest md = null; + try { + md = MessageDigest.getInstance("SHA-256"); + hash = md.digest(blob); + System.out.println(Arrays.toString(hash)); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + } + + @Override + public boolean equals(Object obj) { + return obj instanceof BlobHash && Arrays.equals(((BlobHash) obj).hash, hash); + } + + @Override + public int hashCode() { + return Arrays.hashCode(hash); + } + +} diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/FileIndexStore.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/FileIndexStore.java new file mode 100644 index 0000000000..6633d2bca4 --- /dev/null +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/FileIndexStore.java @@ -0,0 +1,21 @@ +package uk.ac.ic.wlgitbridge.writelatex.filestore; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by Winston on 08/11/14. + */ +public class FileIndexStore { + + private final Map blobHashMappings; + private final Map urlMappings; + + public FileIndexStore() { + blobHashMappings = new HashMap(); + urlMappings = new HashMap(); + } + + + +} diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/db/WLDirectoryNode.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/WLDirectoryNode.java similarity index 71% rename from services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/db/WLDirectoryNode.java rename to services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/WLDirectoryNode.java index 3477cd74f0..7611a00a3c 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/db/WLDirectoryNode.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/WLDirectoryNode.java @@ -1,8 +1,10 @@ -package uk.ac.ic.wlgitbridge.writelatex.db; +package uk.ac.ic.wlgitbridge.writelatex.filestore; import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot; import uk.ac.ic.wlgitbridge.writelatex.model.WLProject; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; @@ -22,7 +24,11 @@ public class WLDirectoryNode { } public void updateFromProject(WLProject project) { - Snapshot snapshot = project.getLatestSnapshot(); + updateFromLatestSnapshot(project.getLatestSnapshot()); + } + + private void updateFromLatestSnapshot(Snapshot snapshot) { + } } diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/db/WLFileStore.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/WLFileStore.java similarity index 94% rename from services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/db/WLFileStore.java rename to services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/WLFileStore.java index 1fe52f6078..1d1caeca43 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/db/WLFileStore.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/WLFileStore.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.writelatex.db; +package uk.ac.ic.wlgitbridge.writelatex.filestore; import uk.ac.ic.wlgitbridge.writelatex.model.WLProject; diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/WLDataModel.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/WLDataModel.java index bf848fa56a..9ddbe893fd 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/WLDataModel.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/WLDataModel.java @@ -4,7 +4,7 @@ import uk.ac.ic.wlgitbridge.writelatex.api.SnapshotDBAPI; import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.SnapshotGetDocRequest; import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException; -import uk.ac.ic.wlgitbridge.writelatex.db.WLFileStore; +import uk.ac.ic.wlgitbridge.writelatex.filestore.WLFileStore; import java.util.HashMap; import java.util.List; diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/WLProject.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/WLProject.java index 9a226984c2..a1000dafb4 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/WLProject.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/WLProject.java @@ -3,7 +3,6 @@ package uk.ac.ic.wlgitbridge.writelatex.model; import uk.ac.ic.wlgitbridge.writelatex.SnapshotFetcher; import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException; -import uk.ac.ic.wlgitbridge.writelatex.db.WLFileStore; import java.util.HashMap; import java.util.List; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/MainTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/MainTests.java similarity index 80% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/MainTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/MainTests.java index aa889c7287..f555531a0a 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/MainTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/MainTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test; +package uk.ac.ic.wlgitbridge; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/WLGitBridgeApplicationTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplicationTests.java similarity index 89% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/WLGitBridgeApplicationTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplicationTests.java index 27f73e699d..5bf1ec3203 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/WLGitBridgeApplicationTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplicationTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.application; +package uk.ac.ic.wlgitbridge.application; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/WLGitBridgeServerTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/application/WLGitBridgeServerTests.java similarity index 77% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/WLGitBridgeServerTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/application/WLGitBridgeServerTests.java index 7c39ac4852..64e444a4da 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/WLGitBridgeServerTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/application/WLGitBridgeServerTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.application; +package uk.ac.ic.wlgitbridge.application; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/exception/InvalidProgramArgumentsExceptionTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/application/exception/InvalidProgramArgumentsExceptionTests.java similarity index 75% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/exception/InvalidProgramArgumentsExceptionTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/application/exception/InvalidProgramArgumentsExceptionTests.java index 8c12756679..aee4ceaedd 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/exception/InvalidProgramArgumentsExceptionTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/application/exception/InvalidProgramArgumentsExceptionTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.application.exception; +package uk.ac.ic.wlgitbridge.application.exception; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/jetty/NullLoggerTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/application/jetty/NullLoggerTests.java similarity index 74% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/jetty/NullLoggerTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/application/jetty/NullLoggerTests.java index 6e360e9302..a68638c21d 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/jetty/NullLoggerTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/application/jetty/NullLoggerTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.application.jetty; +package uk.ac.ic.wlgitbridge.application.jetty; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/bridge/WLBridgedProjectTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/bridge/WLBridgedProjectTests.java similarity index 83% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/bridge/WLBridgedProjectTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/bridge/WLBridgedProjectTests.java index 238f1a8fec..334613cf88 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/bridge/WLBridgedProjectTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/bridge/WLBridgedProjectTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.bridge; +package uk.ac.ic.wlgitbridge.bridge; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/WLGitServletConfigTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/WLGitServletConfigTests.java similarity index 80% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/WLGitServletConfigTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/git/WLGitServletConfigTests.java index d78f43ad3b..5cf6d6e317 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/WLGitServletConfigTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/WLGitServletConfigTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.git; +package uk.ac.ic.wlgitbridge.git; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/WLGitServletTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/WLGitServletTests.java similarity index 80% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/WLGitServletTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/git/WLGitServletTests.java index 0a90b8ea1f..bd97cb9b4f 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/WLGitServletTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/WLGitServletTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.git; +package uk.ac.ic.wlgitbridge.git; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/exception/InvalidRootDirectoryPathException.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/exception/InvalidRootDirectoryPathException.java similarity index 77% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/exception/InvalidRootDirectoryPathException.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/git/exception/InvalidRootDirectoryPathException.java index f8ce1770d5..720c7d6ef8 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/exception/InvalidRootDirectoryPathException.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/exception/InvalidRootDirectoryPathException.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.git.exception; +package uk.ac.ic.wlgitbridge.git.exception; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLReceivePackFactoryTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLReceivePackFactoryTests.java similarity index 77% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLReceivePackFactoryTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLReceivePackFactoryTests.java index aed492ff5b..f1afabefd1 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLReceivePackFactoryTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLReceivePackFactoryTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.git.handler; +package uk.ac.ic.wlgitbridge.git.handler; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLRepositoryResolverTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolverTests.java similarity index 78% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLRepositoryResolverTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolverTests.java index c5f0b99ae8..538dd2fafb 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLRepositoryResolverTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolverTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.git.handler; +package uk.ac.ic.wlgitbridge.git.handler; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLUploadPackTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLUploadPackTests.java similarity index 76% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLUploadPackTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLUploadPackTests.java index 9199c4c9d0..93de41ea0f 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/WLUploadPackTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/WLUploadPackTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.git.handler; +package uk.ac.ic.wlgitbridge.git.handler; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/hook/CheckNonFastForwardHookTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/hook/CheckNonFastForwardHookTests.java similarity index 76% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/hook/CheckNonFastForwardHookTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/hook/CheckNonFastForwardHookTests.java index 3824d1aef6..34a3a475da 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/handler/hook/CheckNonFastForwardHookTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/git/handler/hook/CheckNonFastForwardHookTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.git.handler.hook; +package uk.ac.ic.wlgitbridge.git.handler.hook; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/SnapshotRepositoryBuilderTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/SnapshotRepositoryBuilderTests.java similarity index 78% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/SnapshotRepositoryBuilderTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/SnapshotRepositoryBuilderTests.java index 5cf9137975..27f4d2db47 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/SnapshotRepositoryBuilderTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/SnapshotRepositoryBuilderTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.writelatex; +package uk.ac.ic.wlgitbridge.writelatex; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/base/RequestTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/base/RequestTests.java similarity index 89% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/base/RequestTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/base/RequestTests.java index 4f850c5cfe..c74165a3f1 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/base/RequestTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/base/RequestTests.java @@ -1,7 +1,6 @@ -package uk.ac.ic.wlgitbridge.test.writelatex.api.request.base; +package uk.ac.ic.wlgitbridge.writelatex.api.request.base; import org.junit.Test; -import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Request; import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.SnapshotGetDocRequest; import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotGetForVersionRequest; import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotGetSavedVersRequest; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/base/SnapshotAPIRequestTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/base/SnapshotAPIRequestTests.java similarity index 72% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/base/SnapshotAPIRequestTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/base/SnapshotAPIRequestTests.java index 3e696479f3..e60a78bbbd 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/base/SnapshotAPIRequestTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/base/SnapshotAPIRequestTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.writelatex.api.request.base; +package uk.ac.ic.wlgitbridge.writelatex.api.request.base; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getdoc/SnapshotGetDocRequestTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getdoc/SnapshotGetDocRequestTests.java similarity index 71% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getdoc/SnapshotGetDocRequestTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getdoc/SnapshotGetDocRequestTests.java index 3e9815c3a1..70775a1e85 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getdoc/SnapshotGetDocRequestTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getdoc/SnapshotGetDocRequestTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.writelatex.api.request.getdoc; +package uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getforversion/SnapshotGetForVersionRequestTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getforversion/SnapshotGetForVersionRequestTests.java similarity index 64% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getforversion/SnapshotGetForVersionRequestTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getforversion/SnapshotGetForVersionRequestTests.java index ca399cca1c..822ee62948 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getforversion/SnapshotGetForVersionRequestTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getforversion/SnapshotGetForVersionRequestTests.java @@ -1,8 +1,6 @@ -package uk.ac.ic.wlgitbridge.test.writelatex.api.request.getforversion; +package uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion; import org.junit.Test; -import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotGetForVersionRequest; -import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotGetForVersionResult; /** * Created by Winston on 06/11/14. diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getsavedvers/SnapshotGetSavedVersRequestTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getsavedvers/SnapshotGetSavedVersRequestTests.java similarity index 73% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getsavedvers/SnapshotGetSavedVersRequestTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getsavedvers/SnapshotGetSavedVersRequestTests.java index 54a4e6fd5a..28d8761fd8 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/api/request/getsavedvers/SnapshotGetSavedVersRequestTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/api/request/getsavedvers/SnapshotGetSavedVersRequestTests.java @@ -1,7 +1,6 @@ -package uk.ac.ic.wlgitbridge.test.writelatex.api.request.getsavedvers; +package uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers; import org.junit.Test; -import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotGetSavedVersRequest; /** * Created by Winston on 06/11/14. diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/filestore/BlobHashTest.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/filestore/BlobHashTest.java new file mode 100644 index 0000000000..b6ba694237 --- /dev/null +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/filestore/BlobHashTest.java @@ -0,0 +1,15 @@ +package uk.ac.ic.wlgitbridge.writelatex.filestore; + +import org.junit.Test; + +public class BlobHashTest { + + private static final String toHash = "\\\\documentclass[a4paper]{article}\\n\\n\\\\usepackage[english]{babel}\\n\\\\usepackage[utf8]{inputenc}\\n\\\\usepackage{graphicx}\\n\\\\usepackage{fullpage}\\n\\\\usepackage{listings}\\n\\\\usepackage{courier}\\n\\\\usepackage{url}\\n\\n\\\\lstset{basicstyle=\\\\ttfamily,breaklines=true}\\n\\n\\\\begin{document}\\n\\\\title{API for the writeLaTeX-Git Bridge}\\n\\\\author{JLM}\\n\\\\date{\\\\today}\\n\\\\maketitle\\n\\n\\\\section{Fetching a Project from WriteLaTeX}\\n\\nThere are three API calls that will likely be of interest. You can run them against this server, \\\\url{radiant-wind-3058.herokuapp.com}, but they're not on the production server yet.\\n\\n\\\\subsection{Get Doc}\\n\\nA ``doc'' is our internal term for a ``project''. At present, this just returns the latest version number.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb\\n# => { latestVerId: 39 }\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Saved Vers}\\n\\nA ``saved ver'' is a version of a doc, saved by via the versions menu. Note that this query is not currently paginated.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/saved_vers\\n# => [\\n {\\\"versionId\\\":39,\\n \\\"comment\\\":\\\"with more files\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T18:02:19Z\\\"},\\n {\\\"versionId\\\":24,\\n \\\"comment\\\":\\\"first draft\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T17:56:58Z\\\"}]\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Snapshot for Version}\\n\\nA snapshot contains the content of a project in the given version. You can safely request a snapshot of any version that is, or was at any point in the last 24 hours, (1) a saved version, or (2) the current version. (Older versions may or may not have been moved to cold storage.)\\n\\nThe srcs array contains (content, file name) pairs; the atts array contains (URL, file name) pairs.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/snapshots/39\\n# => {\\n \\\"srcs\\\":[\\n [\\\"This text is from another file.\\\",\\\"foo/bar/test.tex\\\"],\\n [\\\"\\\\\\\\documentclass[a4paper]{article}\\\\n...\\\",\\\"main.tex\\\"]],\\n \\\"atts\\\":[\\n [\\\"https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png\\\",\\\"min_mean_wait_evm_7_eps_150dpi.png\\\"]]}\\n\\\\end{lstlisting}\\n\\n\\\\section{Pushing a Project to WriteLaTeX}\\n\\nTODO still working on this part\\n\\n\\\\section{Test Data}\\n\\nYou can use this project as one of your test projects. I've added an attachment and a file in a subfolder to make it a bit more interesting.\\n\\n\\\\input{foo/bar/test}\\n\\n\\\\includegraphics[width=\\\\linewidth]{min_mean_wait_evm_7_eps_150dpi}\\n\\n\\\\end{document}"; + + @Test + public void hashesTheBytesGivenInTheConstructorUsingSha256() { + BlobHash blobHash = new BlobHash(toHash.getBytes()); + + } + +} \ No newline at end of file diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/SnapshotTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/SnapshotTests.java similarity index 74% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/SnapshotTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/SnapshotTests.java index a2e3c6824b..1aa62b0be0 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/SnapshotTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/SnapshotTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.writelatex.model; +package uk.ac.ic.wlgitbridge.writelatex.model; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/WLDataModelTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/WLDataModelTests.java similarity index 74% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/WLDataModelTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/WLDataModelTests.java index c720b62655..e4aeaa1676 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/WLDataModelTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/WLDataModelTests.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.test.writelatex.model; +package uk.ac.ic.wlgitbridge.writelatex.model; import org.junit.Test; diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/WLProjectTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/WLProjectTests.java similarity index 76% rename from services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/WLProjectTests.java rename to services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/WLProjectTests.java index 8ccc713724..bf6093d69c 100644 --- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/writelatex/model/WLProjectTests.java +++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/writelatex/model/WLProjectTests.java @@ -1,12 +1,8 @@ -package uk.ac.ic.wlgitbridge.test.writelatex.model; +package uk.ac.ic.wlgitbridge.writelatex.model; import org.junit.Test; import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException; -import uk.ac.ic.wlgitbridge.writelatex.model.WLProject; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; /** * Created by Winston on 06/11/14.