Files
openide/java/java-tests/testSrc/com/intellij/roots/ModuleGraphTest.java
Vladimir Krivosheev e0943106e4 cleanup
GitOrigin-RevId: 7908df7629cfe67403f0e7551e6dd199c0633007
2020-06-18 10:35:58 +03:00

39 lines
1.3 KiB
Java

// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.roots;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.roots.DependencyScope;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.graph.Graph;
import com.intellij.util.graph.GraphAlgorithms;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author Dmitry Avdeev
*/
public class ModuleGraphTest extends ModuleRootManagerTestCase {
public void testOuts() {
Module a = createModule("a");
Module b = createModule("b");
addDependency(myModule, a);
addDependency(a, b);
Graph<Module> graph = ModuleManager.getInstance(getProject()).moduleGraph();
List<Module> outs = ContainerUtil.collect(graph.getOut(a));
assertEquals(1, outs.size());
Set<Module> set = new HashSet<>();
GraphAlgorithms.getInstance().collectOutsRecursively(graph, b, set);
assertEquals(3, set.size());
}
protected void addDependency(Module module, Module a) {
ModuleRootModificationUtil.addDependency(module, a, DependencyScope.COMPILE, true);
}
}