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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations