Skip to content

Commit

Permalink
getRequests: fix query error
Browse files Browse the repository at this point in the history
  • Loading branch information
Amarygdala committed Oct 28, 2022
1 parent bd41f66 commit 754fda1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/java/ca/utoronto/utm/mcs/Neo4jDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ 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);
Expand All @@ -124,7 +124,7 @@ public String getMovie(String movieId) throws JSONException {
}
List<Record> 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);
Expand All @@ -139,15 +139,15 @@ 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()){
System.out.println("No movie with this ID");
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()){
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/ca/utoronto/utm/mcs/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void getMoviePass() throws JSONException, IOException, InterruptedExcepti
public void getMovieFail() throws JSONException, IOException, InterruptedException {
JSONObject setupReq = new JSONObject()
.put("name", "TestMovie")
.put("actorId", "12345678901");
.put("movieId", "12345678901");
sendRequest("/api/v1/addMovie", "PUT", setupReq.toString());

JSONObject confirmReq = new JSONObject()
Expand Down

0 comments on commit 754fda1

Please sign in to comment.