Search in sources :

Example 16 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildProviderImplTest method testFilterRunningBuildsByBuildConfigName.

@Test
public void testFilterRunningBuildsByBuildConfigName() {
    // Given
    mockBuildRecord();
    mockBuildTask();
    String givenBcName = "bcName";
    BuildTask givenBT = mockBuildTask(givenBcName);
    // When
    BuildPageInfo pageInfo = new BuildPageInfo(0, 2, "", "", false, true, givenBcName);
    Page<Build> builds = provider.getBuilds(pageInfo);
    // Then
    assertEquals(1, builds.getTotalHits());
    Iterator<Build> it = builds.getContent().iterator();
    assertEquals(givenBT.getId(), it.next().getId());
}
Also used : BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) Build(org.jboss.pnc.dto.Build) BuildPageInfo(org.jboss.pnc.facade.providers.api.BuildPageInfo) Test(org.junit.Test)

Example 17 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildProviderImplTest method testFilterFinishedBuildsByBuildConfigName.

@Test
public void testFilterFinishedBuildsByBuildConfigName() {
    // Given
    Base32LongID givenIdAndBcName = new Base32LongID(85792L);
    mockBuildTask();
    mockBuildTask();
    BuildRecord givenBuild = mockBuildRecord(givenIdAndBcName, new Long[0], new Long[0]);
    when(buildConfigurationAuditedRepository.searchIdRevForBuildConfigurationName(givenIdAndBcName.toString())).thenReturn(Stream.of(givenBuild.getBuildConfigurationAuditedIdRev()).collect(Collectors.toList()));
    // When
    BuildPageInfo pageInfo = new BuildPageInfo(0, 10, "", "", false, false, givenIdAndBcName.toString());
    Page<Build> builds = provider.getBuilds(pageInfo);
    // Then
    assertEquals(1, builds.getTotalHits());
    Iterator<Build> it = builds.getContent().iterator();
    assertEquals(BuildMapper.idMapper.toDto(givenBuild.getId()), it.next().getId());
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID) Build(org.jboss.pnc.dto.Build) BuildPageInfo(org.jboss.pnc.facade.providers.api.BuildPageInfo) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 18 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildProviderImplTest method testGetRunningBuilds.

@Test
public void testGetRunningBuilds() {
    // Prepare
    mockBuildRecord();
    // hit
    mockBuildTask();
    mockBuildRecord();
    // hit
    mockBuildTask();
    mockBuildRecord();
    // hit
    BuildTask build2 = mockBuildTask();
    mockBuildRecord();
    // hit
    BuildTask build1 = mockBuildTask();
    // When
    BuildPageInfo pageInfo = new BuildPageInfo(0, 2, "", "", false, true, "");
    Page<Build> builds = provider.getBuilds(pageInfo);
    // Verify
    assertEquals(4, builds.getTotalHits());
    assertEquals(2, builds.getContent().size());
    Iterator<Build> it = builds.getContent().iterator();
    assertEquals(build1.getId(), it.next().getId());
    assertEquals(build2.getId(), it.next().getId());
}
Also used : BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) Build(org.jboss.pnc.dto.Build) BuildPageInfo(org.jboss.pnc.facade.providers.api.BuildPageInfo) Test(org.junit.Test)

Example 19 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildProviderImplTest method testGetSpecificRunning.

@Test
public void testGetSpecificRunning() {
    BuildTask task = mockBuildTask();
    Build specific = provider.getSpecific(task.getId());
    assertThat(specific.getId()).isEqualTo(task.getId());
    assertThat(specific.getSubmitTime()).isEqualTo(task.getSubmitTime().toInstant());
}
Also used : BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) Build(org.jboss.pnc.dto.Build) Test(org.junit.Test)

Example 20 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildProviderImplTest method testFilterLikeRunningBuildsByBuildConfigName.

@Test
public void testFilterLikeRunningBuildsByBuildConfigName() {
    // Given
    mockBuildRecord();
    mockBuildTask();
    String givenBcName = "VeryLongAndComplicatedBcName";
    String givenBcNamePattern = "*LongAndComplicated*";
    BuildTask givenBT = mockBuildTask(givenBcName);
    // When
    BuildPageInfo pageInfo = new BuildPageInfo(0, 2, "", "", false, true, givenBcNamePattern);
    Page<Build> builds = provider.getBuilds(pageInfo);
    // Then
    assertEquals(1, builds.getTotalHits());
    Iterator<Build> it = builds.getContent().iterator();
    assertEquals(givenBT.getId(), it.next().getId());
}
Also used : BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) Build(org.jboss.pnc.dto.Build) BuildPageInfo(org.jboss.pnc.facade.providers.api.BuildPageInfo) Test(org.junit.Test)

Aggregations

Build (org.jboss.pnc.dto.Build)71 Test (org.junit.Test)52 ContainerTest (org.jboss.pnc.test.category.ContainerTest)35 BuildClient (org.jboss.pnc.client.BuildClient)20 BuildRecord (org.jboss.pnc.model.BuildRecord)18 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)16 BuildStatus (org.jboss.pnc.enums.BuildStatus)15 GroupBuild (org.jboss.pnc.dto.GroupBuild)14 BuildPageInfo (org.jboss.pnc.facade.providers.api.BuildPageInfo)14 ArrayList (java.util.ArrayList)12 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)11 HashSet (java.util.HashSet)10 List (java.util.List)10 Set (java.util.Set)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 Date (java.util.Date)9 Page (org.jboss.pnc.dto.response.Page)9 BuildMapper (org.jboss.pnc.mapper.api.BuildMapper)9 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)9