@Test public void testGetCommitMetadata() throws JsonSyntaxException, IOException { ClassLoader classLoader = getClass().getClassLoader(); String path = classLoader.getResource("commitDir1").getPath(); Commit commit = Metadata.getCommitMetadata(path); assertEquals("master", commit.getBranch()); assertEquals("b2b8f4adc557e4ef1ee2fe5e0ab46866c06ec55b", commit.getCommitId()); assertEquals("1447974481000", commit.getTimestamp()); assertEquals("https: assertEquals(path, commit.getDirectory()); }
public static Commit getCommitMetadata(String commitDir) throws JsonSyntaxException, IOException { String filePath = commitDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { log.error( "The commit folder {} or the meta file is missing {} in commit folder", commitDir, filePath); return null; } Gson gson = new Gson(); Commit metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Commit.class); metadata.setDirectory(commitDir); return metadata; }
Metadata { public static Commit getCommitMetadata(String commitDir) throws JsonSyntaxException, IOException { String filePath = commitDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { log.error( "The commit folder {} or the meta file is missing {} in commit folder", commitDir, filePath); return null; } Gson gson = new Gson(); Commit metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Commit.class); metadata.setDirectory(commitDir); return metadata; } }
Metadata { public static Commit getCommitMetadata(String commitDir) throws JsonSyntaxException, IOException { String filePath = commitDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { log.error( "The commit folder {} or the meta file is missing {} in commit folder", commitDir, filePath); return null; } Gson gson = new Gson(); Commit metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Commit.class); metadata.setDirectory(commitDir); return metadata; }  }
Metadata { public static Commit getCommitMetadata(String commitDir) throws JsonSyntaxException, IOException { String filePath = commitDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { log.error( "The commit folder {} or the meta file is missing {} in commit folder", commitDir, filePath); return null; } Gson gson = new Gson(); Commit metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Commit.class); metadata.setDirectory(commitDir); return metadata; }  static Commit getCommitMetadata(String commitDir); static Vulnerability getVulnerabilityMetadata(String rootDir); }
Metadata { public static Commit getCommitMetadata(String commitDir) throws JsonSyntaxException, IOException { String filePath = commitDir + File.separator + META_PROPERTIES_FILE; if (!FileUtil.isAccessibleFile(filePath)) { log.error( "The commit folder {} or the meta file is missing {} in commit folder", commitDir, filePath); return null; } Gson gson = new Gson(); Commit metadata = null; metadata = gson.fromJson(FileUtil.readFile(filePath), Commit.class); metadata.setDirectory(commitDir); return metadata; }  static Commit getCommitMetadata(String commitDir); static Vulnerability getVulnerabilityMetadata(String rootDir);  }