Search in sources :

Example 6 with TestName

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));
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) TestName(jetbrains.buildServer.tests.TestName) TestNameResponsibilityFacade(jetbrains.buildServer.responsibility.TestNameResponsibilityFacade) SUser(jetbrains.buildServer.users.SUser) TestNameResponsibilityEntryImpl(jetbrains.buildServer.responsibility.impl.TestNameResponsibilityEntryImpl) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 7 with TestName

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());
    }
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) BuildTypeEx(jetbrains.buildServer.serverSide.BuildTypeEx) TestName(jetbrains.buildServer.tests.TestName) SUser(jetbrains.buildServer.users.SUser) STest(jetbrains.buildServer.serverSide.STest) Mutes(jetbrains.buildServer.server.rest.model.problem.Mutes) STest(jetbrains.buildServer.serverSide.STest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Aggregations

TestName (jetbrains.buildServer.tests.TestName)7 Test (org.testng.annotations.Test)6 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)5 SUser (jetbrains.buildServer.users.SUser)5 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)3 Mutes (jetbrains.buildServer.server.rest.model.problem.Mutes)3 BuildTypeEx (jetbrains.buildServer.serverSide.BuildTypeEx)3 STest (jetbrains.buildServer.serverSide.STest)3 Date (java.util.Date)2 TestNameResponsibilityFacade (jetbrains.buildServer.responsibility.TestNameResponsibilityFacade)2 TestNameResponsibilityEntryImpl (jetbrains.buildServer.responsibility.impl.TestNameResponsibilityEntryImpl)2 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)2 InvestigationWrapper (jetbrains.buildServer.server.rest.data.investigations.InvestigationWrapper)1 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)1 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)1 Investigation (jetbrains.buildServer.server.rest.model.buildType.Investigation)1 Investigations (jetbrains.buildServer.server.rest.model.buildType.Investigations)1 TestName2Index (jetbrains.buildServer.serverSide.TestName2Index)1 Nullable (org.jetbrains.annotations.Nullable)1