Search in sources :

Example 1 with BuildArtifactsDownloadInfo

use of jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.BuildArtifactsDownloadInfo in project teamcity-rest by JetBrains.

the class BuildTest method testDownloadedArtifacts.

@Test
@TestFor(issues = "TW-21036")
public void testDownloadedArtifacts() {
    DownloadedArtifactsLoggerImpl artifactsLogger = myFixture.getSingletonService(DownloadedArtifactsLoggerImpl.class);
    SBuildType bt1 = registerBuildType("bt1", "project1", "Ant");
    SBuild build1 = createBuild(bt1, Status.NORMAL);
    SBuildType bt2 = registerBuildType("bt2", "project2", "Ant");
    SBuild build2 = createBuild(bt2, Status.NORMAL);
    artifactsLogger.logArtifactDownload(build2.getBuildId(), build1.getBuildId(), "path1");
    artifactsLogger.waitForQueuePersisting();
    Build build2model = new Build(build2, Fields.ALL_NESTED, getBeanContext(myFixture));
    jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.DownloadedArtifacts build2Artifacts = build2model.getDownloadedArtifacts();
    assertEquals("There is 1 build as a source of artifacts", 1, (int) build2Artifacts.getUnfilteredCount());
    assertEquals("There is 1 build as a source of artifacts", 1, (int) build2Artifacts.getCount());
    assertEquals("There is 1 build as a source of artifacts", 1, build2Artifacts.getDownloadInfo().size());
    BuildArtifactsDownloadInfo build2downloadInfo = build2Artifacts.getDownloadInfo().get(0);
    assertEquals("There is 1 downloaded artifact", 1, (int) build2downloadInfo.getCount());
    assertEquals("Build(" + build2.getBuildId() + ") downloaded artifact from build(" + build1.getBuildId() + ")", build1.getBuildId(), (long) build2downloadInfo.getBuild().getId());
    DownloadedArtifacts realDownloaded = build2.getDownloadedArtifacts();
    ArtifactDownloadInfo artifactInfo = build2downloadInfo.getArtifactInfo().get(0);
    assertEquals("path1", artifactInfo.getArtifactPath());
    assertEquals(Util.formatTime(realDownloaded.getArtifacts().get(build1).get(0).getDownloadTimestamp()), artifactInfo.getDownloadTimestamp());
}
Also used : Build(jetbrains.buildServer.server.rest.model.build.Build) BuildArtifactsDownloadInfo(jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.BuildArtifactsDownloadInfo) ArtifactDownloadInfo(jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.ArtifactDownloadInfo) Test(org.testng.annotations.Test) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)1 Build (jetbrains.buildServer.server.rest.model.build.Build)1 ArtifactDownloadInfo (jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.ArtifactDownloadInfo)1 BuildArtifactsDownloadInfo (jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.BuildArtifactsDownloadInfo)1 TestFor (jetbrains.buildServer.util.TestFor)1 Test (org.testng.annotations.Test)1