Search in sources :

Example 1 with BuildPageInfo

use of org.jboss.pnc.facade.providers.api.BuildPageInfo 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 2 with BuildPageInfo

use of org.jboss.pnc.facade.providers.api.BuildPageInfo 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 3 with BuildPageInfo

use of org.jboss.pnc.facade.providers.api.BuildPageInfo 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 4 with BuildPageInfo

use of org.jboss.pnc.facade.providers.api.BuildPageInfo 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)

Example 5 with BuildPageInfo

use of org.jboss.pnc.facade.providers.api.BuildPageInfo in project pnc by project-ncl.

the class BuildProviderImplTest method testGetBuilds.

@Test
public void testGetBuilds() {
    // Prepare
    // hit
    mockBuildRecord();
    // hit
    mockBuildTask();
    // hit
    mockBuildRecord();
    // hit
    mockBuildTask();
    // hit
    mockBuildRecord();
    // hit
    mockBuildTask();
    // hit
    BuildRecord build2 = mockBuildRecord();
    // hit
    BuildTask build1 = mockBuildTask();
    // When
    BuildPageInfo pageInfo = new BuildPageInfo(0, 2, "", "", false, false, "");
    Page<Build> builds = provider.getBuilds(pageInfo);
    // Verify
    assertEquals(8, builds.getTotalHits());
    assertEquals(2, builds.getContent().size());
    Iterator<Build> it = builds.getContent().iterator();
    assertEquals(build1.getId(), it.next().getId());
    assertEquals(BuildMapper.idMapper.toDto(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) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Aggregations

BuildPageInfo (org.jboss.pnc.facade.providers.api.BuildPageInfo)10 Build (org.jboss.pnc.dto.Build)9 Test (org.junit.Test)8 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)6 BuildRecord (org.jboss.pnc.model.BuildRecord)4 Base32LongID (org.jboss.pnc.model.Base32LongID)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Page (org.jboss.pnc.dto.response.Page)1 BuildRecordRepository (org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository)1 PageInfo (org.jboss.pnc.spi.datastore.repositories.api.PageInfo)1 Predicate (org.jboss.pnc.spi.datastore.repositories.api.Predicate)1 SortInfo (org.jboss.pnc.spi.datastore.repositories.api.SortInfo)1 DefaultPageInfo (org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo)1