ng[][] MockHTable table = MockHTable.with(new String[][] { { "<rowid>", "<column>", "<value>" }, { "id", "family:qualifier1", "data1" }, { "id", "family:qualifier2", "data2" } }); // YAML String database = "id:\n family:qualifier1: data1\n family:qualifier2: data2\n"; MockHTable table = MockHTable.with((Map
) new Yaml().load(database)); If value is not supposed to be a String, but an int, double or anything, MockHTable.toEString()
can be used to turn it into a String.
In order to simplify assertions for tests that should put anything into database, MockHTable.read() works with two parameters (id and column) and returns anything written to that row/column. So, previous test can be reduced to
@Test public void testSave() { MockHTable table = MockHTable.create(); MyDAO(table).saveData(id, data); assertArrayEquals(data, table.read(id, "family:qualifier")); }
@author erdem