Skip to content

Commit

Permalink
Updated ReadMe for syntax errors of strike of code (#147)
Browse files Browse the repository at this point in the history
Syntax error corrections on strike of code.
Correcting the assert methods name as Assert.assertTrue()
Making assertion pass by swapping the value of friend1Obj with friend2Obj.
  • Loading branch information
RushikeshNaiknaware authored Jul 11, 2022
1 parent 5e73cb0 commit 7414e90
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,23 @@ Assert.assertTrue(data.has("friends"));
Object friendsObject = data.get("friends");
Assert.assertTrue(friendsObject instanceof JSONArray);
JSONArray friends = (JSONArray) friendsObject;
Assert.assertEquals(2, data.length());
JSONObject friend1Obj = friends.getJSONObject(data.get(0));
Assert.true(friend1Obj.has("id"));
Assert.true(friend1Obj.has("name"));
JSONObject friend2Obj = friends.getJSONObject(data.get(1));
Assert.true(friend2Obj.has("id"));
Assert.true(friend2Obj.has("name"));
Assert.assertEquals(2, friends.length());
JSONObject friend1Obj = friends.getJSONObject(0);
Assert.assertTrue(friend1Obj.has("id"));
Assert.assertTrue(friend1Obj.has("name"));
JSONObject friend2Obj = friends.getJSONObject(1);
Assert.assertTrue(friend2Obj.has("id"));
Assert.assertTrue(friend2Obj.has("name"));

if ("Carter Page".equals(friend1Obj.getString("name"))) {
Assert.assertEquals(123, friend1Obj.getInt("id"));
Assert.assertEquals(456, friend1Obj.getInt("id"));
Assert.assertEquals("Corby Page", friend2Obj.getString("name"));
Assert.assertEquals(456, friend2Obj.getInt("id"));
Assert.assertEquals(123, friend2Obj.getInt("id"));
}
else if ("Corby Page".equals(friend1Obj.getString("name"))) {
Assert.assertEquals(456, friend1Obj.getInt("id"));
Assert.assertEquals(123, friend1Obj.getInt("id"));
Assert.assertEquals("Carter Page", friend2Obj.getString("name"));
Assert.assertEquals(123, friend2Obj.getInt("id"));
Assert.assertEquals(456, friend2Obj.getInt("id"));
}
else {
Assert.fail("Expected either Carter or Corby, Got: " + friend1Obj.getString("name"));
Expand Down

0 comments on commit 7414e90

Please sign in to comment.