public final void topoSort(final CaseInsensitiveString root, final PipelineDependencyState pipelineDependencyState) throws Exception {
        Hashtable<CaseInsensitiveString, CycleState> state = new Hashtable<>();
        Stack<CaseInsensitiveString> visiting = new Stack<>();

        if (!state.containsKey(root)) {
            tsort(root, pipelineDependencyState, state, visiting);
        } else if (state.get(root) == CycleState.VISITING) {
            throw ExceptionUtils.bomb("Unexpected node in visiting state: " + root);
        }
        assertHasVisitedAllNodesInTree(state);
    }
@Test
    public void shouldNotThrowExceptionWhenCycleDependencyNotFound() throws Exception {
        when(state.getDependencyMaterials(new CaseInsensitiveString("a"))).thenReturn(new Node(new Node.DependencyNode(new CaseInsensitiveString("b"), new CaseInsensitiveString("stage"))));
        when(state.getDependencyMaterials(new CaseInsensitiveString("b"))).thenReturn(new Node(new Node.DependencyNode(new CaseInsensitiveString("c"), new CaseInsensitiveString("stage"))));
        when(state.getDependencyMaterials(new CaseInsensitiveString("c"))).thenReturn(new Node(new ArrayList<>()));

        when(state.hasPipeline(new CaseInsensitiveString("a"))).thenReturn(true);
        when(state.hasPipeline(new CaseInsensitiveString("b"))).thenReturn(true);
        when(state.hasPipeline(new CaseInsensitiveString("c"))).thenReturn(true);
        project.topoSort(new CaseInsensitiveString("a"), state);
    }