LazyHBaseRow o = new LazyHBaseRow((LazySimpleStructObjectInspector) oi);
HbaseMapWritable<byte[], Cell> cells =
new HbaseMapWritable<byte[], Cell>();
cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
cells.put("cfa:b".getBytes(), new Cell("a:b:c".getBytes(), 0));
cells.put("cfb:d".getBytes(), new Cell("e".getBytes(), 0));
cells.put("cfb:f".getBytes(), new Cell("g".getBytes(), 0));
cells.put("cfc:d".getBytes(), new Cell("hi".getBytes(), 0));
RowResult rr = new RowResult("test-row".getBytes(), cells);
o.init(rr, hbaseColumnNames);
assertEquals(
("{'key':'test-row','a':123,'b':['a','b','c'],"
+ "'c':{'d':'e','f':'g'},'d':'hi'}").replace("'", "\""),
SerDeUtils.getJSONString(o, oi));
cells.clear();
cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
cells.put("cfb:d".getBytes(), new Cell("e".getBytes(), 0));
cells.put("cfb:f".getBytes(), new Cell("g".getBytes(), 0));
rr = new RowResult("test-row".getBytes(), cells);
o.init(rr, hbaseColumnNames);
assertEquals(
("{'key':'test-row','a':123,'b':null,"
+ "'c':{'d':'e','f':'g'},'d':null}").replace("'", "\""),
SerDeUtils.getJSONString(o, oi));
cells.clear();
cells.put("cfa:b".getBytes(), new Cell("a".getBytes(), 0));
cells.put("cfb:f".getBytes(), new Cell("g".getBytes(), 0));
cells.put("cfc:d".getBytes(), new Cell("no".getBytes(), 0));
rr = new RowResult("test-row".getBytes(), cells);
o.init(rr, hbaseColumnNames);
assertEquals(
("{'key':'test-row','a':null,'b':['a'],"
+ "'c':{'f':'g'},'d':'no'}").replace("'", "\""),
SerDeUtils.getJSONString(o, oi));
cells.clear();
cells.put("cfa:b".getBytes(), new Cell(":a::".getBytes(), 0));
cells.put("cfc:d".getBytes(), new Cell("no".getBytes(), 0));
rr = new RowResult("test-row".getBytes(), cells);
o.init(rr, hbaseColumnNames);
assertEquals(
("{'key':'test-row','a':null,'b':['','a','',''],"
+ "'c':{},'d':'no'}").replace("'", "\""),
SerDeUtils.getJSONString(o, oi));
cells.clear();
cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
cells.put("cfa:b".getBytes(), new Cell("".getBytes(), 0));
cells.put("cfc:d".getBytes(), new Cell("".getBytes(), 0));
rr = new RowResult("test-row".getBytes(), cells);
o.init(rr, hbaseColumnNames);
assertEquals(
"{'key':'test-row','a':123,'b':[],'c':{},'d':''}".replace("'", "\""),
SerDeUtils.getJSONString(o, oi));