@Test
public void testGetActiveColumnsByToTV() throws Exception {

    DateTime end = DateTime.now();
    DateTime start = end.minusDays(1);
    underTest.persistValue(new EmojiEntity("u1", "r1", start.plusMillis(1), "a", 1, true));
    underTest.persistValue(new EmojiEntity("u1", "r2", start.plusMillis(2), "b", 1, false));
    underTest.persistValue(new EmojiEntity("u2", "r3", start.plusMillis(3), "c", 1, false));
    underTest.persistValue(new EmojiEntity("u1", "r4", start.plusMillis(4), "d", 1, false));
    underTest.persistValue(new EmojiEntity("u1", "r4", start.plusMillis(5), "e", 1, false));
    underTest.persistValue(new EmojiEntity("u1", "r5", start.plusMillis(6), "f", 1, false));
    underTest.persistValue(new EmojiEntity("u1", "r5", start.plusMillis(7), "g", 1, false));
    underTest.persistValue(new EmojiEntity("u1", "r5", start.plusMillis(8), "h", 1, false));
    Interval interval = new Interval(start, end);
    Map<String, Double> result = underTest.getActiveColumnsByToTV("roomName", interval, 100,
                                                                  true);
    assertEquals(5, result.size());
    assertEquals(0.375, result.get("r5").doubleValue(), 0);
    assertEquals(0.25, result.get("r4").doubleValue(), 0);
    assertEquals(0.125, result.get("r3").doubleValue(), 0);
    assertEquals(0.125, result.get("r2").doubleValue(), 0);
    assertEquals(0.125, result.get("r1").doubleValue(), 0);
    // check that they're in descending order
    double previousValue = Double.MIN_VALUE;
    for (double value : result.values()) {
        assertTrue(Double.compare(value, previousValue) > 0);
    }
    // exclude bots
    result = underTest.getActiveColumnsByToTV("roomName", interval, 100, false);
    assertEquals(4, result.size());
    assertEquals(0.428, result.get("r5").doubleValue(), 0.001);
    assertEquals(0.285, result.get("r4").doubleValue(), 0.001);
    assertEquals(0.142, result.get("r3").doubleValue(), 0.001);
    assertEquals(0.142, result.get("r2").doubleValue(), 0.001);
    // check with a smaller interval
    interval = new Interval(start.plusMillis(2), start.plusMillis(6));
    result = underTest.getActiveColumnsByToTV("roomName", interval, 100, true);
    assertEquals(3, result.size());
    Map.Entry<String, Double> firstEntry = result.entrySet().iterator().next();
    assertEquals("r4", firstEntry.getKey());
    assertEquals(0.5, firstEntry.getValue().doubleValue(), 0);
}