use of ru.fix.completable.reactor.api.ReactorGraphModel.Transition in project completable-reactor by ru-fix.
the class ProcessorsHaveIncomingFlowsValidator method validateGraph.
@Override
public void validateGraph(ReactorGraphModel graph) throws ValidationException {
val processorsWithIncomingTransitions = graph.getMergePoints().stream().flatMap(mergePoint -> mergePoint.getTransitions().stream()).map(Transition::getHandleByProcessingItem).filter(Objects::nonNull).collect(Collectors.toSet());
processorsWithIncomingTransitions.addAll(graph.getStartPoint().getProcessingItems());
graph.getMergePoints().stream().flatMap(mergePoint -> mergePoint.getTransitions().stream()).map(Transition::getHandleByProcessingItem).filter(Objects::nonNull).forEach(processorsWithIncomingTransitions::add);
val processorWithoutIncomingTransitions = Stream.concat(graph.getProcessors().stream().map(Processor::getIdentity), graph.getSubgraphs().stream().map(Subgraph::getIdentity)).filter(processor -> !processorsWithIncomingTransitions.contains(processor)).findAny();
if (processorWithoutIncomingTransitions.isPresent()) {
throw new ValidationException(String.format("ProcessingItem %s does not have incoming transitions.", processorWithoutIncomingTransitions.get()));
}
}
Aggregations