forked from FrontEndART/AIFix4SecCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create integration test for: extracting column info FrontEndART#6
- Loading branch information
1 parent
09d75fe
commit f9672a8
Showing
7 changed files
with
9,688 additions
and
1 deletion.
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
71 changes: 71 additions & 0 deletions
71
src/test/java/eu/assuremoss/utils/ColumnInfoParserTest.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,71 @@ | ||
package eu.assuremoss.utils; | ||
|
||
import eu.assuremoss.framework.api.VulnerabilityDetector; | ||
import eu.assuremoss.framework.model.CodeModel; | ||
import eu.assuremoss.framework.model.VulnerabilityEntry; | ||
import eu.assuremoss.utils.factories.ToolFactory; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.ObjectInputStream; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
class ColumnInfoParserTest { | ||
private static VulnerabilityDetector vulnDetector; | ||
private static final String mockedResultsPath = String.valueOf(Paths.get("src","test", "resources", "mocked-results")); | ||
|
||
@BeforeAll | ||
static void beforeAll() throws IOException { | ||
Configuration config = new Configuration("config.properties"); | ||
vulnDetector = ToolFactory.createOsa(config.properties); | ||
} | ||
|
||
private static List<CodeModel> mockedCodeModels() { | ||
List<CodeModel> resList = new ArrayList<>(); | ||
|
||
String asg = String.valueOf(Paths.get(mockedResultsPath, "asg.jfif")); | ||
String graphXML = String.valueOf(Paths.get(mockedResultsPath, "graph.xml")); | ||
String findBugsXML = String.valueOf(Paths.get(mockedResultsPath, "FindBugs.xml")); | ||
|
||
resList.add(new CodeModel(CodeModel.MODEL_TYPES.ASG, new File(asg))); | ||
resList.add(new CodeModel(CodeModel.MODEL_TYPES.OSA_GRAPH_XML, new File(graphXML))); | ||
resList.add(new CodeModel(CodeModel.MODEL_TYPES.FINDBUGS_XML, new File(findBugsXML))); | ||
|
||
return resList; | ||
} | ||
|
||
@Test | ||
void Should_Attach_Column_Info_For_Vulnerability_Entries() { | ||
var expectedEntries = getExpectedEntries(); | ||
var result = vulnDetector.getVulnerabilityLocations(new File(""), mockedCodeModels()); | ||
|
||
Assertions.assertEquals(expectedEntries, result); | ||
} | ||
|
||
private List<VulnerabilityEntry> getExpectedEntries() { | ||
var result = new ArrayList<VulnerabilityEntry>(); | ||
|
||
String vulnEntriesPath = String.valueOf(Paths.get(mockedResultsPath, "vulnEntries.ser").toAbsolutePath()); | ||
|
||
try { | ||
FileInputStream fileIn = new FileInputStream(vulnEntriesPath); | ||
ObjectInputStream in = new ObjectInputStream(fileIn); | ||
result = (ArrayList<VulnerabilityEntry>) in.readObject(); | ||
in.close(); | ||
fileIn.close(); | ||
} catch (IOException i) { | ||
i.printStackTrace(); | ||
} catch (ClassNotFoundException c) { | ||
System.out.println("VulnerabilityEntry class not found"); | ||
c.printStackTrace(); | ||
} | ||
|
||
return result; | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.