2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.util;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertThrows;
13 import java.util.HashSet;
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.util.TopologicalSort.Node;
16 import org.opendaylight.yangtools.util.TopologicalSort.NodeImpl;
18 class TopologicalSortTest {
21 final var nodes = new HashSet<Node>();
23 final var node1 = new NodeImpl();
25 final var node2 = new NodeImpl();
27 final var node3 = new NodeImpl();
34 assertThrows(IllegalStateException.class, () -> TopologicalSort.sort(nodes));
38 void testValidSimple() {
39 final var nodes = new HashSet<Node>();
41 final var node1 = new NodeImpl();
43 final var node2 = new NodeImpl();
45 final var node3 = new NodeImpl();
47 final var node4 = new NodeImpl();
55 final var sorted = TopologicalSort.sort(nodes);
57 assertEquals(node4, sorted.get(0));
58 assertEquals(node2, sorted.get(1));
59 assertEquals(node3, sorted.get(2));
60 assertEquals(node1, sorted.get(3));