use of org.jboss.pnc.dto.response.Graph in project pnc by project-ncl.
the class BuildProviderImpl method getBuildGraphForGroupBuild.
@Override
public Graph<Build> getBuildGraphForGroupBuild(String groupBuildId) {
BuildConfigSetRecord buildConfigSetRecord = buildConfigSetRecordRepository.queryById(Integer.valueOf(groupBuildId));
if (buildConfigSetRecord == null) {
throw new EmptyEntityException("Build group " + groupBuildId + " does not exists.");
}
List<String> runningAndStoredIds = getBuildIdsInTheGroup(buildConfigSetRecord);
org.jboss.util.graph.Graph<BuildWithDependencies> buildGraph = new org.jboss.util.graph.Graph<>();
for (String buildId : runningAndStoredIds) {
org.jboss.util.graph.Graph<BuildWithDependencies> dependencyGraph = createBuildDependencyGraph(buildId);
GraphUtils.merge(buildGraph, dependencyGraph);
logger.trace("Merged graph from buildRecordId {} to BuildConfigSetRecordGraph {}; Edges {},", buildId, buildGraph, buildGraph.getEdges());
}
GraphDtoBuilder<BuildWithDependencies, Build> graphBuilder = new GraphDtoBuilder();
Graph<Build> graphDto = graphBuilder.from(buildGraph, Build.class, vertex -> vertex.getData().getBuild());
return graphDto;
}
use of org.jboss.pnc.dto.response.Graph 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);
}
Aggregations