Skip to content

Commit

Permalink
getRequests: removed unused variables and changed data label
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyZ1435 committed Oct 28, 2022
1 parent bd41f66 commit 6ea9169
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
15 changes: 7 additions & 8 deletions src/main/java/ca/utoronto/utm/mcs/Neo4jDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 +140,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 Expand Up @@ -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);
}
}
6 changes: 0 additions & 6 deletions src/test/java/ca/utoronto/utm/mcs/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> confirmRes = sendRequest("/api/v1/getMovie", "GET", confirmReq.toString());

sendRequest("/api/v1/deleteMovie", "DELETE", setupReq.toString());
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, confirmRes.statusCode());
}

Expand Down

0 comments on commit 6ea9169

Please sign in to comment.