changeset 935:eb3e0285ae52

TW-43138 Migrate to fresh auto checkout api
author Dmitry.Treskunov@UNIT-412.Labs.IntelliJ.Net
date Wed, 11 Nov 2015 21:03:31 +0300
parents 3db6c332fc3b
children 68160fb667b1
files mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java
diffstat 2 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java	Tue Nov 10 21:27:07 2015 +0300
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java	Wed Nov 11 21:03:31 2015 +0300
@@ -56,8 +56,8 @@
 
   @NotNull
   @Override
-  public AgentCheckoutAbility canCheckout(@NotNull VcsRootEntry vcsRoot, @NotNull AgentRunningBuild build) {
-    CheckoutInfo info = new CheckoutInfo(myRepoFactory, new HgVcsRoot(vcsRoot.getVcsRoot()), vcsRoot.getCheckoutRules());
+  public AgentCheckoutAbility canCheckout(@NotNull VcsRoot vcsRoot, @NotNull CheckoutRules checkoutRules, @NotNull AgentRunningBuild build) {
+    CheckoutInfo info = new CheckoutInfo(myRepoFactory, new HgVcsRoot(vcsRoot), checkoutRules);
     try {
       info.getTempDirRepo().version().call();
     } catch (VcsException e) {
@@ -65,7 +65,7 @@
     }
 
     try {
-      for (IncludeRule rule : vcsRoot.getCheckoutRules().getRootIncludeRules()) {
+      for (IncludeRule rule : checkoutRules.getRootIncludeRules()) {
         MercurialIncludeRuleUpdater.checkRuleIsValid(rule);
       }
       return AgentCheckoutAbility.canCheckout();
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Tue Nov 10 21:27:07 2015 +0300
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Wed Nov 11 21:03:31 2015 +0300
@@ -29,6 +29,7 @@
 import jetbrains.buildServer.util.TestFor;
 import jetbrains.buildServer.vcs.*;
 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
+import org.hamcrest.CoreMatchers;
 import org.jetbrains.annotations.NotNull;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
@@ -106,17 +107,17 @@
   public void auto_checkout_when_hg_client_not_found() throws Exception {
     VcsRootImpl root = new VcsRootBuilder().withUrl(copyRepository(myTempFiles, simpleRepo()).getAbsolutePath()).withHgPath("invalid_hg_path").build();
 
-    AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(new VcsRootEntry(root, CheckoutRules.DEFAULT), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
+    AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(root, CheckoutRules.DEFAULT, myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
 
-    assertThat(agentCheckoutAbility.getCanNotCheckoutReason(), containsString(AgentCheckoutAbility.NO_VCS_CLIENT));
+    assertThat(agentCheckoutAbility.getCanNotCheckoutReason().getType(), CoreMatchers.equalTo(AgentCheckoutAbility.NO_VCS_CLIENT));
   }
 
   public void auto_checkout_when_unsupported_include_rule_is_used() throws Exception {
     VcsRootImpl root = createVcsRoot(simpleRepo());
 
-    AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(new VcsRootEntry(root, new CheckoutRules("+:subdir=>subdir2")), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
+    AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(root, new CheckoutRules("+:subdir=>subdir2"), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
 
-    assertThat(agentCheckoutAbility.getCanNotCheckoutReason(), containsString("Invalid include rule: subdir=>subdir2"));
+    assertThat(agentCheckoutAbility.getCanNotCheckoutReason().describe(true), containsString("Invalid include rule: subdir=>subdir2"));
   }
 
   public void checkout_on_agent() throws IOException, VcsException {
@@ -169,7 +170,7 @@
       allowing(build).getBuildLogger(); will(returnValue(myLogger));
       allowing(build).getSharedConfigParameters(); will(returnValue(sharedConfigParameters));
     }});
-    assertNull(myVcsSupport.canCheckout(new VcsRootEntry(vcsRoot, new CheckoutRules("")), build).getCanNotCheckoutReason());
+    assertNull(myVcsSupport.canCheckout(vcsRoot, new CheckoutRules(""), build).getCanNotCheckoutReason());
     myVcsSupport.getUpdater(vcsRoot, new CheckoutRules(""), version, myWorkDir, build, false).process(includeRule, actualWorkDir);
 
     File hgDir = new File(actualWorkDir, ".hg");