Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/VcsRootBuilder.java @ 405:0b0a9c0ced8f
Merge branch Faradi-7.0.x
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 02 Mar 2012 15:33:14 +0400 |
parents | 24d926f22e85 |
children | 2755266b7dd5 |
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.vcs.SVcsRoot; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import org.jetbrains.annotations.NotNull; import org.jmock.Expectations; import org.jmock.Mockery; import java.io.IOException; /** * @author dmitry.neverov */ public class VcsRootBuilder { private String myRepository; private String myUsername; private String myPassword; private String myBranch; private long myRootId = 1L; private String myHgPath; private String myUserForTag; public static VcsRootBuilder vcsRoot() { return new VcsRootBuilder(); } public VcsRootImpl build() throws IOException { VcsRootImpl vcsRoot = new VcsRootImpl(myRootId, Constants.VCS_NAME); vcsRoot.addProperty(Constants.REPOSITORY_PROP, myRepository); vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, myHgPath != null ? myHgPath : Util.getHgPath()); vcsRoot.addProperty(Constants.USERNAME, myUsername); vcsRoot.addProperty(Constants.PASSWORD, myPassword); vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, myBranch); vcsRoot.addProperty(Constants.USER_FOR_TAG, myUserForTag); return vcsRoot; } public SVcsRoot build(Mockery context) { final SVcsRoot root = context.mock(SVcsRoot.class, "SVcsRoot" + myRootId); context.checking(new Expectations() {{ allowing(root).getVcsName(); will(returnValue(Constants.VCS_NAME)); allowing(root).getProperty(with(Constants.REPOSITORY_PROP)); will(returnValue(myRepository)); allowing(root).getProperty(with(Constants.HG_COMMAND_PATH_PROP)); will(returnValue(myHgPath)); allowing(root).getProperty(with(Constants.BRANCH_NAME_PROP)); will(returnValue(myBranch)); allowing(root).getProperty(with(Constants.SERVER_CLONE_PATH_PROP)); will(returnValue(null)); allowing(root).getProperty(with(Constants.USERNAME)); will(returnValue(myUsername)); allowing(root).getProperty(with(Constants.PASSWORD)); will(returnValue(myPassword)); allowing(root).getProperty(with(Constants.UNCOMPRESSED_TRANSFER)); will(returnValue(null)); allowing(root).getProperty(with(Constants.USER_FOR_TAG)); will(returnValue(myUserForTag)); }}); return root; } public VcsRootBuilder withUrl(@NotNull String repository) { myRepository = repository; return this; } public VcsRootBuilder withUserName(@NotNull String username) { myUsername = username; return this; } public VcsRootBuilder withPassword(@NotNull String password) { myPassword = password; return this; } public VcsRootBuilder withBranch(@NotNull String branch) { myBranch = branch; return this; } public VcsRootBuilder withId(long rootId) { myRootId = rootId; return this; } public VcsRootBuilder withHgPath(String hgPath) { myHgPath = hgPath; return this; } public VcsRootBuilder withUserForTag(String username) { myUserForTag = username; return this; } }