use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class ProjectRequestTest method testBranchesDiffInCaseOnly.
@Test
public void testBranchesDiffInCaseOnly() {
String prjId = "Project1";
ProjectEx project1 = getRootProject().createProject(prjId, "Project test 1");
String bt1Id = "testBT1";
String bt2Id = "testBT2";
final BuildTypeEx bt1 = project1.createBuildType(bt1Id, "My test build type 1");
final BuildTypeEx bt2 = project1.createBuildType(bt2Id, "My test build type 2");
final ProjectRequest request = new ProjectRequest();
request.setInTests(myProjectFinder, myBranchFinder, myBeanContext);
MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
BuildFinderTestBase.MockCollectRepositoryChangesPolicy collectChangesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
vcs.setCollectChangesPolicy(collectChangesPolicy);
setCurrentBranches(bt1, collectChangesPolicy, "master", map("master", "1", "aaa", "2", "bbb", "3", "Aaa", "3"));
setCurrentBranches(bt2, collectChangesPolicy, "Master", map("Master", "1", "bBb", "2", "ccc", "3"));
Branches branches = request.getBranches("id:" + prjId, "policy:ALL_BRANCHES", null);
assertBranchesEquals(branches.branches, "<default>", true, null, "Aaa", null, null, "aaa", null, null, "bBb", null, null, "bbb", null, null, "ccc", null, null);
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class VcsRootFinderTest method setUp.
@Override
@BeforeMethod
public void setUp() throws Exception {
super.setUp();
setFinder(myVcsRootFinder);
myFixture.registerVcsSupport("svn");
myFixture.registerVcsSupport("cvs");
final ProjectEx rootProject = myProjectManager.getRootProject();
myProject = rootProject.createProject("project1", "Project name");
myRoot10 = rootProject.createVcsRoot("svn", "id1", "VCS root 1 name");
myRoot20 = myProject.createVcsRoot("svn", "id2", "VCS root 2 name");
myRoot30 = myProject.createVcsRoot("cvs", "id3", "VCS root 3 name");
myRoot40 = rootProject.createVcsRoot("svn", "id4", "VCS root 4 name");
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class TestOccurrenceFinderTest method testInvestigationState.
@Test
public void testInvestigationState() throws Exception {
final BuildTypeImpl buildType = registerBuildType("buildConf1", "project1");
final SFinishedBuild build = build().in(buildType).withTest("aaa_active", false).withTest("bbb_fixed", false).withTest("ccc_given_up", false).withTest("ddd_none", false).finish();
long activeNameId = myFixture.getSingletonService(TestName2Index.class).getOrSaveTestNameId("aaa_active");
long fixedNameId = myFixture.getSingletonService(TestName2Index.class).getOrSaveTestNameId("bbb_fixed");
long givenUpNameId = myFixture.getSingletonService(TestName2Index.class).getOrSaveTestNameId("ccc_given_up");
SUser user = createUser("user");
ProjectEx project = myServer.getProjectManager().getRootProject().findProjectByName("project1");
TestNameResponsibilityEntryImpl activeEntry = new TestNameResponsibilityEntryImpl(new TestName("aaa_active"), activeNameId, ResponsibilityEntry.State.TAKEN, user, user, new Date(), "Please, fix", project, ResponsibilityEntry.RemoveMethod.MANUALLY);
TestNameResponsibilityEntryImpl fixedEntry = new TestNameResponsibilityEntryImpl(new TestName("bbb_fixed"), fixedNameId, ResponsibilityEntry.State.FIXED, user, user, new Date(), "Please, fix", project, ResponsibilityEntry.RemoveMethod.MANUALLY);
TestNameResponsibilityEntryImpl givenUpEntry = new TestNameResponsibilityEntryImpl(new TestName("ccc_given_up"), givenUpNameId, ResponsibilityEntry.State.GIVEN_UP, user, user, new Date(), "Please, fix", project, ResponsibilityEntry.RemoveMethod.MANUALLY);
TestNameResponsibilityFacade testNameResponsibilityFacade = myFixture.getSingletonService(TestNameResponsibilityFacade.class);
testNameResponsibilityFacade.setTestNameResponsibility(new TestName("aaa_active"), project.getProjectId(), activeEntry);
testNameResponsibilityFacade.setTestNameResponsibility(new TestName("bbb_fixed"), project.getProjectId(), fixedEntry);
testNameResponsibilityFacade.setTestNameResponsibility(new TestName("ccc_given_up"), project.getProjectId(), givenUpEntry);
TestRunData activeRunData = t("aaa_active", Status.FAILURE, 1);
TestRunData fixedRunData = t("bbb_fixed", Status.FAILURE, 2);
TestRunData givenUpRunData = t("ccc_given_up", Status.FAILURE, 3);
TestRunData noneRunData = t("ddd_none", Status.FAILURE, 4);
check("currentlyFailing:true,currentlyInvestigated:true", TEST_MATCHER, activeRunData);
check("currentlyFailing:true,currentlyInvestigated:false", TEST_MATCHER, fixedRunData, givenUpRunData, noneRunData);
check("currentlyFailing:true,investigationState:active", TEST_MATCHER, activeRunData);
check("currentlyFailing:true,investigationState:fixed", TEST_MATCHER, fixedRunData);
check("currentlyFailing:true,investigationState:givenUp", TEST_MATCHER, givenUpRunData);
check("currentlyFailing:true,investigationState:none", TEST_MATCHER, noneRunData);
check("currentlyFailing:true", TEST_MATCHER, activeRunData, fixedRunData, givenUpRunData, noneRunData);
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class TestOccurrenceFinderTest method testSameTestInDifferentBuilds.
@Test
public void testSameTestInDifferentBuilds() throws Exception {
final BuildTypeImpl buildType1 = registerBuildType("buildConf1", "project1");
final BuildTypeImpl buildType2 = registerBuildType("buildConf2", "project2");
final SFinishedBuild build10 = build().in(buildType1).withTest("aaa", false).finish();
final SFinishedBuild build20 = build().in(buildType2).withTest("aaa", false).finish();
check("currentlyFailing:true", TEST_MATCHER, t("aaa", Status.FAILURE, 1), t("aaa", Status.FAILURE, 1));
check("currentlyFailing:true,buildType:(id:" + buildType1.getExternalId() + ")", TEST_MATCHER, t("aaa", Status.FAILURE, 1));
STestRun testRun1 = getFinder().getItems("currentlyFailing:true").myEntries.get(0);
STestRun testRun2 = getFinder().getItems("currentlyFailing:true").myEntries.get(1);
assertEquals(testRun1.getBuildId(), build10.getBuildId());
assertEquals(testRun2.getBuildId(), build20.getBuildId());
check("currentlyFailing:true,currentlyInvestigated:false", TEST_MATCHER, t("aaa", Status.FAILURE, 1), t("aaa", Status.FAILURE, 1));
long nameId = myFixture.getSingletonService(TestName2Index.class).getOrSaveTestNameId("aaa");
SUser user = createUser("user");
ProjectEx project = myServer.getProjectManager().getRootProject().findProjectByName("project1");
TestNameResponsibilityEntryImpl testNameResponsibilityEntry = new TestNameResponsibilityEntryImpl(new TestName("aaa"), nameId, ResponsibilityEntry.State.TAKEN, user, user, new Date(), "Please, fix", project, ResponsibilityEntry.RemoveMethod.MANUALLY);
myFixture.getSingletonService(TestNameResponsibilityFacade.class).setTestNameResponsibility(new TestName("aaa"), project.getProjectId(), testNameResponsibilityEntry);
check("currentlyFailing:true,currentlyInvestigated:false", TEST_MATCHER, t("aaa", Status.FAILURE, 1));
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class BuildTypeRequestTest method testCreatingWithTemplate.
@Test
public void testCreatingWithTemplate() {
// see also alike setup in BuildTypeTest.testInheritance()
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_FAIL_IF_TESTS_FAIL, 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.addParameter(new SimpleParameter("a30", "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_FAIL_IF_TESTS_FAIL, false);
{
// hack to reproduce case related to https://youtrack.jetbrains.com/issue/TW-45273
// comment until TW-45273 is fixed t10.setOption(BuildTypeOptions.BT_FAIL_IF_TESTS_FAIL, false);
}
bt10.setOption(BuildTypeOptions.BT_CHECKOUT_DIR, "checkout_bt");
bt10.setOption(BuildTypeOptions.BT_CHECKOUT_MODE, "ON_SERVER");
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", "b"));
bt10.addParameter(new SimpleParameter("a40", "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!
// get buildType
BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt10), new Fields("$long"), getBeanContext(myServer));
// post buildType to create new one
buildType.initializeSubmittedFromUsual();
buildType.setId("bt10_copy");
buildType.setName("bt 10 - copy");
BuildType buildType_copy = myBuildTypeRequest.addBuildType(buildType, Fields.LONG.getFieldsSpec());
// compare initial and new buildType
BuildTypeImpl bt10_copy = myFixture.getProjectManager().findBuildTypeByExternalId("bt10_copy");
assertNotNull(bt10_copy);
assertNull(BuildTypeUtil.compareBuildTypes(bt10.getSettings(), bt10_copy.getSettings(), true, false));
// todo:
// check different settings in submitted from the inherited one, but with inherited flag
// check submitting with different enabled state
// check submitting with different id
}
Aggregations