use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildProviderImplTest method testFailFilterLikeRunningBuildsByBuildConfigName.
@Test
public void testFailFilterLikeRunningBuildsByBuildConfigName() {
// 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(0, builds.getTotalHits());
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildProviderImplTest method testGetSpecificFinished.
@Test
public void testGetSpecificFinished() {
BuildRecord record = mockBuildRecord();
Build specific = provider.getSpecific(BuildMapper.idMapper.toDto(record.getId()));
assertThat(specific.getId()).isEqualTo(BuildMapper.idMapper.toDto(record.getId()));
assertThat(specific.getSubmitTime()).isEqualTo(record.getSubmitTime().toInstant());
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildProviderImplTest method shouldGetGraphWithDependencies.
@Test
public void shouldGetGraphWithDependencies() {
// With
Integer buildSetTaskId = 1;
BuildSetTask buildSetTask = mock(BuildSetTask.class);
when(buildSetTask.getId()).thenReturn(buildSetTaskId);
BuildTask task = mockBuildTaskWithSet(buildSetTask);
BuildTask taskDep = mockBuildTaskWithSet(buildSetTask);
BuildTask taskDepDep = mockBuildTaskWithSet(buildSetTask);
when(task.getDependencies()).thenReturn(asSet(taskDep));
when(taskDep.getDependencies()).thenReturn(asSet(taskDepDep));
// When
Graph<Build> graph = provider.getBuildGraphForGroupBuild(Integer.toString(buildSetTaskId));
// Then
assertThat(graph.getVertices()).hasSize(3);
List<String> buildTaskIDsOrderedByBCName = Stream.of(task, taskDep, taskDepDep).sorted(Comparator.comparing(t -> t.getBuildConfigurationAudited().getName())).map(t -> t.getId()).collect(Collectors.toList());
assertThat(graph.getVertices().values().stream().map(Vertex::getName)).containsExactlyElementsOf(buildTaskIDsOrderedByBCName);
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildProviderImplTest method shouldThrowCorruptedDataExceptionTest.
@Test(expected = CorruptedDataException.class)
public void shouldThrowCorruptedDataExceptionTest() {
// given
mockBuildRecord(new Base32LongID(200000L), new Long[] {}, new Long[] {});
BuildRecord buildRecord = mockBuildRecord(new Base32LongID(200001L), new Long[] { 200000L, 220000L }, new Long[] {});
// when
Graph<Build> dependencyGraph = provider.getDependencyGraph(BuildMapper.idMapper.toDto(buildRecord.getId()));
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildProviderImplTest method testGetAll.
@Test
public void testGetAll() throws InterruptedException {
BuildRecord buildRecord1 = mockBuildRecord();
// make sure new start time is in the next millisecond
Thread.sleep(1L);
BuildRecord buildRecord2 = mockBuildRecord();
// make sure new start time is in the next millisecond
Thread.sleep(1L);
BuildRecord buildRecord3 = mockBuildRecord();
Page<Build> all = provider.getAll(0, 10, null, null);
assertThat(all.getContent()).hasSize(3).haveExactly(1, new Condition<>(b -> buildRecord1.getSubmitTime().toInstant().equals(b.getSubmitTime()), "Build present")).haveExactly(1, new Condition<>(b -> buildRecord2.getSubmitTime().toInstant().equals(b.getSubmitTime()), "Build present")).haveExactly(1, new Condition<>(b -> buildRecord3.getSubmitTime().toInstant().equals(b.getSubmitTime()), "Build present"));
}
Aggregations