@Override public Boolean convertToAvro(String value) { return ParserUtils.parseToBoolean(value); } }
@Test public void testParseToBoolean() throws Exception { assertNull(ParserUtils.parseToBoolean(null)); // "1" would return true assertTrue(ParserUtils.parseToBoolean("1")); // Others flow to the boolean parser assertFalse(ParserUtils.parseToBoolean("0")); assertTrue(ParserUtils.parseToBoolean("true")); assertFalse(ParserUtils.parseToBoolean("false")); assertTrue(ParserUtils.parseToBoolean("TRUE")); assertFalse(ParserUtils.parseToBoolean("FALSE")); assertFalse(ParserUtils.parseToBoolean("a")); }