Search in sources :

Example 11 with MockVcsSupport

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

the class ChangeFinderTest method testChangesByBuildTypeFromDependenciesHaveDescriptor.

@Test
@TestFor(issues = "TW-72448")
public void testChangesByBuildTypeFromDependenciesHaveDescriptor() {
    final BuildTypeImpl buildConf1 = registerBuildType("buildConf1", "project");
    final BuildTypeImpl buildConf2 = registerBuildType("buildConf2", "project");
    createDependencyChain(buildConf2, buildConf1);
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    vcs.setDAGBased(true);
    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;
    assert root2 != null;
    setBranchSpec(root1, "+:*");
    setBranchSpec(root2, "+:*");
    final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(changesPolicy);
    myFixture.addModification(modification().in(root1).version("1").parentVersions("0"));
    myFixture.addModification(modification().in(root2).version("2").parentVersions("0"));
    List<SVcsModificationOrChangeDescriptor> items = getFinder().getItems("buildType:buildConf2,changesFromDependencies:true,vcsRoot:(id:" + root1.getExternalId() + ")").myEntries;
    assertEquals("There is exactly one pending change coming from dependency.", 1, items.size());
    ChangeDescriptor descriptor = items.get(0).getChangeDescriptor();
    assertNotNull("Depency change descriptor must be present when looking for changes using build type.", descriptor);
    assertEquals(ChangeDescriptorConstants.SNAPSHOT_DEPENDENCY_VCS_CHANGE, descriptor.getType());
    SVcsModification modification = items.get(0).getSVcsModification();
    assertEquals("1", modification.getDisplayVersion());
}
Also used : MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) SVcsModificationOrChangeDescriptor(jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) SVcsModificationOrChangeDescriptor(jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 12 with MockVcsSupport

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

the class ChangeFinderTest method testChangesByBuildIdFromDependenciesHaveDescriptor.

@Test
@TestFor(issues = "TW-60774")
public void testChangesByBuildIdFromDependenciesHaveDescriptor() {
    final BuildTypeImpl buildConf1 = registerBuildType("buildConf1", "project");
    final BuildTypeImpl buildConf2 = registerBuildType("buildConf2", "project");
    createDependencyChain(buildConf2, buildConf1);
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    vcs.setDAGBased(true);
    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;
    assert root2 != null;
    setBranchSpec(root1, "+:*");
    setBranchSpec(root2, "+:*");
    SVcsModification m1 = myFixture.addModification(modification().in(root1).version("1").parentVersions("0"));
    SVcsModification m2 = myFixture.addModification(modification().in(root2).version("2").parentVersions("0"));
    SQueuedBuild qb1 = build().in(buildConf1).onModifications(m1).addToQueue();
    SQueuedBuild qb2 = build().in(buildConf2).onModifications(m2).snapshotDepends(qb1.getBuildPromotion()).addToQueue();
    SFinishedBuild build1 = finishBuild(myFixture.flushQueueAndWait(), false);
    SFinishedBuild build2 = finishBuild(myFixture.flushQueueAndWait(), false);
    List<SVcsModificationOrChangeDescriptor> items = getFinder().getItems("build:" + build2.getBuildId() + ",changesFromDependencies:true,vcsRoot:(id:" + root1.getExternalId() + ")").myEntries;
    assertEquals("There is exactly one change coming from dependency.", 1, items.size());
    ChangeDescriptor descriptor = items.get(0).getChangeDescriptor();
    assertNotNull("Change descriptor must be present when looking for changes using build id.", descriptor);
    assertEquals(ChangeDescriptorConstants.SNAPSHOT_DEPENDENCY_VCS_CHANGE, descriptor.getType());
    SVcsModification modification = items.get(0).getSVcsModification();
    assertEquals("1", modification.getDisplayVersion());
}
Also used : MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) SVcsModificationOrChangeDescriptor(jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) SVcsModificationOrChangeDescriptor(jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 13 with MockVcsSupport

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

the class ChangeFinderTest method testBranchFromBranch.

@Test
public void testBranchFromBranch() {
    final BuildTypeImpl buildConf = registerBuildType("buildConf1", "project");
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    vcs.setDAGBased(true);
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
    VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
    assert root1 != null;
    setBranchSpec(root1, "+:*");
    final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(changesPolicy);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("10"));
    build().in(buildConf).onModifications(m20).finish();
    SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("20"));
    SVcsModification m40 = myFixture.addModification(modification().in(root1).version("40").parentVersions("30"));
    SVcsModification m45 = myFixture.addModification(modification().in(root1).version("45").parentVersions("30"));
    SVcsModification m60 = myFixture.addModification(modification().in(root1).version("60").parentVersions("20"));
    changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "60", "branch1", "40", "branch2", "45")));
    myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    check(null, m60, m45, m40, m30, m20);
    String btLocator = "buildType:(id:" + buildConf.getExternalId() + ")";
    // documenting current behavior, should be check(btLocator, m60, m20);
    check(btLocator, m60, m45, m40, m30, m20);
    check(btLocator + ",branch:(default:any)", m60, m45, m40, m30, m20);
    check(btLocator + ",pending:true", m60);
    check(btLocator + ",pending:true,branch:branch1", m40, m30);
    check(btLocator + ",pending:true,branch:(default:false)", m45, m40, m30);
    check(btLocator + ",pending:true,branch:(default:any)", m60, m45, m40, m30);
}
Also used : MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 14 with MockVcsSupport

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

the class ChangeFinderTest method testChangeBean.

@Test
public void testChangeBean() {
    MockVcsSupport vcsSupport = new MockVcsSupport("svn");
    myFixture.getVcsManager().registerVcsSupport(vcsSupport);
    SVcsRootImpl vcsRoot = myFixture.addVcsRoot(vcsSupport.getName(), "", myBuildType);
    VcsRootInstance vcsRootInstance = myBuildType.getVcsRootInstanceForParent(vcsRoot);
    MockVcsModification modification10 = MockVcsModification.createWithoutFiles("user1", "descr1", new Date());
    modification10.addChange(new VcsChange(VcsChangeInfo.Type.ADDED, "root/a/file.txt", "a/file.txt", "9", "10"));
    modification10.addChange(new VcsChange(VcsChangeInfo.Type.CHANGED, "root/a/file2.txt", "a/file2.txt", null, null));
    modification10.addChange(new VcsChange(VcsChangeInfo.Type.REMOVED, "root/b/file.txt", "b/file.txt", null, null));
    modification10.addChange(new VcsChange(VcsChangeInfo.Type.NOT_CHANGED, "root/b/file3.txt", "b/file3.txt", null, null));
    modification10.addChange(new VcsChange(VcsChangeInfo.Type.DIRECTORY_ADDED, "root/c", "c", null, "after"));
    modification10.addChange(new VcsChange(VcsChangeInfo.Type.DIRECTORY_CHANGED, "root/c1", "c1", null, "after"));
    modification10.addChange(new VcsChange(VcsChangeInfo.Type.DIRECTORY_REMOVED, "root/d", "d", "before", null));
    modification10.addChange(new VcsChange(VcsChangeInfo.Type.DIRECTORY_COPIED, "root/e", "e", "before", "after"));
    vcsSupport.addChange(vcsRootInstance, modification10);
    Change change10 = new Change(modification10, Fields.ALL, getBeanContext(myServer));
    FileChanges fileChanges10 = change10.getFileChanges();
    assertEquals(Integer.valueOf(8), fileChanges10.count);
    // type names are part of API
    check(fileChanges10.files.get(0), "added", null, null, "root/a/file.txt", "a/file.txt");
    check(fileChanges10.files.get(1), "edited", null, null, "root/a/file2.txt", "a/file2.txt");
    check(fileChanges10.files.get(2), "removed", null, null, "root/b/file.txt", "b/file.txt");
    check(fileChanges10.files.get(3), "unchanged", null, null, "root/b/file3.txt", "b/file3.txt");
    check(fileChanges10.files.get(4), "added", null, true, "root/c", "c");
    check(fileChanges10.files.get(5), "edited", null, true, "root/c1", "c1");
    check(fileChanges10.files.get(6), "removed", null, true, "root/d", "d");
    check(fileChanges10.files.get(7), "copied", null, true, "root/e", "e");
}
Also used : SVcsRootImpl(jetbrains.buildServer.vcs.impl.SVcsRootImpl) MockVcsModification(jetbrains.buildServer.serverSide.impl.MockVcsModification) FileChanges(jetbrains.buildServer.server.rest.model.change.FileChanges) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) FileChange(jetbrains.buildServer.server.rest.model.change.FileChange) Change(jetbrains.buildServer.server.rest.model.change.Change) Test(org.testng.annotations.Test)

Example 15 with MockVcsSupport

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

the class BuildTypeTest method testBranchesCaseDiff.

// TW-49294
@Test
public void testBranchesCaseDiff() throws ExecutionException, InterruptedException {
    final BuildTypeEx bt = getRootProject().createProject("Project1", "Project test 1").createBuildType("testBT", "My test build type");
    final BuildTypeRequest buildTypeRequest = new BuildTypeRequest();
    buildTypeRequest.setInTests(myBuildTypeFinder, myBranchFinder, myBeanContext);
    MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
    BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(collectChangesPolicy);
    final SVcsRoot vcsRoot = bt.getProject().createVcsRoot("vcs", "extId", "name");
    bt.addVcsRoot(vcsRoot);
    final VcsRootInstance vcsRootInstance = bt.getVcsRootInstances().get(0);
    collectChangesPolicy.setCurrentState(vcsRootInstance, createVersionState("master", map("master", "1", "aaa", "2", "bbb", "2", "Aaa", "3")));
    setBranchSpec(vcsRootInstance, "+:*");
    myFixture.getVcsModificationChecker().checkForModifications(bt.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    Branches branches = buildTypeRequest.serveBranches("id:testBT", "policy:ALL_BRANCHES", Fields.ALL_NESTED.getFieldsSpec());
    assertEquals("<default>", branches.branches.get(0).getInternalName());
    assertEquals("Aaa", branches.branches.get(1).getInternalName());
    assertEquals("aaa", branches.branches.get(2).getInternalName());
    assertEquals("bbb", branches.branches.get(3).getInternalName());
}
Also used : SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) BuildTypeRequest(jetbrains.buildServer.server.rest.request.BuildTypeRequest) Branches(jetbrains.buildServer.server.rest.model.build.Branches) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildFinderTestBase(jetbrains.buildServer.server.rest.data.BuildFinderTestBase) VcsRootInstance(jetbrains.buildServer.vcs.VcsRootInstance) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

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