@Test(expected = IllegalArgumentException.class) public void testInvalidCommitMetadataDir() throws JsonSyntaxException, IOException { Metadata.getVulnerabilityMetadata("commitDir2"); }
public static Vulnerability getVulnerabilityMetadata(String rootDir) throws JsonSyntaxException, IOException { String filePath = rootDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { throw new IllegalArgumentException( "The root folder " + rootDir + " or the meta file in root directory is missing " + filePath); } Gson gson = new Gson(); Vulnerability metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Vulnerability.class); if (StringUtils.isBlank(metadata.getVulnId())) { throw new IllegalArgumentException( "The vulnerability_id is missing missing in the " + filePath + " file"); } return metadata; }
Metadata { public static Vulnerability getVulnerabilityMetadata(String rootDir) throws JsonSyntaxException, IOException { String filePath = rootDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { throw new IllegalArgumentException( "The root folder " + rootDir + " or the meta file in root directory is missing " + filePath); } Gson gson = new Gson(); Vulnerability metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Vulnerability.class); if (StringUtils.isBlank(metadata.getVulnId())) { throw new IllegalArgumentException( "The vulnerability_id is missing missing in the " + filePath + " file"); } return metadata; } }
Metadata { public static Vulnerability getVulnerabilityMetadata(String rootDir) throws JsonSyntaxException, IOException { String filePath = rootDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { throw new IllegalArgumentException( "The root folder " + rootDir + " or the meta file in root directory is missing " + filePath); } Gson gson = new Gson(); Vulnerability metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Vulnerability.class); if (StringUtils.isBlank(metadata.getVulnId())) { throw new IllegalArgumentException( "The vulnerability_id is missing missing in the " + filePath + " file"); } return metadata; }  }
Metadata { public static Vulnerability getVulnerabilityMetadata(String rootDir) throws JsonSyntaxException, IOException { String filePath = rootDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { throw new IllegalArgumentException( "The root folder " + rootDir + " or the meta file in root directory is missing " + filePath); } Gson gson = new Gson(); Vulnerability metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Vulnerability.class); if (StringUtils.isBlank(metadata.getVulnId())) { throw new IllegalArgumentException( "The vulnerability_id is missing missing in the " + filePath + " file"); } return metadata; }  static Commit getCommitMetadata(String commitDir); static Vulnerability getVulnerabilityMetadata(String rootDir); }
Metadata { public static Vulnerability getVulnerabilityMetadata(String rootDir) throws JsonSyntaxException, IOException { String filePath = rootDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { throw new IllegalArgumentException( "The root folder " + rootDir + " or the meta file in root directory is missing " + filePath); } Gson gson = new Gson(); Vulnerability metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Vulnerability.class); if (StringUtils.isBlank(metadata.getVulnId())) { throw new IllegalArgumentException( "The vulnerability_id is missing missing in the " + filePath + " file"); } return metadata; }  static Commit getCommitMetadata(String commitDir); static Vulnerability getVulnerabilityMetadata(String rootDir);  }