### Question:
FileLocation extends AbstractReport { @Override public void print(PrintStream out, StringBuilder ret , int level, boolean first) { ret.setLength(0); out.print(addLevel(ret, level).append('{')); out.print(toJsonString(ret, level + 1, "filename", filename, true)); if (lineNumber != null) { out.print(toJsonString(ret, level + 1, "line_number", lineNumber, false)); } if (columnNumber != null) { out.print(toJsonString(ret, level + 1, "column_number", columnNumber, false)); } ret.setLength(0); out.print(addLevel(ret.append('\n'), level).append('}')); } protected  FileLocation(String fileName); protected  FileLocation(String fileName, int lineNumber, int columnNumber);  FileLocation(DataLocation dl); @Override void print(PrintStream out, StringBuilder ret , int level, boolean first);  }### Answer:
@Test(groups = { "JsonGeneration" }, description = "Json generated", priority = 104) public void verifyJsonGeneration() throws Exception { { ByteArrayOutputStream oStream = new ByteArrayOutputStream(); PrintStream stream = new PrintStream(oStream); FileLocation fileLocation = new FileLocation("fileName", 0, 0); fileLocation.print(stream, new StringBuilder(), 1, true); String text = oStream.toString(); JSONObject res = new JSONObject(text); Assert.assertEquals(res.getString("filename"), "fileName", "wrong file location name"); Assert.assertEquals(res.getInt("line_number"), 0, "wrong file location line number"); Assert.assertEquals(res.getInt("column_number"), 0, "wrong file location column number"); } { ByteArrayOutputStream oStream = new ByteArrayOutputStream(); PrintStream stream = new PrintStream(oStream); FileLocation fileLocation = new FileLocation("fileName", 15, 0); fileLocation.print(stream, new StringBuilder(), 1, true); String text = oStream.toString(); JSONObject res = new JSONObject(text); Assert.assertEquals(res.getString("filename"), "fileName", "wrong file location name"); Assert.assertEquals(res.getInt("line_number"), 15, "wrong file location line number"); Assert.assertEquals(res.getInt("column_number"), 0, "wrong file location column number"); } { ByteArrayOutputStream oStream = new ByteArrayOutputStream(); PrintStream stream = new PrintStream(oStream); FileLocation fileLocation = new FileLocation("fileName", 0, 10); fileLocation.print(stream, new StringBuilder(), 1, true); String text = oStream.toString(); JSONObject res = new JSONObject(text); Assert.assertEquals(res.getString("filename"), "fileName", "wrong file location name"); Assert.assertEquals(res.getInt("line_number"), 0, "wrong file location line number"); Assert.assertEquals(res.getInt("column_number"), 10, "wrong file location column number"); } }