@Test
public void testSingleLoad() throws Exception {

    Formatter formatter;
    String resultString;
    LoadRecord rec1, rec2;
    String expected;
    Map<Level, LoadRecord> loadMap;
    LoadRecord summary;
    Load load = new Load(new LevelClass(ServerName.class));
    // iteration 1
    loadMap = new TreeMap<>();
    rec1 = new LoadRecord();
    rec1.put(LoadEntry.MemstoreSize, 112233);
    rec1.put(LoadEntry.Writes, 0);
    loadMap.put(new Level("rec11"), rec1);
    rec2 = new LoadRecord();
    rec2.put(LoadEntry.Writes, 11223344556677L);
    loadMap.put(new Level("rec1122334455"), rec2);
    summary = new LoadRecord();
    summary.put(LoadEntry.MemstoreSize, 11223344);
    summary.put(LoadEntry.Writes, 0);
    load.setLoadMap(loadMap);
    load.setSummary(summary);
    formatter = new Formatter("testTable", load);
    resultString = formatter.buildString(false, Formatter.Type.ANSI);
    System.out.println(resultString);
    expected = "RegionServer    Reads      Writes                Regions    Files      FileSize   FileSizeUncomp  MemstoreSize     CompactedKVs  \n" +
            " rec11          N/A | N/A               0 | N/A  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A         112233m | N/A  N/A | N/A     \n" +
            " rec1122334455  N/A | N/A  11223344556677 | N/A  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A             N/A | N/A  N/A | N/A     \n" +
            " Total: 2       N/A | N/A               0 | N/A  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A       11223344m | N/A  N/A | N/A     \n";
    Assert.assertEquals(expected, Color.clearColor(resultString, Formatter.Type.ANSI));
    // iteration 2
    load.prepare();
    loadMap = new TreeMap<>();
    rec1 = new LoadRecord();
    rec1.put(LoadEntry.MemstoreSize, 112233);
    rec1.put(LoadEntry.Writes, 0);
    loadMap.put(new Level("rec11"), rec1);
    summary = new LoadRecord();
    summary.put(LoadEntry.MemstoreSize, 11223344);
    summary.put(LoadEntry.Writes, 1);
    load.setLoadMap(loadMap);
    load.setSummary(summary);
    resultString = formatter.buildString(false, Formatter.Type.ANSI);
    System.out.println(resultString);
    expected = "RegionServer  Reads      Writes  Regions    Files      FileSize   FileSizeUncomp  MemstoreSize    CompactedKVs  \n" +
            " rec11        N/A | N/A  0 | 0   N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A         112233m | 0m  N/A | N/A     \n" +
            " Total: 1     N/A | N/A  1 | 1   N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A       11223344m | 0m  N/A | N/A     \n";
    Assert.assertEquals(expected, Color.clearColor(resultString, Formatter.Type.ANSI));
    // iteration 3
    load.prepare();
    loadMap = new TreeMap<>();
    rec1 = new LoadRecord();
    rec1.put(LoadEntry.MemstoreSize, 1122);
    rec1.put(LoadEntry.Writes, 0);
    loadMap.put(new Level("rec1122"), rec1);
    summary = new LoadRecord();
    summary.put(LoadEntry.MemstoreSize, 11223344);
    summary.put(LoadEntry.Writes, 0);
    load.setLoadMap(loadMap);
    load.setSummary(summary);
    resultString = formatter.buildString(false, Formatter.Type.ANSI);
    System.out.println(resultString);
    expected = "RegionServer  Reads      Writes   Regions    Files      FileSize   FileSizeUncomp  MemstoreSize     CompactedKVs  \n" +
            " rec1122      N/A | N/A  0 | N/A  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A           1122m | N/A  N/A | N/A     \n" +
            " Total: 1     N/A | N/A  0 |  -1  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A       11223344m |  0m  N/A | N/A     \n";
    Assert.assertEquals(expected, Color.clearColor(resultString, Formatter.Type.ANSI));
}