Search in sources :

Example 1 with Investigation

use of jetbrains.buildServer.server.rest.model.buildType.Investigation in project teamcity-rest by JetBrains.

the class InvestigationRequestTest method testAssignInvestigation.

@Test
void testAssignInvestigation() throws Throwable {
    final SUser user2 = createUser("user2");
    Investigation investigation = new Investigation();
    investigation.state = "taken";
    investigation.assignee = new User();
    investigation.assignee.setId(user2.getId());
    investigation.assignment = new Comment();
    investigation.assignment.text = "comment here";
    investigation.scope = new ProblemScope();
    investigation.scope.project = new Project();
    investigation.scope.project.id = myProject.getExternalId();
    investigation.target = new ProblemTarget();
    investigation.target.tests = new Tests();
    jetbrains.buildServer.server.rest.model.problem.Test test = new jetbrains.buildServer.server.rest.model.problem.Test();
    test.name = "testname";
    investigation.target.tests.items = Collections.singletonList(test);
    investigation.resolution = new Resolution();
    investigation.resolution.type = Resolution.ResolutionType.manually;
    investigation.resolution.time = "20900512T163700";
    assertEmpty(myInvestigationFinder.getItems(null).myEntries);
    createBuildWithFailedTest("testname");
    Investigation result = myRequest.createInstance(investigation, "$long");
    assertEquals("testname", result.target.tests.items.get(0).name);
    List<InvestigationWrapper> currentInvestigations = myInvestigationFinder.getItems(null).myEntries;
    assertEquals(1, currentInvestigations.size());
    InvestigationWrapper investigationWrapper = currentInvestigations.get(0);
    assertEquals(ResponsibilityEntry.State.TAKEN, investigationWrapper.getState());
    assertEquals(user2.getId(), investigationWrapper.getResponsibleUser().getId());
    assertEquals("comment here", investigationWrapper.getComment());
    assertEquals(null, investigationWrapper.getProblemRE());
    assertEquals(myProject.getProjectId(), investigationWrapper.getTestRE().getProjectId());
    assertEquals("testname", investigationWrapper.getTestRE().getTestName().getAsString());
    assertEquals(myProject.getProjectId(), investigationWrapper.getAssignmentProject().getProjectId());
    myRequest.deleteInstance(investigationWrapper.getId());
    assertEmpty(myInvestigationFinder.getItems(null).myEntries);
}
Also used : Comment(jetbrains.buildServer.server.rest.model.Comment) InvestigationWrapper(jetbrains.buildServer.server.rest.data.investigations.InvestigationWrapper) User(jetbrains.buildServer.server.rest.model.user.User) SUser(jetbrains.buildServer.users.SUser) ProblemTarget(jetbrains.buildServer.server.rest.model.buildType.ProblemTarget) SUser(jetbrains.buildServer.users.SUser) Tests(jetbrains.buildServer.server.rest.model.problem.Tests) ProblemScope(jetbrains.buildServer.server.rest.model.buildType.ProblemScope) Project(jetbrains.buildServer.server.rest.model.project.Project) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test) Investigation(jetbrains.buildServer.server.rest.model.buildType.Investigation) Resolution(jetbrains.buildServer.server.rest.model.problem.Resolution) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) Test(org.testng.annotations.Test)

Example 2 with Investigation

use of jetbrains.buildServer.server.rest.model.buildType.Investigation in project teamcity-rest by JetBrains.

the class InvestigationFinderTest method testTestInvestigationModel.

@Test
public void testTestInvestigationModel() throws Exception {
    createFailingBuild();
    final TestName testName = new TestName(FAIL_TEST2_NAME);
    myFixture.getResponsibilityFacadeEx().setTestNameResponsibility(testName, myProject.getProjectId(), createRespEntry(ResponsibilityEntry.State.TAKEN, myUser));
    final PagedSearchResult<InvestigationWrapper> ivestigationWrappers = myInvestigationFinder.getItems((String) null);
    final Investigations investigations = new Investigations(ivestigationWrappers.myEntries, null, Fields.LONG, getBeanContext(myServer));
    assertEquals(1, investigations.count.longValue());
    final Investigation investigation = investigations.items.get(0);
    final TestName2Index testName2Index = myFixture.getSingletonService(TestName2Index.class);
    assertEquals("assignmentProject:(id:" + myProject.getExternalId() + "),test:(id:" + testName2Index.findTestNameId(testName) + ")", investigation.id);
    assertEquals("TAKEN", investigation.state);
    assertEquals((Long) myUser.getId(), investigation.assignee.getId());
    assertEquals("The comment", investigation.assignment.text);
    assertEquals(null, investigation.target.anyProblem);
    assertEquals(null, investigation.target.problems);
    assertEquals(FAIL_TEST2_NAME, investigation.target.tests.items.get(0).name);
    assertEquals(null, investigation.scope.buildTypes);
    assertEquals(myProject.getExternalId(), investigation.scope.project.id);
}
Also used : TestName(jetbrains.buildServer.tests.TestName) InvestigationWrapper(jetbrains.buildServer.server.rest.data.investigations.InvestigationWrapper) Investigation(jetbrains.buildServer.server.rest.model.buildType.Investigation) TestName2Index(jetbrains.buildServer.serverSide.TestName2Index) Investigations(jetbrains.buildServer.server.rest.model.buildType.Investigations) Test(org.testng.annotations.Test)

Example 3 with Investigation

use of jetbrains.buildServer.server.rest.model.buildType.Investigation in project teamcity-rest by JetBrains.

the class InvestigationFinderTest method testProblemInvestigationModel.

@Test
public void testProblemInvestigationModel() throws Exception {
    createFailingBuild();
    final BuildProblemInfoImpl buildProblem = new BuildProblemInfoImpl(myProject.getProjectId(), getProblemId(PROBLEM_IDENTITY));
    myFixture.getResponsibilityFacadeEx().setBuildProblemResponsibility(buildProblem, myProject.getProjectId(), createRespEntry(ResponsibilityEntry.State.TAKEN, myUser));
    final BuildProblemResponsibilityEntry buildProblemResponsibility = myFixture.getResponsibilityFacadeEx().findBuildProblemResponsibility(buildProblem, myProject.getProjectId());
    assert buildProblemResponsibility != null;
    final PagedSearchResult<InvestigationWrapper> ivestigationWrappers = myInvestigationFinder.getItems((String) null);
    final Investigations investigations = new Investigations(ivestigationWrappers.myEntries, null, Fields.LONG, getBeanContext(myServer));
    assertEquals(1, investigations.count.longValue());
    final Investigation investigation = investigations.items.get(0);
    assertEquals("assignmentProject:(id:" + myProject.getExternalId() + "),problem:(id:" + buildProblemResponsibility.getBuildProblemInfo().getId() + ")", investigation.id);
    assertEquals("TAKEN", investigation.state);
    assertEquals((Long) myUser.getId(), investigation.assignee.getId());
    assertEquals("The comment", investigation.assignment.text);
    assertEquals(null, investigation.target.anyProblem);
    assertEquals(null, investigation.target.tests);
    assertEquals(PROBLEM_IDENTITY, investigation.target.problems.items.get(0).identity);
    assertEquals(myProject.getExternalId(), investigation.scope.project.id);
}
Also used : InvestigationWrapper(jetbrains.buildServer.server.rest.data.investigations.InvestigationWrapper) BuildProblemResponsibilityEntry(jetbrains.buildServer.responsibility.BuildProblemResponsibilityEntry) Investigation(jetbrains.buildServer.server.rest.model.buildType.Investigation) BuildProblemInfoImpl(jetbrains.buildServer.serverSide.impl.problems.BuildProblemInfoImpl) Investigations(jetbrains.buildServer.server.rest.model.buildType.Investigations) Test(org.testng.annotations.Test)

Example 4 with Investigation

use of jetbrains.buildServer.server.rest.model.buildType.Investigation in project teamcity-rest by JetBrains.

the class InvestigationFinderTest method testBuildTypeInvestigationModel.

@Test
public void testBuildTypeInvestigationModel() throws Exception {
    createFailingBuild();
    myFixture.getResponsibilityFacadeEx().setBuildTypeResponsibility(myBuildType, createRespEntry(ResponsibilityEntry.State.TAKEN, myUser));
    final PagedSearchResult<InvestigationWrapper> ivestigationWrappers = myInvestigationFinder.getItems((String) null);
    final Investigations investigations = new Investigations(ivestigationWrappers.myEntries, null, Fields.ALL_NESTED, getBeanContext(myServer));
    assertEquals(1, investigations.count.longValue());
    final Investigation investigation = investigations.items.get(0);
    assertEquals("buildType:(id:" + myBuildType.getExternalId() + ")", investigation.id);
    assertEquals("TAKEN", investigation.state);
    assertEquals((Long) myUser.getId(), investigation.assignee.getId());
    assertEquals("The comment", investigation.assignment.text);
    assertEquals(Boolean.TRUE, investigation.target.anyProblem);
    assertEquals(null, investigation.target.problems);
    assertEquals(null, investigation.target.tests);
    assertEquals(myBuildType.getExternalId(), investigation.scope.buildTypes.buildTypes.get(0).getId());
    assertEquals(null, investigation.scope.project);
}
Also used : InvestigationWrapper(jetbrains.buildServer.server.rest.data.investigations.InvestigationWrapper) Investigation(jetbrains.buildServer.server.rest.model.buildType.Investigation) Investigations(jetbrains.buildServer.server.rest.model.buildType.Investigations) Test(org.testng.annotations.Test)

Aggregations

InvestigationWrapper (jetbrains.buildServer.server.rest.data.investigations.InvestigationWrapper)4 Investigation (jetbrains.buildServer.server.rest.model.buildType.Investigation)4 Test (org.testng.annotations.Test)4 Investigations (jetbrains.buildServer.server.rest.model.buildType.Investigations)3 BuildProblemResponsibilityEntry (jetbrains.buildServer.responsibility.BuildProblemResponsibilityEntry)1 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)1 Comment (jetbrains.buildServer.server.rest.model.Comment)1 ProblemScope (jetbrains.buildServer.server.rest.model.buildType.ProblemScope)1 ProblemTarget (jetbrains.buildServer.server.rest.model.buildType.ProblemTarget)1 Resolution (jetbrains.buildServer.server.rest.model.problem.Resolution)1 Tests (jetbrains.buildServer.server.rest.model.problem.Tests)1 Project (jetbrains.buildServer.server.rest.model.project.Project)1 User (jetbrains.buildServer.server.rest.model.user.User)1 TestName2Index (jetbrains.buildServer.serverSide.TestName2Index)1 BuildProblemInfoImpl (jetbrains.buildServer.serverSide.impl.problems.BuildProblemInfoImpl)1 TestName (jetbrains.buildServer.tests.TestName)1 SUser (jetbrains.buildServer.users.SUser)1