@Test public void getNPMAuthorTest() throws Exception { File packageFile = getFileFromClasspath("package.json"); Author actual = JsonUtil.getNPMAuthor(packageFile); Assert.assertEquals("Name", actual.getName()); Assert.assertEquals("test@test.com", actual.getEmail()); }
public static Author getNPMAuthor(final File file) throws IOException { final JSONObject obj = readJsconFile(file); final JSONObject authorObject = obj.optJSONObject("author"); if (authorObject != null) { String name = authorObject.optString("name"); String email = authorObject.optString("email"); return new Author(name, email); } return null; }
JsonUtil { public static Author getNPMAuthor(final File file) throws IOException { final JSONObject obj = readJsconFile(file); final JSONObject authorObject = obj.optJSONObject("author"); if (authorObject != null) { String name = authorObject.optString("name"); String email = authorObject.optString("email"); return new Author(name, email); } return null; } }
JsonUtil { public static Author getNPMAuthor(final File file) throws IOException { final JSONObject obj = readJsconFile(file); final JSONObject authorObject = obj.optJSONObject("author"); if (authorObject != null) { String name = authorObject.optString("name"); String email = authorObject.optString("email"); return new Author(name, email); } return null; } private  JsonUtil(); }
JsonUtil { public static Author getNPMAuthor(final File file) throws IOException { final JSONObject obj = readJsconFile(file); final JSONObject authorObject = obj.optJSONObject("author"); if (authorObject != null) { String name = authorObject.optString("name"); String email = authorObject.optString("email"); return new Author(name, email); } return null; } private  JsonUtil(); static ArchiveIdentifierVersion getNPMArchiveDescription(final File file); static String getNPMArchiveLicenseName(final File file); static String getNPMArchiveVendorName(final File file); static Author getNPMAuthor(final File file); }
JsonUtil { public static Author getNPMAuthor(final File file) throws IOException { final JSONObject obj = readJsconFile(file); final JSONObject authorObject = obj.optJSONObject("author"); if (authorObject != null) { String name = authorObject.optString("name"); String email = authorObject.optString("email"); return new Author(name, email); } return null; } private  JsonUtil(); static ArchiveIdentifierVersion getNPMArchiveDescription(final File file); static String getNPMArchiveLicenseName(final File file); static String getNPMArchiveVendorName(final File file); static Author getNPMAuthor(final File file);  }