-
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.
Added test for CollectorClassFileVisitor (#74)
Co-authored-by: César Soto Valero <[email protected]>
- Loading branch information
1 parent
30afab9
commit 0c4bcae
Showing
6 changed files
with
37 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
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
32 changes: 32 additions & 0 deletions
32
depclean-core/src/test/java/se/kth/depclean/core/analysis/CollectorClassFileVisitorTest.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,32 @@ | ||
package se.kth.depclean.core.analysis; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@Slf4j | ||
class CollectorClassFileVisitorTest { | ||
|
||
private static final File classFile = new File("src/test/resources/ClassFileVisitorResources/test.class"); | ||
private static final String className = "test"; | ||
private static final CollectorClassFileVisitor collector = new CollectorClassFileVisitor(); | ||
|
||
@Test | ||
@DisplayName("Test that the class is visited and added to the set of visited classes") | ||
void whenClassIsVisited_thenItIsAddedToTheSetOfVisitedClasses() throws FileNotFoundException { | ||
FileInputStream fileInputStream = new FileInputStream(classFile); | ||
try { | ||
collector.visitClass(className, fileInputStream); | ||
} catch (IllegalArgumentException e) { | ||
log.error("Failed to visit the class at: " + classFile.getAbsolutePath()); | ||
} | ||
Set<String> visitedClasses = new HashSet<>(collector.getClasses()); | ||
Assertions.assertFalse(visitedClasses.isEmpty()); | ||
} | ||
} |
Binary file added
BIN
+393 Bytes
depclean-core/src/test/resources/ClassFileVisitorResources/test.class
Binary file not shown.