+ Set<ModelledSTSTest> testsWithDeps = new HashSet<>();
+ // This TreeMap sorts the tests with the comparator
+ TreeMap<ModelledSTSTest, String> sortedTests = new TreeMap<>(comparator);
+ for (ModelledSTSTest test : getChildren()) {
+ Set<String> testDependencies = test.getDependencies();
+ if (testDependencies.isEmpty()) {
+ // First tests that have no dependencies
+ sortedTests.put(test, test.getName());
+ } else {
+ // These are resolved later
+ testsWithDeps.add(test);
+ }
+ }
+
+ // Construct a LinkedList that is returned as a result
+ LinkedList<ModelledSTSTest> results = new LinkedList<>(sortedTests.keySet());
+
+// Set<ModelledSTSTest> temp = new HashSet<>(testsWithDeps);
+ // Now resolve tests with dependencies
+ for (ModelledSTSTest testWithDep : testsWithDeps) {
+ boolean satisfied = true;
+ for (String dep : testWithDep.getDependencies()) {
+ if (!sortedTests.containsValue(dep)) {
+ satisfied = false;
+ } else {
+ testWithDep.resolveDependency(dep);
+ }
+ }
+ if (satisfied) {
+ results.addLast(testWithDep);
+ sortedTests.put(testWithDep, testWithDep.getName());
+ } else {
+ // Not satisfied
+ System.out.println(testWithDep.getName() + " not satisfied");
+ }
+ }
+ return results;