### Question:
WikidataInterface { public static List<String> getAliases(String qid) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException, TransformerException, URISyntaxException { final ArrayList<String> strings = new ArrayList<>(); String json = getAlias(qid, "en"); try { JSONObject Ojson = (JSONObject) JSONSerializer.toJSON(json); if (Ojson.getInt("success") < 1) { return Arrays.asList(new String[] {"fail!"}); } try { JSONArray results = ((JSONObject) ((JSONObject) ((JSONObject) Ojson.get("entities")).get(qid)).get("aliases")).getJSONArray("en"); for (Object result : results) { final JSONObject sres = (JSONObject) result; strings.add((String) sres.get("value")); } } catch (JSONException e) { Logger.error(((JSONObject) ((JSONObject) Ojson.get("entities")).get(qid)).get("aliases"),e.getMessage()); } } catch (Exception e) { e.printStackTrace(); } return strings; }  static List<String> getEntities(String text); static List<String> getAliases(String qid);  }### Answer:
@Test public void testGetAliases() throws Exception { for (String qid : qIds) { Path file = Paths.get(File.createTempFile("temp", Long.toString(System.nanoTime())).getPath()); List<String> aliases = WikidataInterface.getAliases(qid); aliases = aliases.stream().map(a -> "\"" + a + "\"").collect(Collectors.toList()); Files.write(file, aliases, Charset.forName("UTF-8")); } }