Search in sources :

Example 6 with MockVcsSupport

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

the class BranchFinderTest method testBranchExists.

@Test
public void testBranchExists() {
    final BuildTypeEx bt = registerBuildType("10", "Project");
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    vcs.setDAGBased(true);
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot = myFixture.addVcsRoot(vcs.getName(), "", bt);
    VcsRootInstance root = bt.getVcsRootInstanceForParent(parentRoot);
    assert root != null;
    setBranchSpec(root, "+:*");
    final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(changesPolicy);
    SVcsModification m10 = myFixture.addModification(modification().in(root).version("10").parentVersions("1"));
    SVcsModification m20 = myFixture.addModification(modification().in(root).version("20").parentVersions("1"));
    SVcsModification m30 = myFixture.addModification(modification().in(root).version("30").parentVersions("1"));
    changesPolicy.setCurrentState(root, RepositoryStateData.createVersionState("master", Util.map("master", "10", "branch1", "20", "branch2", "30")));
    myFixture.getVcsModificationChecker().checkForModifications(bt.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    assertTrue("There are more than one branch by this locator.", myBranchFinder.itemsExist(new Locator("buildType:(id:" + bt.getExternalId() + ")")));
    assertTrue("Should find default branch.", myBranchFinder.itemsExist(new Locator("buildType:(id:" + bt.getExternalId() + "),default:true")));
    assertTrue("Should find non-default branch.", myBranchFinder.itemsExist(new Locator("buildType:(id:" + bt.getExternalId() + "),default:false")));
    assertTrue("Should find branch by name.", myBranchFinder.itemsExist(new Locator("buildType:(id:" + bt.getExternalId() + "),name:branch1")));
    assertFalse("Should not find branch of there isn't one.", myBranchFinder.itemsExist(new Locator("buildType:(id:" + bt.getExternalId() + "),name:branch999")));
}
Also used : BuildTypeEx(jetbrains.buildServer.serverSide.BuildTypeEx) ServiceLocator(jetbrains.buildServer.ServiceLocator) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) Test(org.testng.annotations.Test)

Example 7 with MockVcsSupport

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

the class BranchFinderTest method testBranchesFromDependencies.

@Test
public void testBranchesFromDependencies() {
    final BuildTypeEx bt10 = registerBuildType("10", "Project");
    final BuildTypeEx bt20 = registerBuildType("20", "Project");
    createDependencyChain(bt20, bt10);
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    vcs.setDAGBased(true);
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", bt10);
    SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", bt20);
    VcsRootInstance root1 = bt10.getVcsRootInstanceForParent(parentRoot1);
    VcsRootInstance root2 = bt20.getVcsRootInstanceForParent(parentRoot2);
    assert root1 != null;
    assert root2 != null;
    setBranchSpec(root1, "+:*");
    setBranchSpec(root2, "+:*");
    final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(changesPolicy);
    SVcsModification m10 = myFixture.addModification(modification().in(root1).version("10").parentVersions("1"));
    SVcsModification m20 = myFixture.addModification(modification().in(root1).version("20").parentVersions("1"));
    SVcsModification m30 = myFixture.addModification(modification().in(root1).version("30").parentVersions("1"));
    SVcsModification n10 = myFixture.addModification(modification().in(root2).version("10").parentVersions("1"));
    SVcsModification n20 = myFixture.addModification(modification().in(root2).version("20").parentVersions("1"));
    SVcsModification n30 = myFixture.addModification(modification().in(root2).version("30").parentVersions("1"));
    changesPolicy.setCurrentState(root1, RepositoryStateData.createVersionState("master", Util.map("master", "10", "branch1", "20", "branch2", "30")));
    changesPolicy.setCurrentState(root2, RepositoryStateData.createVersionState("master", Util.map("master", "10", "branch2", "20", "branch3", "30")));
    myFixture.getVcsModificationChecker().checkForModifications(bt10.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    myFixture.getVcsModificationChecker().checkForModifications(bt20.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    check("buildType:(id:" + bt10.getExternalId() + ")", "<default>", "branch1", "branch2");
    check("buildType:(id:" + bt20.getExternalId() + ")", "<default>", "branch2", "branch3");
    check("buildType:(id:" + bt20.getExternalId() + "),changesFromDependencies:true", "<default>", "branch1", "branch2", "branch3");
    check("buildType:(id:" + bt20.getExternalId() + "),changesFromDependencies:false", "<default>", "branch2", "branch3");
    bt20.setOption(BuildTypeOptions.BT_SHOW_DEPS_CHANGES, true);
    check("buildType:(id:" + bt20.getExternalId() + ")", "<default>", "branch1", "branch2", "branch3");
    check("buildType:(id:" + bt20.getExternalId() + "),changesFromDependencies:false", "<default>", "branch2", "branch3");
    check("buildType:(id:" + bt20.getExternalId() + "),changesFromDependencies:true", "<default>", "branch1", "branch2", "branch3");
    checkExceptionOnItemsSearch(LocatorProcessException.class, "buildType:(id:" + bt20.getExternalId() + "),changesFromDependencies:any");
}
Also used : BuildTypeEx(jetbrains.buildServer.serverSide.BuildTypeEx) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) Test(org.testng.annotations.Test)

Example 8 with MockVcsSupport

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

the class BuildTypeTest method testBranches.

@Test
public void testBranches() 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);
    Branches branches = buildTypeRequest.serveBranches("id:testBT", null, null);
    ProjectRequestTest.assertBranchesEquals(branches.branches, "<default>", true, null);
    branches = buildTypeRequest.serveBranches("id:testBT", null, Fields.ALL_NESTED.getFieldsSpec());
    ProjectRequestTest.assertBranchesEquals(branches.branches, "<default>", true, false);
    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", "branch1", "2", "branch2", "3")));
    setBranchSpec(vcsRootInstance, "+:*");
    branches = buildTypeRequest.serveBranches("id:testBT", null, null);
    // why default before checking for changes???
    ProjectRequestTest.assertBranchesEquals(branches.branches, "<default>", true, null);
    myFixture.getVcsModificationChecker().checkForModifications(bt.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    branches = buildTypeRequest.serveBranches("id:testBT", null, null);
    ProjectRequestTest.assertBranchesEquals(branches.branches, "master", true, null);
    branches = buildTypeRequest.serveBranches("id:testBT", "policy:ALL_BRANCHES", null);
    ProjectRequestTest.assertBranchesEquals(branches.branches, "master", true, null, "branch1", null, null, "branch2", null, null);
    assertNull(branches.branches.get(0).getInternalName());
    branches = buildTypeRequest.serveBranches("id:testBT", "policy:ALL_BRANCHES", Fields.ALL_NESTED.getFieldsSpec());
    assertEquals("<default>", branches.branches.get(0).getInternalName());
    assertEquals("branch1", branches.branches.get(1).getInternalName());
    assertEquals("branch2", branches.branches.get(2).getInternalName());
    branches = buildTypeRequest.serveBranches("id:testBT", "policy:all_branches", null);
    ProjectRequestTest.assertBranchesEquals(branches.branches, "master", true, null, "branch1", null, null, "branch2", null, null);
    branches = buildTypeRequest.serveBranches("id:testBT", "default:true", null);
    ProjectRequestTest.assertBranchesEquals(branches.branches, "master", true, null);
    bt.addVcsRoot(bt.getProject().createVcsRoot("vcs", "extId2", "name2"));
    final VcsRootInstance vcsRootInstance2 = bt.getVcsRootInstances().get(1);
    collectChangesPolicy.setCurrentState(vcsRootInstance2, createVersionState("master2", map("master2", "1", "branch1", "2", "branch2", "3")));
    setBranchSpec(vcsRootInstance2, "+:*");
    myFixture.getVcsModificationChecker().checkForModifications(bt.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    branches = buildTypeRequest.serveBranches("id:testBT", "policy:ALL_BRANCHES", Fields.ALL_NESTED.getFieldsSpec());
    ProjectRequestTest.assertBranchesEquals(branches.branches, "<default>", true, false, "branch1", false, false, "branch2", false, false);
    assertEquals("<default>", branches.branches.get(0).getInternalName());
    checkException(LocatorProcessException.class, new Runnable() {

        public void run() {
            buildTypeRequest.serveBranches("id:testBT", "changesFromDependencies:any", null);
        }
    }, "searching with wrong changesFromDependencies");
    checkException(BadRequestException.class, new Runnable() {

        public void run() {
            buildTypeRequest.serveBranches("id:testBT", "policy:INVALID_POLICY", null);
        }
    }, "searching with wrong changesFromDependencies");
// can also add test for branches from builds
// can also add test for "changesFromDependencies:true" locator and several defaults in different branches
}
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)

Example 9 with MockVcsSupport

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

the class BuildTypeTest method testInheritance.

@Test
public void testInheritance() {
    // see also alike setup in BuildTypeRequestTest.testCreatingWithTemplate()
    ProjectEx project10 = createProject("project10", "project 10");
    MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
    final SVcsRoot vcsRoot10 = project10.createVcsRoot("vcs", "extId10", "name10");
    final SVcsRoot vcsRoot20 = project10.createVcsRoot("vcs", "extId20", "name20");
    final SVcsRoot vcsRoot30 = project10.createVcsRoot("vcs", "extId30", "name30");
    project10.addParameter(new SimpleParameter("p", "v"));
    BuildTypeEx bt100 = project10.createBuildType("bt100", "bt 100");
    BuildTypeEx bt110 = project10.createBuildType("bt110", "bt 110");
    BuildTypeEx bt120 = project10.createBuildType("bt120", "bt 120");
    // TEMPLATE
    BuildTypeTemplate t10 = project10.createBuildTypeTemplate("t10", "bt 10");
    t10.setArtifactPaths("aaaaa");
    t10.setBuildNumberPattern("pattern");
    t10.setOption(BuildTypeOptions.BT_ALLOW_EXTERNAL_STATUS, true);
    t10.setOption(BuildTypeOptions.BT_CHECKOUT_DIR, "checkout_t");
    t10.setOption(BuildTypeOptions.BT_CHECKOUT_MODE, "ON_AGENT");
    t10.setOption(BuildTypeOptions.BT_FAIL_ON_ANY_ERROR_MESSAGE, true);
    t10.setOption(BuildTypeOptions.BT_EXECUTION_TIMEOUT, 11);
    t10.addVcsRoot(vcsRoot10);
    t10.addVcsRoot(vcsRoot20);
    t10.setCheckoutRules(vcsRoot20, new CheckoutRules("a=>b"));
    BuildRunnerDescriptorFactory runnerDescriptorFactory = myFixture.getSingletonService(BuildRunnerDescriptorFactory.class);
    t10.addBuildRunner(runnerDescriptorFactory.createBuildRunner(project10, "run10", "name10", "Ant1", map("a", "b")));
    t10.addBuildRunner(runnerDescriptorFactory.createBuildRunner(project10, "run20", "name20", "Ant2", map("a", "b")));
    BuildTriggerDescriptor trigger10 = t10.addBuildTrigger("Type", map("a", "b"));
    BuildTriggerDescriptor trigger20 = t10.addBuildTrigger("Type", map("a", "b"));
    t10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f10", "type", map("a", "b")));
    t10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f20", "type", map("a", "b")));
    t10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f30", "type", map("a", "b")));
    ArtifactDependencyFactory artifactDependencyFactory = myFixture.getSingletonService(ArtifactDependencyFactory.class);
    ArrayList<SArtifactDependency> artifactDeps = new ArrayList<>();
    artifactDeps.add(artifactDependencyFactory.createArtifactDependency("art10", bt100.getExternalId(), "path1", RevisionRules.LAST_PINNED_RULE));
    artifactDeps.add(artifactDependencyFactory.createArtifactDependency("art20", bt100.getExternalId(), "path2", RevisionRules.LAST_PINNED_RULE));
    artifactDeps.add(artifactDependencyFactory.createArtifactDependency("art30", bt100.getExternalId(), "path3", RevisionRules.LAST_PINNED_RULE));
    t10.setArtifactDependencies(artifactDeps);
    t10.addDependency(myFixture.getSingletonService(DependencyFactory.class).createDependency(bt100));
    t10.addDependency(myFixture.getSingletonService(DependencyFactory.class).createDependency(bt110));
    t10.addParameter(new SimpleParameter("a10", "b"));
    t10.addParameter(new SimpleParameter("a20", "b"));
    t10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req10", "a", null, RequirementType.EXISTS));
    t10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req20", "b", null, RequirementType.EXISTS));
    t10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req30", "c", null, RequirementType.EXISTS));
    // BUILD TYPE
    BuildTypeEx bt10 = project10.createBuildType("bt10", "bt 10");
    bt10.attachToTemplate(t10);
    // todo: test w/o override
    bt10.setArtifactPaths("bbbb");
    bt10.setOption(BuildTypeOptions.BT_ALLOW_EXTERNAL_STATUS, false);
    bt10.setOption(BuildTypeOptions.BT_CHECKOUT_DIR, "checkout_bt");
    bt10.setOption(BuildTypeOptions.BT_CHECKOUT_MODE, "ON_AGENT");
    bt10.setOption(BuildTypeOptions.BT_EXECUTION_TIMEOUT, 17);
    bt10.addVcsRoot(vcsRoot20);
    bt10.setCheckoutRules(vcsRoot20, new CheckoutRules("x=>y"));
    bt10.addVcsRoot(vcsRoot30);
    bt10.setEnabled("run20", false);
    bt10.addBuildRunner(runnerDescriptorFactory.createBuildRunner(project10, "run30", "name30", "Ant30", map("a", "b")));
    bt10.setEnabled(trigger20.getId(), false);
    BuildTriggerDescriptor trigger30 = bt10.addBuildTrigger("Type", map("a", "b"));
    bt10.setEnabled("f20", false);
    bt10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f30", "type_bt", map("a", "b")));
    bt10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f40", "type", map("a", "b")));
    ArrayList<SArtifactDependency> artifactDepsBt = new ArrayList<>();
    artifactDepsBt.add(artifactDependencyFactory.createArtifactDependency("art30", bt100.getExternalId(), "path30", RevisionRules.LAST_FINISHED_RULE));
    artifactDepsBt.add(artifactDependencyFactory.createArtifactDependency("art40", bt100.getExternalId(), "path4", RevisionRules.LAST_PINNED_RULE));
    bt10.setArtifactDependencies(artifactDepsBt);
    bt10.setEnabled("art20", false);
    bt10.addDependency(myFixture.getSingletonService(DependencyFactory.class).createDependency(bt110));
    bt10.addDependency(myFixture.getSingletonService(DependencyFactory.class).createDependency(bt120));
    bt10.addParameter(new SimpleParameter("a20", "x"));
    bt10.addParameter(new SimpleParameter("a30", "x"));
    bt10.setEnabled("req20", false);
    bt10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req30", "x", null, RequirementType.EQUALS));
    bt10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req40", "y", null, RequirementType.EXISTS));
    // NOW, TEST TIME!
    BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt10), new Fields("$long"), myBeanContext);
    parameterEquals(find(buildType.getSettings().properties, "artifactRules"), "artifactRules", "bbbb", null);
    parameterEquals(find(buildType.getSettings().properties, "buildNumberPattern"), "buildNumberPattern", "pattern", true);
    parameterEquals(find(buildType.getSettings().properties, "allowExternalStatus"), "allowExternalStatus", "false", null);
    parameterEquals(find(buildType.getSettings().properties, "checkoutDirectory"), "checkoutDirectory", "checkout_bt", null);
    // parameterEquals(find(buildType.getSettings().properties, "checkoutMode"), "checkoutMode", "ON_AGENT", null); //option set to the same value in bt - API does not make difference so far
    parameterEquals(find(buildType.getSettings().properties, "shouldFailBuildOnAnyErrorMessage"), "shouldFailBuildOnAnyErrorMessage", "true", true);
    parameterEquals(find(buildType.getSettings().properties, "executionTimeoutMin"), "executionTimeoutMin", "17", null);
    // default value
    assertNull(find(buildType.getSettings().properties, "showDependenciesChanges"));
    assertEquals(3, buildType.getVcsRootEntries().vcsRootAssignments.size());
    vcsRootEntryEquals(buildType.getVcsRootEntries().vcsRootAssignments.get(0), vcsRoot10.getExternalId(), "", true);
    // bt modifications are ignored
    vcsRootEntryEquals(buildType.getVcsRootEntries().vcsRootAssignments.get(1), vcsRoot20.getExternalId(), "a=>b", true);
    vcsRootEntryEquals(buildType.getVcsRootEntries().vcsRootAssignments.get(2), vcsRoot30.getExternalId(), "", null);
    assertEquals(3, buildType.getSteps().propEntities.size());
    stepsEquals(buildType.getSteps().propEntities.get(0), "run10", "Ant1", null, true);
    stepsEquals(buildType.getSteps().propEntities.get(1), "run20", "Ant2", false, true);
    stepsEquals(buildType.getSteps().propEntities.get(2), "run30", "Ant30", null, null);
    // TeamCity issue: order of some entities depends on where the trigger is defined (build type or template)
    assertEquals(3, buildType.getTriggers().propEntities.size());
    stepsEquals(buildType.getTriggers().propEntities.get(0), trigger30.getId(), "Type", null, null);
    stepsEquals(buildType.getTriggers().propEntities.get(1), trigger10.getId(), "Type", null, true);
    stepsEquals(buildType.getTriggers().propEntities.get(2), trigger20.getId(), "Type", false, true);
    assertEquals(4, buildType.getFeatures().propEntities.size());
    stepsEquals(buildType.getFeatures().propEntities.get(0), "f30", "type_bt", null, null);
    stepsEquals(buildType.getFeatures().propEntities.get(1), "f40", "type", null, null);
    stepsEquals(buildType.getFeatures().propEntities.get(2), "f10", "type", null, true);
    stepsEquals(buildType.getFeatures().propEntities.get(3), "f20", "type", false, true);
    assertEquals(4, buildType.getArtifactDependencies().propEntities.size());
    stepsEquals(buildType.getArtifactDependencies().propEntities.get(0), "art30", "artifact_dependency", null, null);
    stepsEquals(buildType.getArtifactDependencies().propEntities.get(1), "art40", "artifact_dependency", null, null);
    stepsEquals(buildType.getArtifactDependencies().propEntities.get(2), "art10", "artifact_dependency", null, true);
    stepsEquals(buildType.getArtifactDependencies().propEntities.get(3), "art20", "artifact_dependency", false, true);
    assertEquals(3, buildType.getSnapshotDependencies().propEntities.size());
    stepsEquals(buildType.getSnapshotDependencies().propEntities.get(0), bt100.getExternalId(), "snapshot_dependency", null, true);
    stepsEquals(buildType.getSnapshotDependencies().propEntities.get(1), bt110.getExternalId(), "snapshot_dependency", null, true);
    stepsEquals(buildType.getSnapshotDependencies().propEntities.get(2), bt120.getExternalId(), "snapshot_dependency", null, null);
    assertEquals(4, buildType.getParameters().properties.size());
    parameterEquals(buildType.getParameters().properties.get(0), "a10", "b", true);
    parameterEquals(buildType.getParameters().properties.get(1), "a20", "x", null);
    parameterEquals(buildType.getParameters().properties.get(2), "a30", "x", null);
    parameterEquals(buildType.getParameters().properties.get(3), "p", "v", true);
    assertEquals(4, buildType.getAgentRequirements().propEntities.size());
    stepsEquals(buildType.getAgentRequirements().propEntities.get(0), "req30", "equals", null, null);
    stepsEquals(buildType.getAgentRequirements().propEntities.get(1), "req40", "exists", null, null);
    stepsEquals(buildType.getAgentRequirements().propEntities.get(2), "req10", "exists", null, true);
    stepsEquals(buildType.getAgentRequirements().propEntities.get(3), "req20", "exists", false, true);
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) ArrayList(java.util.ArrayList) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) BuildTriggerDescriptor(jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor) SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Example 10 with MockVcsSupport

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

the class ChangeFinderTest method testVersionedSettings.

@Test
public void testVersionedSettings() {
    ProjectEx project = getRootProject().createProject("project", "project");
    project.persist();
    final BuildTypeEx buildConf = project.createBuildType("buildConf1");
    buildConf.persist();
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf);
    VcsRootInstance root1 = buildConf.getVcsRootInstanceForParent(parentRoot1);
    assert root1 != null;
    SVcsRoot vsRoot = project.createVcsRoot(vcsSupport().withName("vcs1").dagBased(true).register().getName(), "Settings Root", map());
    VcsRootInstance vsInstance = resolveInProject(vsRoot, project);
    myFixture.getSingletonService(RepositoryStateManager.class).setRepositoryState(vsInstance, createRepositoryState(map("default", "vs10"), "default"));
    VersionedSettingsConfig vsConfig = new VersionedSettingsConfig();
    vsConfig.setVcsRootExternalId(vsRoot.getExternalId());
    vsConfig.setEnabled(true);
    vsConfig.setShowSettingsChanges(true);
    vsConfig.setBuildSettingsMode(VersionedSettingsConfig.BuildSettingsMode.PREFER_VCS);
    myFixture.writeVersionedSettingsConfig(project, vsConfig);
    SVcsModification m20 = myFixture.addModification(modification().in(root1).by("user1").version("m20").parentVersions("m10"));
    SVcsModification vs_m20 = myFixture.addModification(modification().in(vsInstance).version("vs20").parentVersions("vs10"), buildConf, RelationType.SETTINGS_AFFECT_BUILDS);
    myFixture.getSingletonService(RepositoryStateManager.class).setRepositoryState(vsInstance, createRepositoryState(map("default", "vs20"), "default"));
    // myFixture.getVcsModificationChecker().checkForModifications(buildConf.getVcsRootInstances(), OperationRequestor.UNKNOWN);
    // myFixture.getVcsModificationChecker().checkForModifications(Collections.singleton(vsInstance), OperationRequestor.UNKNOWN);
    check(null, vs_m20, m20);
    String bt = "buildType:(" + buildConf.getExternalId() + ")";
    check(bt, vs_m20, m20);
    check(bt + ",versionedSettings:true", vs_m20);
    check(bt + ",versionedSettings:false", m20);
    check(bt + ",versionedSettings:any", vs_m20, m20);
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) RepositoryStateManager(jetbrains.buildServer.vcs.impl.RepositoryStateManager) VersionedSettingsConfig(jetbrains.buildServer.serverSide.impl.versionedSettings.VersionedSettingsConfig) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) 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