-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38d59a6
commit 139c48a
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
depclean-core/src/test/java/se/kth/depclean/core/analysis/graph/DefaultCallGraphTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package se.kth.depclean.core.analysis.graph; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class DefaultCallGraphTest { | ||
|
||
@BeforeEach | ||
void setUp() { | ||
DefaultCallGraph.addEdge("A", new HashSet<>(Arrays.asList("B", "C", "D"))); | ||
DefaultCallGraph.addEdge("D", new HashSet<>(Arrays.asList("E", "F"))); | ||
DefaultCallGraph.addEdge("F", new HashSet<>(Arrays.asList("G", "H"))); | ||
DefaultCallGraph.addEdge("I", new HashSet<>(Arrays.asList("J"))); | ||
} | ||
|
||
@Test | ||
void referencedClassMembers() { | ||
HashSet<String> projectClasses = new HashSet<>(Arrays.asList("A")); | ||
Set<String> referenced = DefaultCallGraph.referencedClassMembers(projectClasses); | ||
// note that there is no path from A to J | ||
Assertions.assertEquals(new HashSet<>(Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H")), referenced); | ||
} | ||
|
||
@Test | ||
void getProjectVertices() { | ||
Set<String> projectVertices = DefaultCallGraph.getProjectVertices(); | ||
Assertions.assertEquals(new HashSet<>(Arrays.asList("A", "D", "F", "I")), projectVertices); | ||
} | ||
|
||
@Test | ||
void getUsagesPerClass() { | ||
Map<String, Set<String>> usagesPerClass = DefaultCallGraph.getUsagesPerClass(); | ||
Map<String, Set<String>> usagesExpected = new HashMap<>(); | ||
usagesExpected.put("A", new HashSet<>(Arrays.asList("B", "C", "D"))); | ||
usagesExpected.put("D", new HashSet<>(Arrays.asList("E", "F"))); | ||
usagesExpected.put("F", new HashSet<>(Arrays.asList("G", "H"))); | ||
usagesExpected.put("I", new HashSet<>(Arrays.asList("J"))); | ||
Assertions.assertEquals(usagesExpected, usagesPerClass); | ||
} | ||
} |