### Question:
JsonParserPlugin implements ParserPlugin { @Override public void transaction(ConfigSource configSource, Control control) { PluginTask task = configSource.loadConfig(PluginTask.class); control.run(task.dump(), newSchema(task)); } JsonParserPlugin(); @Override void transaction(ConfigSource configSource, Control control); @Override void run(TaskSource taskSource, Schema schema, FileInput input, PageOutput output);  }### Answer:
@Test public void readBrokenJson() { try { transaction(config, fileInput( "{\"_c0\":true,\"_c1\":10," )); fail(); } catch (Throwable t) { assertTrue(t instanceof DataException); } }
@Test public void readInvalidTimestampColumn() { final List<Object> schemaConfig = new ArrayList<>(); schemaConfig.add(config().set("name", "_c0").set("type", "long")); schemaConfig.add(config().set("name", "_c1").set("type", "timestamp")); ConfigSource config = this.config.deepCopy() .set("stop_on_invalid_record", true) .set("columns", schemaConfig); try { transaction(config, fileInput( "{\"_c0\":true,\"_c1\":\"\"," )); fail(); } catch (Throwable t) { assertTrue(t instanceof DataException); } }
@Test public void useDefaultInvalidEscapeStringFunction() throws Exception { try { transaction(config, fileInput( "{\"\\a\":\"b\"}\\" )); fail(); } catch (Throwable t) { assertTrue(t instanceof DataException); } }
@Test public void usePassthroughInvalidEscapeStringFunction() throws Exception { try { ConfigSource config = this.config.deepCopy().set("invalid_string_escapes", "PASSTHROUGH"); transaction(config, fileInput( "{\"\\a\":\"b\"}\\" )); fail(); } catch (Throwable t) { assertTrue(t instanceof DataException); } }
@Test(expected = DataException.class) public void useRootWithStopOnInvalidRecord() throws Exception { ConfigSource config = this.config.deepCopy() .set("root", "/_c0") .set("stop_on_invalid_record", true); transaction(config, fileInput( "{\"_c0\":{\"b\": 1}, \"_c1\": true}", "{}", "{\"_c0\":{\"b\": 2}, \"_c1\": false}" )); }
@Test(expected = DataException.class) public void useFlattenJsonArrayWithNonArrayJson() throws Exception { ConfigSource config = this.config .set("flatten_json_array", true) .set("stop_on_invalid_record", true); transaction(config, fileInput( "{\"_c0\": 1}" )); }
@Test public void useStopOnInvalidRecord() throws Exception { ConfigSource config = this.config.deepCopy().set("stop_on_invalid_record", true); try { transaction(config, fileInput( "[1, 2, 3]" )); fail(); } catch (Throwable t) { assertTrue(t instanceof DataException); } }