Search in sources :

Example 16 with BeanContext

use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.

the class TestOccurrenceRequestTest method testWontFetchItemsWhenNotNeededWithDefaultFieldsValue.

@Test
public void testWontFetchItemsWhenNotNeededWithDefaultFieldsValue() {
    BeanContext ctx = BaseFinderTest.getBeanContext(myFixture);
    myRequest.initForTests(ctx.getServiceLocator(), new TestOccurrenceFinderDenyingItemsFetch(), ctx.getApiUrlBuilder(), ctx);
    final SFinishedBuild build = build().in(myBuildType).withTest(BuildBuilder.TestData.test("aaa").duration(76)).finish();
    FakeHttpServletRequest mockRequest = new FakeHttpServletRequest();
    mockRequest.setRequestURL("http://test/httpAuth/app/rest/testOccurrences?locator=build:" + build.getBuildId());
    TestOccurrences testOccurrences = myRequest.getTestOccurrences("build:" + build.getBuildId(), "", null, mockRequest);
    assertEquals(new Integer(1), testOccurrences.getCount());
}
Also used : BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) FakeHttpServletRequest(jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) Test(org.testng.annotations.Test)

Example 17 with BeanContext

use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.

the class ServerRequestTest method setUp.

@Override
@BeforeMethod
public void setUp() throws Exception {
    super.setUp();
    BeanContext ctx = BaseFinderTest.getBeanContext(myFixture);
    PermissionChecker checker = new PermissionChecker(myServer.getSecurityContext(), myProjectManager);
    myFixture.addService(checker);
    myRequest = new ServerRequest();
    myRequest.initForTests(ctx.getServiceLocator(), ctx.getApiUrlBuilder(), new BeanFactory(null), ctx, checker);
}
Also used : BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) PermissionChecker(jetbrains.buildServer.server.rest.data.PermissionChecker) BeanFactory(jetbrains.buildServer.server.rest.util.BeanFactory) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 18 with BeanContext

use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.

the class BuildTypeRequest method replaceArtifactDeps.

/**
 * Replaces the dependencies to those sent in the request.
 */
@PUT
@Path("/{btLocator}/artifact-dependencies")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update all artifact dependencies of the matching build configuration.", nickname = "replaceAllArtifactDependencies")
public PropEntitiesArtifactDep replaceArtifactDeps(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @QueryParam("fields") String fields, PropEntitiesArtifactDep deps) {
    final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
    deps.setToBuildType(buildType.getSettingsEx(), myServiceLocator);
    buildType.persist("Artifact dependencies replaced");
    return new PropEntitiesArtifactDep(buildType.getSettingsEx(), new Fields(fields), new BeanContext(myFactory, myServiceLocator, myApiUrlBuilder));
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) ApiOperation(io.swagger.annotations.ApiOperation)

Example 19 with BeanContext

use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.

the class BuildTypeRequest method getSnapshotDep.

@GET
@Path("/{btLocator}/snapshot-dependencies/{snapshotDepLocator}")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get a snapshot dependency of the matching build configuration.", nickname = "getSnapshotDependency")
public PropEntitySnapshotDep getSnapshotDep(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @PathParam("snapshotDepLocator") String snapshotDepLocator, @QueryParam("fields") String fields) {
    final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
    final Dependency dependency = PropEntitySnapshotDep.getSnapshotDep(buildType.get(), snapshotDepLocator, myBuildTypeFinder);
    return new PropEntitySnapshotDep(dependency, buildType.getSettingsEx(), new Fields(fields), new BeanContext(myFactory, myServiceLocator, myApiUrlBuilder));
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) Dependency(jetbrains.buildServer.serverSide.dependency.Dependency) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ApiOperation(io.swagger.annotations.ApiOperation)

Example 20 with BeanContext

use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.

the class BuildTypeRequest method getArtifactDep.

@GET
@Path("/{btLocator}/artifact-dependencies/{artifactDepLocator}")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get an artifact dependency of the matching build configuration.", nickname = "getArtifactDependency")
public PropEntityArtifactDep getArtifactDep(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @PathParam("artifactDepLocator") String artifactDepLocator, @QueryParam("fields") String fields) {
    final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
    final SArtifactDependency artifactDependency = getArtifactDependency(buildType, artifactDepLocator);
    return new PropEntityArtifactDep(artifactDependency, buildType.getSettingsEx(), new Fields(fields), new BeanContext(myFactory, myServiceLocator, myApiUrlBuilder));
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

BeanContext (jetbrains.buildServer.server.rest.util.BeanContext)21 ApiOperation (io.swagger.annotations.ApiOperation)12 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)10 SArtifactDependency (jetbrains.buildServer.serverSide.artifacts.SArtifactDependency)6 BeanFactory (jetbrains.buildServer.server.rest.util.BeanFactory)5 ApiUrlBuilder (jetbrains.buildServer.server.rest.ApiUrlBuilder)4 Test (org.testng.annotations.Test)4 PathTransformer (jetbrains.buildServer.server.rest.PathTransformer)3 Dependency (jetbrains.buildServer.serverSide.dependency.Dependency)3 File (java.io.File)2 FakeHttpServletRequest (jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest)2 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)2 Build (jetbrains.buildServer.server.rest.model.build.Build)2 TestOccurrences (jetbrains.buildServer.server.rest.model.problem.TestOccurrences)2 TestFor (jetbrains.buildServer.util.TestFor)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Logger (com.intellij.openapi.diagnostic.Logger)1 ApiModelProperty (io.swagger.annotations.ApiModelProperty)1 Collections (java.util.Collections)1 List (java.util.List)1