LemonGraph { public static String createGraph(JSONObject meta) throws Exception { return createGraph(null, meta); } LemonGraph(); static void openConnection(); static boolean isConnected(); static void close(); static boolean isApiUp(); static JSONObject queryBasedOnPatterns(String jobId, HashMap<String, String> adapterPatterns, int startId); static JSONObject queryBasedOnPatterns(String jobId, HashMap<String, String> adapterPatterns, int startId, int stopId); static JSONObject queryBasedOnPatterns(String jobId, HashMap<String, String> adapterPatterns); static HashMap parseLemonGraphResult(JSONObject resultdata); static JSONObject resetGraph(String graphId); static JSONObject deleteGraph(String graphId); static String createGraph(JSONObject meta); static String createGraph(String graphId, JSONObject meta); static LemonGraphResponse postToGraph(String graphId, LemonGraphObject graph); static LemonGraphResponse postToGraph(LGPayload payload); static String getContent(String uri); static JSONObject getGraph(String jobId); static JSONObject getGraphCytoscape(String jobId); static JSONObject getGraphD3(String jobId); static JSONObject getGraphD3(String jobId, int start, int stop); static LemonGraphObject buildLemonGraphFromPayloadNodesandEdges(List<JSONObject> inNodes, List<JSONArray> inEdges); static void main(String[] args); final static int NOT_FOUND; static String restUrl; static HttpClient client; }
@Test public void testCreateGraph() { String graphId = ""; try { JSONObject meta = new JSONObject(); meta.put("orig_meta", 4); graphId = lg.createGraph(meta); } catch (Exception e) { fail("Unable to create new graph in LEMONGRAPH"); } try { UUID toUuid = UUID.fromString(graphId); assertEquals(toUuid.toString(), graphId); } catch (IllegalArgumentException e) { fail("Invalid graph id in testCreateGraph"); } try { JSONObject results2 = lg.getGraph(graphId); JSONObject meta = results2.getJSONObject("meta"); if (meta.has("orig_meta")) { int v = meta.getInt("orig_meta"); assertEquals(v,4); } } catch (InvalidGraphException e) { fail("ERROR getting the graph " + graphId + " " + e.getMessage()); } try { lg.deleteGraph(graphId); } catch (Exception e) { fail("Unable to delete graph from LemonGraph " + e.getMessage()); } try { JSONObject deleteCheck = lg.getGraph(graphId); fail("Graph delete failed!"); } catch (InvalidGraphException e) { } }