@Test
public void testResetDiffStartPointWithShowRate() throws Exception {

    String resultString;
    LoadRecord rec1;
    String expected;
    Map<Level, LoadRecord> loadMap;
    LoadRecord summary;
    Load load = new Load(new LevelClass(ServerName.class));
    Formatter formatter = new Formatter("testTable", load);
    // resetDiffFromStart and showRate
    load.resetDiffStartPoint();
    Assert.assertEquals(Load.EMPTY_TIMESTAMP, load.getTimestampStart());
    Assert.assertEquals(0, load.getTotalDuration());
    load.toggleShowRate();
    Assert.assertTrue(load.isShowRate());
    // iteration 1
    load.prepare();
    loadMap = new TreeMap<>();
    rec1 = new LoadRecord();
    rec1.put(LoadEntry.MemstoreSize, 112234);
    rec1.put(LoadEntry.Writes, 3);
    loadMap.put(new Level("rec11"), rec1);
    summary = new LoadRecord();
    summary.put(LoadEntry.MemstoreSize, 112234);
    summary.put(LoadEntry.Writes, 3);
    load.setLoadMap(loadMap);
    load.setSummary(summary);
    load.updateChangeMap();
    Assert.assertFalse(load.isDiffFromStart());
    load.setDuration(0);
    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  3 | N/A  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A       112234m | N/A  N/A | N/A     \n" +
            " Total: 1     N/A | N/A  3 | N/A  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A       112234m | 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, 112235);
    rec1.put(LoadEntry.Writes, 4);
    loadMap.put(new Level("rec11"), rec1);
    summary = new LoadRecord();
    summary.put(LoadEntry.MemstoreSize, 112235);
    summary.put(LoadEntry.Writes, 4);
    load.setLoadMap(loadMap);
    load.setSummary(summary);
    load.updateChangeMap();
    Assert.assertFalse(load.isDiffFromStart());
    load.setDuration(1000);
    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  4 | 1.0/s  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A       112235m | 1.0m/s  N/A | N/A     \n" +
            " Total: 1     N/A | N/A  4 | 1.0/s  N/A | N/A  N/A | N/A  N/A | N/A  N/A | N/A       112235m | 1.0m/s  N/A | N/A     \n";
    Assert.assertEquals(expected, Color.clearColor(resultString, Formatter.Type.ANSI));
}