From 6ea9169e31c8c5376dec90a763722453eae6c685 Mon Sep 17 00:00:00 2001 From: BillyZ1435 Date: Fri, 28 Oct 2022 14:14:31 -0400 Subject: [PATCH] getRequests: removed unused variables and changed data label --- src/main/java/ca/utoronto/utm/mcs/Neo4jDAO.java | 15 +++++++-------- src/test/java/ca/utoronto/utm/mcs/AppTest.java | 6 ------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/java/ca/utoronto/utm/mcs/Neo4jDAO.java b/src/main/java/ca/utoronto/utm/mcs/Neo4jDAO.java index 311c728..27ec9b4 100644 --- a/src/main/java/ca/utoronto/utm/mcs/Neo4jDAO.java +++ b/src/main/java/ca/utoronto/utm/mcs/Neo4jDAO.java @@ -114,17 +114,18 @@ public String getActor(String id) throws JSONException { public String getMovie(String movieId) throws JSONException { JSONObject response = new JSONObject(); String query; - query = "MATCH (m:movie { id: \"%s\"}) RETURN m.name"; + query = "MATCH (m:movie { id: \"%s\"}) RETURN m.Name"; query = String.format(query, movieId); Result result = this.session.run(query); + System.out.println(result.hasNext()); if(!result.hasNext()){ System.out.println("No movie with this ID"); return "404"; } List resultValues = result.list(); response.put("movieId", movieId); - response.put("name", resultValues.get(0).get("m.name").asString()); + response.put("name", resultValues.get(0).get("m.Name").asString()); query = "MATCH (a:actor)-[r:ACTED_IN]->(m:movie { id: \"%s\"}) RETURN a.id"; query = String.format(query, movieId); @@ -139,7 +140,7 @@ public String hasRelationship(String actorId, String movieId) throws JSONExcepti JSONObject response = new JSONObject(); String query; - query = "MATCH (m:movie { id: \"%s\"}) RETURN m.name"; + query = "MATCH (m:movie { id: \"%s\"}) RETURN m.Name"; query = String.format(query, movieId); Result result = this.session.run(query); if(!result.hasNext()){ @@ -147,7 +148,7 @@ public String hasRelationship(String actorId, String movieId) throws JSONExcepti return "404"; } - query = "MATCH (a:actor { id: \"%s\"}) RETURN a.name"; + query = "MATCH (a:actor { id: \"%s\"}) RETURN a.Name"; query = String.format(query, actorId); result = this.session.run(query); if(!result.hasNext()){ @@ -224,19 +225,17 @@ public String computeBaconPath(String actorId) throws JSONException { } public void deleteMovie(String movieId) throws JSONException { - JSONObject response = new JSONObject(); String query; query = "MATCH (m:movie { id: \"%s\"}) DETACH DELETE m"; query = String.format(query, movieId); - Result result = this.session.run(query); + this.session.run(query); } public void deleteActor(String actorId) throws JSONException { - JSONObject response = new JSONObject(); String query; query = "MATCH (a:actor { id: \"%s\"}) DETACH DELETE a"; query = String.format(query, actorId); - Result result = this.session.run(query); + this.session.run(query); } } diff --git a/src/test/java/ca/utoronto/utm/mcs/AppTest.java b/src/test/java/ca/utoronto/utm/mcs/AppTest.java index 3ada8ea..4ca7f06 100644 --- a/src/test/java/ca/utoronto/utm/mcs/AppTest.java +++ b/src/test/java/ca/utoronto/utm/mcs/AppTest.java @@ -149,16 +149,10 @@ public void getMoviePass() throws JSONException, IOException, InterruptedExcepti @Test public void getMovieFail() throws JSONException, IOException, InterruptedException { - JSONObject setupReq = new JSONObject() - .put("name", "TestMovie") - .put("actorId", "12345678901"); - sendRequest("/api/v1/addMovie", "PUT", setupReq.toString()); - JSONObject confirmReq = new JSONObject() .put("name", "TestMovie"); HttpResponse confirmRes = sendRequest("/api/v1/getMovie", "GET", confirmReq.toString()); - sendRequest("/api/v1/deleteMovie", "DELETE", setupReq.toString()); assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, confirmRes.statusCode()); }