Search in sources :

Example 1 with Investigations

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

the class BuildTypeTest method testSimple.

@Test
public void testSimple() {
    final BuildTypeEx bt = getRootProject().createProject("Project1", "Project test 1").createBuildType("testBT", "My test build type");
    final BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt), Fields.LONG, myBeanContext);
    assertEquals(bt.getName(), buildType.getName());
    assertEquals(bt.getProjectExternalId(), buildType.getProjectId());
    assertEquals(bt.getProjectName(), buildType.getProjectName());
    assertEquals(new Integer(0), buildType.getParameters().count);
    final Investigations investigations = buildType.getInvestigations();
    assertEquals(null, investigations.count);
    assertEquals("/app/rest/investigations?locator=buildType:(id:testBT)", investigations.href);
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) Investigations(jetbrains.buildServer.server.rest.model.buildType.Investigations) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Example 2 with Investigations

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

the class BuildTypeTest method testInvestigations.

@Test
public void testInvestigations() {
    final SUser user = createUser("user");
    final BuildTypeEx bt = getRootProject().createProject("Project1", "Project test 1").createBuildType("testBT", "My test build type");
    myFixture.getResponsibilityFacadeEx().setBuildTypeResponsibility(bt, createRespEntry(ResponsibilityEntry.State.TAKEN, user));
    BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt), Fields.LONG, myBeanContext);
    Investigations investigations = buildType.getInvestigations();
    assertEquals(null, investigations.count);
    assertEquals("/app/rest/investigations?locator=buildType:(id:testBT)", investigations.href);
    assertEquals(null, investigations.items);
    buildType = new BuildType(new BuildTypeOrTemplate(bt), new Fields("investigations($long)"), myBeanContext);
    investigations = buildType.getInvestigations();
    assertEquals(new Integer(1), investigations.count);
    assertEquals("/app/rest/investigations?locator=buildType:(id:testBT)", investigations.href);
    assertEquals(1, investigations.items.size());
    assertEquals(ResponsibilityEntry.State.TAKEN.name(), investigations.items.get(0).state);
    buildType = new BuildType(new BuildTypeOrTemplate(bt), new Fields("investigations($long,$locator(assignee(id:" + user.getId() + ")))"), myBeanContext);
    investigations = buildType.getInvestigations();
    assertEquals(new Integer(1), investigations.count);
    assertEquals("/app/rest/investigations?locator=assignee:(id:" + user.getId() + "),buildType:(id:testBT)", investigations.href);
    assertEquals(1, investigations.items.size());
    assertEquals(ResponsibilityEntry.State.TAKEN.name(), investigations.items.get(0).state);
    final SUser user2 = createUser("user2");
    buildType = new BuildType(new BuildTypeOrTemplate(bt), new Fields("investigations($long,count,$locator(assignee(id:" + user2.getId() + ")))"), myBeanContext);
    investigations = buildType.getInvestigations();
    assertEquals(new Integer(0), investigations.count);
    assertEquals("/app/rest/investigations?locator=assignee:(id:" + user2.getId() + "),buildType:(id:testBT)", investigations.href);
    assertNull(investigations.items);
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) SUser(jetbrains.buildServer.users.SUser) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) Investigations(jetbrains.buildServer.server.rest.model.buildType.Investigations) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Example 3 with Investigations

use of jetbrains.buildServer.server.rest.model.buildType.Investigations 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 4 with Investigations

use of jetbrains.buildServer.server.rest.model.buildType.Investigations 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 5 with Investigations

use of jetbrains.buildServer.server.rest.model.buildType.Investigations 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

Investigations (jetbrains.buildServer.server.rest.model.buildType.Investigations)5 Test (org.testng.annotations.Test)5 InvestigationWrapper (jetbrains.buildServer.server.rest.data.investigations.InvestigationWrapper)3 Investigation (jetbrains.buildServer.server.rest.model.buildType.Investigation)3 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)2 BuildType (jetbrains.buildServer.server.rest.model.buildType.BuildType)2 ProjectRequestTest (jetbrains.buildServer.server.rest.request.ProjectRequestTest)2 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)2 BuildProblemResponsibilityEntry (jetbrains.buildServer.responsibility.BuildProblemResponsibilityEntry)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