use of jetbrains.buildServer.tests.TestName 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.tests.TestName in project teamcity-rest by JetBrains.
the class MuteRequestTest method test_unmuteBuildType.
@Test
public void test_unmuteBuildType() {
final ProjectEx project = createProject("Project", "Project");
final BuildTypeEx bt1 = project.createBuildType("bt1");
final BuildTypeEx bt2 = project.createBuildType("bt2");
// just a child project
final ProjectEx projectChild = project.createProject("Project2", "Project2");
final BuildTypeEx bt21 = projectChild.createBuildType("bt21");
createBuild(bt1, new String[0], new String[] { "test1", "test2", "test3" });
createBuild(bt2, new String[0], new String[] { "test1", "test2", "test3", "test4" });
createBuild(bt21, new String[0], new String[] { "test1", "test2", "test3", "test4" });
final STest test1 = myFixture.getTestManager().createTest(new TestName("test1"), project.getProjectId());
final STest test2 = myFixture.getTestManager().createTest(new TestName("test2"), project.getProjectId());
SUser user = createUser("user");
{
Mutes mutes = myRequest.getMutes(null, null, null, null);
// assertEquals(Integer.valueOf(0), mutes.count); //todo: fix
assertEmpty(mutes.items);
}
myMutingService.muteTestsInBuildTypes(user, null, false, null, Arrays.asList(bt1, bt2), Arrays.asList(test1, test2), false);
{
Mutes mutes = myRequest.getMutes(null, null, null, null);
assertEquals(Integer.valueOf(1), mutes.count);
assertEquals(1, mutes.items.size());
assertNull(mutes.items.get(0).scope.project);
assertNotNull(mutes.items.get(0).scope.buildTypes);
assertEquals(2, mutes.items.get(0).scope.buildTypes.buildTypes.size());
assertTrue(mutes.items.get(0).scope.buildTypes.buildTypes.stream().anyMatch(buildType -> bt1.getExternalId().equals(buildType.getId())));
assertTrue(mutes.items.get(0).scope.buildTypes.buildTypes.stream().anyMatch(buildType -> bt2.getExternalId().equals(buildType.getId())));
assertNull(mutes.items.get(0).target.problems);
assertEquals(2, mutes.items.get(0).target.tests.items.size());
assertTrue(mutes.items.get(0).target.tests.items.stream().anyMatch(test -> String.valueOf(test1.getTestNameId()).equals(test.id)));
assertTrue(mutes.items.get(0).target.tests.items.stream().anyMatch(test -> String.valueOf(test2.getTestNameId()).equals(test.id)));
}
myMutingService.unmuteTests(user, null, bt1, Arrays.asList(test1, test2));
{
Mutes mutes = myRequest.getMutes(null, null, null, null);
assertEquals(Integer.valueOf(1), mutes.count);
assertEquals(1, mutes.items.size());
assertNull(mutes.items.get(0).scope.project);
assertNotNull(mutes.items.get(0).scope.buildTypes);
assertEquals(1, mutes.items.get(0).scope.buildTypes.buildTypes.size());
assertTrue(mutes.items.get(0).scope.buildTypes.buildTypes.stream().anyMatch(buildType -> bt2.getExternalId().equals(buildType.getId())));
assertNull(mutes.items.get(0).target.problems);
assertEquals(2, mutes.items.get(0).target.tests.items.size());
assertTrue(mutes.items.get(0).target.tests.items.stream().anyMatch(test -> String.valueOf(test1.getTestNameId()).equals(test.id)));
assertTrue(mutes.items.get(0).target.tests.items.stream().anyMatch(test -> String.valueOf(test2.getTestNameId()).equals(test.id)));
}
{
setInternalProperty(Mutes.REST_MUTES_ACTUAL_STATE, "true");
Mutes mutes = myRequest.getMutes(null, "$long,mute(target(tests(test(mutes(mute(scope(buildTypes($long))))))))", null, null);
assertEquals(1, mutes.items.get(0).target.tests.items.get(0).mutes.items.get(0).scope.buildTypes.buildTypes.size());
}
}
Aggregations