summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2014-04-15 16:10:18 (EDT)
committerTomasz Zarna2014-04-16 18:26:34 (EDT)
commitab3a3f7f92eb08ab55600cdd9c7fa4ddeb3319a8 (patch)
tree326117dafe0fa3c242d8d47ed5883898ca8f21c8
parent1e81dc0cbcca7e86f8ccee46fe6fbd8e80631470 (diff)
downloadorg.eclipse.mylyn.reviews-ab3a3f7f92eb08ab55600cdd9c7fa4ddeb3319a8.zip
org.eclipse.mylyn.reviews-ab3a3f7f92eb08ab55600cdd9c7fa4ddeb3319a8.tar.gz
org.eclipse.mylyn.reviews-ab3a3f7f92eb08ab55600cdd9c7fa4ddeb3319a8.tar.bz2
Refactor tests: create utility methodsrefs/changes/88/25088/3
Change-Id: Ia460fd862d874cc18492c85223d69e58e9f53c9b Signed-off-by: Sam Davis <sam.davis@tasktop.com>
-rw-r--r--org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java17
-rw-r--r--org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/PatchSetRemoteFactoryTest.java34
-rw-r--r--org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/ReviewHarness.java29
3 files changed, 42 insertions, 38 deletions
diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java
index 4f62287..27ff212 100644
--- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java
+++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/GerritReviewRemoteFactoryTest.java
@@ -114,12 +114,9 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
@Test
public void testNewChange() throws Exception {
- CommitCommand command2 = reviewHarness.git.commit()
- .setAmend(true)
- .setAll(true)
- .setMessage("Test Change " + reviewHarness.testIdent + " [2]\n\nChange-Id: " + reviewHarness.changeId);
- reviewHarness.gerritHarness.project().addFile("testFile2.txt");
- reviewHarness.gerritHarness.project().commitAndPush(command2);
+ CommitCommand command2 = reviewHarness.createCommitCommand();
+ reviewHarness.addFile("testFile2.txt");
+ reviewHarness.commitAndPush(command2);
reviewHarness.consumer.retrieve(false);
reviewHarness.listener.waitForResponse(2, 2);
List<IReviewItemSet> items = getReview().getSets();
@@ -188,11 +185,9 @@ public class GerritReviewRemoteFactoryTest extends GerritRemoteTest {
@Test
public void testDependencies() throws Exception {
String changeIdDep1 = "I" + StringUtils.rightPad(System.currentTimeMillis() + "", 40, "a");
- CommitCommand commandDep1 = reviewHarness.git.commit()
- .setAll(true)
- .setMessage("Test Change Dependent 1 " + reviewHarness.testIdent + "\n\nChange-Id: " + changeIdDep1);
- reviewHarness.gerritHarness.project().addFile("testFile1.txt", "test 2");
- CommitResult resultDep1 = reviewHarness.gerritHarness.project().commitAndPush(commandDep1);
+ CommitCommand commandDep1 = reviewHarness.createCommitCommand(changeIdDep1);
+ reviewHarness.addFile("testFile1.txt", "test 2");
+ CommitResult resultDep1 = reviewHarness.commitAndPush(commandDep1);
String resultIdDep1 = StringUtils.trimToEmpty(StringUtils.substringAfterLast(resultDep1.push.getMessages(), "/"));
assertThat("Bad Push: " + resultDep1.push.getMessages(), resultIdDep1.length(), greaterThan(0));
diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/PatchSetRemoteFactoryTest.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/PatchSetRemoteFactoryTest.java
index 1aecddb..c0da123 100644
--- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/PatchSetRemoteFactoryTest.java
+++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/PatchSetRemoteFactoryTest.java
@@ -46,21 +46,15 @@ public class PatchSetRemoteFactoryTest extends GerritRemoteTest {
@Test
public void testPatchSetFiles() throws Exception {
- CommitCommand command2 = reviewHarness.git.commit()
- .setAmend(true)
- .setAll(true)
- .setMessage("Test Change " + reviewHarness.testIdent + " [2]\n\nChange-Id: " + reviewHarness.changeId);
- reviewHarness.gerritHarness.project().addFile("testFile2.txt");
- reviewHarness.gerritHarness.project().addFile("testFile3.txt");
- reviewHarness.gerritHarness.project().commitAndPush(command2);
- CommitCommand command3 = reviewHarness.git.commit()
- .setAmend(true)
- .setAll(true)
- .setMessage("Test Change " + reviewHarness.testIdent + " [2]\n\nChange-Id: " + reviewHarness.changeId);
- reviewHarness.gerritHarness.project().addFile("testFile2.txt", "testmod");
- reviewHarness.gerritHarness.project().addFile("testFile4.txt");
- reviewHarness.gerritHarness.project().addFile("testFile5.txt");
- reviewHarness.gerritHarness.project().commitAndPush(command3);
+ CommitCommand command2 = reviewHarness.createCommitCommand();
+ reviewHarness.addFile("testFile2.txt");
+ reviewHarness.addFile("testFile3.txt");
+ reviewHarness.commitAndPush(command2);
+ CommitCommand command3 = reviewHarness.createCommitCommand();
+ reviewHarness.addFile("testFile2.txt", "testmod");
+ reviewHarness.addFile("testFile4.txt");
+ reviewHarness.addFile("testFile5.txt");
+ reviewHarness.commitAndPush(command3);
reviewHarness.consumer.retrieve(false);
reviewHarness.listener.waitForResponse(2, 2);
@@ -125,13 +119,9 @@ public class PatchSetRemoteFactoryTest extends GerritRemoteTest {
@Test
public void testPatchSetComments() throws Exception {
- CommitCommand command2 = reviewHarness.git.commit()
- .setAmend(true)
- .setAll(true)
- .setMessage("Test Change " + reviewHarness.testIdent + " [2]\n\nChange-Id: " + reviewHarness.changeId);
- reviewHarness.gerritHarness.project().addFile("testComments.txt",
- "line1\nline2\nline3\nline4\nline5\nline6\nline7\n");
- reviewHarness.gerritHarness.project().commitAndPush(command2);
+ CommitCommand command2 = reviewHarness.createCommitCommand();
+ reviewHarness.addFile("testComments.txt", "line1\nline2\nline3\nline4\nline5\nline6\nline7\n");
+ reviewHarness.commitAndPush(command2);
reviewHarness.consumer.retrieve(false);
reviewHarness.listener.waitForResponse(2, 2);
RemoteEmfConsumer<IReview, IReviewItemSet, String, PatchSetDetail, PatchSetDetail, String> itemSetConsumer = reviewHarness.provider.getReviewItemSetFactory()
diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/ReviewHarness.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/ReviewHarness.java
index 8bebe04..07645bd 100644
--- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/ReviewHarness.java
+++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/internal/gerrit/core/remote/ReviewHarness.java
@@ -104,11 +104,9 @@ class ReviewHarness {
public void pushFileToReview(String testIdent) throws Exception {
changeId = "I" + StringUtils.rightPad(testIdent, 40, "a");
- CommitCommand command = git.commit()
- .setAll(true)
- .setMessage("Test Change " + testIdent + "\n\nChange-Id: " + changeId);
- gerritHarness.project().addFile("testFile1.txt");
- CommitResult result = gerritHarness.project().commitAndPush(command);
+ CommitCommand command = createCommitCommand(changeId);
+ addFile("testFile1.txt");
+ CommitResult result = commitAndPush(command);
shortId = StringUtils.trimToEmpty(StringUtils.substringAfterLast(result.push.getMessages(), "/"));
commitId = result.commit.getId().toString();
assertThat("Bad Push: " + result.push.getMessages(), shortId.length(), greaterThan(0));
@@ -134,4 +132,25 @@ class ReviewHarness {
IRepository getRepository() {
return provider.getRoot();
}
+
+ public CommitCommand createCommitCommand() {
+ return createCommitCommand(changeId).setAmend(true);
+ }
+
+ public CommitCommand createCommitCommand(String changeId) {
+ return git.commit().setAll(true).setMessage("Test Change " + testIdent + "\n\nChange-Id: " + changeId);
+ }
+
+ public void addFile(String fileName) throws Exception {
+ gerritHarness.project().addFile(fileName);
+ }
+
+ public void addFile(String fileName, String text) throws Exception {
+ gerritHarness.project().addFile(fileName, text);
+ }
+
+ public CommitResult commitAndPush(CommitCommand command) throws Exception {
+ return gerritHarness.project().commitAndPush(command);
+ }
+
} \ No newline at end of file