Search in sources :

Example 1 with MockVcsSupport

use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.

the class ChangeStatusTest method setUp.

@Override
@BeforeMethod
public void setUp() throws Exception {
    super.setUp();
    setFinder(myChangeFinder);
    myFixture.getServerSettings().setPerProjectPermissionsEnabled(true);
    myVcs = new MockVcsSupport("vcs");
    myVcs.setDAGBased(true);
    myFixture.getVcsManager().registerVcsSupport(myVcs);
    myTestProject = createProject("someproject");
    myUser = createUser("testuser");
    myUser.addRole(RoleScope.projectScope(myTestProject.getProjectId()), getTestRoles().getProjectViewerRole());
    myAnotherUser = createUser("anothertestuser");
}
Also used : MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with MockVcsSupport

use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.

the class VcsRootInstanceFinderTest method testRepositoryIdString.

@SuppressWarnings("ConstantConditions")
@Test
public void testRepositoryIdString() throws Exception {
    MockVcsSupport svn = myFixture.registerVcsSupport("svn");
    svn.addCustomVcsExtension(VcsPersonalSupport.class, new VcsPersonalSupport() {

        @NotNull
        @Override
        public Collection<String> mapFullPath(@NotNull final VcsRootEntry rootEntry, @NotNull final String fullPath) throws VcsException {
            String prefix = rootEntry.getProperties().get("prefix");
            if (prefix != null && fullPath.startsWith(prefix))
                return Collections.singletonList(fullPath.substring(prefix.length()));
            return Collections.emptyList();
        }
    });
    svn.addCustomVcsExtension(VcsClientMappingProvider.class, new VcsRootBasedMappingProvider() {

        @Override
        public Collection<VcsClientMapping> getClientMapping(@NotNull final VcsRoot vcsRoot) throws VcsException {
            String prefix = vcsRoot.getProperties().get("prefix");
            if (prefix != null)
                return Collections.singletonList(new VcsClientMapping(prefix, ""));
            return Collections.emptyList();
        }
    });
    myFixture.registerVcsSupport("custom");
    final ProjectEx project10 = getRootProject().createProject("project10", "Project name 10");
    final SVcsRoot vcsRoot10 = project10.createVcsRoot("svn", "id10", "VCS root 10 name");
    vcsRoot10.setProperties(CollectionsUtil.asMap("url", "22", "prefix", "000000-0000-1111-000000000001|trunk/path1"));
    final SVcsRoot vcsRoot12 = project10.createVcsRoot("svn", "id12", "VCS root 12 name");
    vcsRoot12.setProperties(CollectionsUtil.asMap("url", "", "prefix", "000000-0000-1111-000000000001|trunk/path2"));
    final SVcsRoot vcsRoot15 = project10.createVcsRoot("custom", "id15", "VCS root 15 name");
    vcsRoot15.setProperties(CollectionsUtil.asMap("url", "", "aaa", "3"));
    final SBuildType bt10 = project10.createBuildType("id10", "name 10");
    VcsRootInstance vInstance10 = attachVcsRoot(bt10, vcsRoot10);
    VcsRootInstance vInstance20 = attachVcsRoot(bt10, vcsRoot12);
    bt10.setCheckoutRules(vcsRoot10, new CheckoutRules("+:aaa=>bbb"));
    check("repositoryIdString:xxx");
    // pre-TeamCity 10 behavior
    check("repositoryIdString:000000-0000-1111-000000000001|trunk/path1", vInstance10);
    // pre-TeamCity 10 behavior
    check("repositoryIdString:000000-0000-1111-000000000001|trunk/path1/aaa", vInstance10);
    check("repositoryIdString:svn://000000-0000-1111-000000000001|trunk/path1", vInstance10);
    check("repositoryIdString:svn://000000-0000-1111-000000000001|trunk/path1/aaa", vInstance10);
    check("repositoryIdString:svn://000000-0000-1111-000000000001|trunk/path2/aaa", vInstance20);
    check("repositoryIdString:svn://000000-0000-1111-000000000001|trunk2");
    check("repositoryIdString:svn://000000-0000-1111-000000000001|trunk/path9");
    check("repositoryIdString:svn://000000-0000-1111-000000000002|trunk/path1");
    // does not work for now    check("repositoryIdString:svn://000000-0000-1111-000000000001|", vInstance10, vInstance20);
    check("repositoryIdString:svn://000000-0000-1111-000000000001|trunk", vInstance10, vInstance20);
    check("repositoryIdString:svn://000000-0000-1111-000000000001|trunk/path");
}
Also used : NotNull(org.jetbrains.annotations.NotNull) ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) Collection(java.util.Collection) Test(org.testng.annotations.Test)

Example 3 with MockVcsSupport

use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.

the class ChangeFinderTest method buildVcsRootInstance.

@NotNull
private VcsRootInstance buildVcsRootInstance() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
    VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
    assert root1 != null;
    return root1;
}
Also used : MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with MockVcsSupport

use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.

the class ChangeFinderTest method testDuplicate.

@Test
public void testDuplicate() {
    final BuildTypeImpl buildConf1 = registerBuildType("buildConf1", "project");
    final BuildTypeImpl buildConf2 = registerBuildType("buildConf2", "project");
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf1);
    SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", buildConf2);
    VcsRootInstance root1 = buildConf1.getVcsRootInstanceForParent(parentRoot1);
    VcsRootInstance root2 = buildConf2.getVcsRootInstanceForParent(parentRoot2);
    assert root1 != null && root2 != null;
    final String version = "12345";
    myFixture.addModification(modification().in(root1).by("user1").version(version));
    myFixture.addModification(modification().in(root2).by("user1").version(version));
    List<SVcsModificationOrChangeDescriptor> result = myChangeFinder.getItems("unique:true").myEntries;
    assertEquals(1, result.size());
    List<SVcsModificationOrChangeDescriptor> resultWithDuplicate = myChangeFinder.getItems("count:10").myEntries;
    assertEquals(2, resultWithDuplicate.size());
}
Also used : MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) SVcsModificationOrChangeDescriptor(jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 5 with MockVcsSupport

use of jetbrains.buildServer.serverSide.impl.MockVcsSupport in project teamcity-rest by JetBrains.

the class ChangeFinderTest method testLimitedProcessing.

@Test
public void testLimitedProcessing() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    final BuildTypeImpl buildConf2 = registerBuildType("buildConf2", "project");
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
    VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
    assert root1 != null;
    SVcsModification m20 = myFixture.addModification(modification().in(root1).by("user1").version("20").parentVersions("10"));
    SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
    SVcsModification m40 = myFixture.addModification(modification().in(root1).version("40").parentVersions("10"));
    SVcsModification m50 = myFixture.addModification(modification().in(root1).by("user1").version("50").parentVersions("40"));
    SVcsModification m60 = myFixture.addModification(modification().in(root1).version("60").parentVersions("15"));
    SVcsModification m70 = myFixture.addModification(modification().in(root1).version("70").parentVersions("10"));
    myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    check(null, m70, m60, m50, m40, m30, m20);
    checkCounts("count:3", 3, 4);
    checkCounts("lookupLimit:3", 3, 4);
    checkCounts("username:user1", 2, 6);
    checkCounts("buildType:(id:" + buildConf2.getExternalId() + ")", 0, 0);
    checkCounts("version:50", 1, 6);
}
Also used : MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Aggregations

MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)22 Test (org.testng.annotations.Test)20 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)10 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)6 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)6 BuildTypeEx (jetbrains.buildServer.serverSide.BuildTypeEx)5 BuildFinderTestBase (jetbrains.buildServer.server.rest.data.BuildFinderTestBase)4 Branches (jetbrains.buildServer.server.rest.model.build.Branches)4 SVcsRoot (jetbrains.buildServer.vcs.SVcsRoot)4 SVcsModificationOrChangeDescriptor (jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor)3 ProjectRequestTest (jetbrains.buildServer.server.rest.request.ProjectRequestTest)3 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)3 ArrayList (java.util.ArrayList)2 ServiceLocator (jetbrains.buildServer.ServiceLocator)2 BuildTriggerDescriptor (jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor)2 BuildTypeRequest (jetbrains.buildServer.server.rest.request.BuildTypeRequest)2 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)2 SArtifactDependency (jetbrains.buildServer.serverSide.artifacts.SArtifactDependency)2 TestFor (jetbrains.buildServer.util.TestFor)2 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)2