@Test
public void testGetActiveColumnsByToMV() throws Exception {

    DateTime end = DateTime.now();
    DateTime start = end.minusDays(1);
    Interval interval = new Interval(start, end);
    IMessageSummaryDAO msgSummaryDao =  ChatAlyticsDAOFactory.createMessageSummaryDAO(config);
    msgSummaryDao.startAsync().awaitRunning();
    underTest.persistValue(new EmojiEntity("u1", "r1", start.plusMillis(1), "a", 1, true));
    underTest.persistValue(new EmojiEntity("u2", "r1", start.plusMillis(3), "c", 1, false));
    underTest.persistValue(new EmojiEntity("u1", "r2", start.plusMillis(4), "a", 1, true));
    msgSummaryDao.persistMessageSummary(new MessageSummary("u1", "r1", start.plusMillis(1),
                                                           MESSAGE, 1, true));
    msgSummaryDao.persistMessageSummary(new MessageSummary("u1", "r1", start.plusMillis(1),
                                                           MESSAGE, 1, true));
    msgSummaryDao.persistMessageSummary(new MessageSummary("u1", "r1", start.plusMillis(1),
                                                           CHANNEL_JOIN, 1, true));
    msgSummaryDao.persistMessageSummary(new MessageSummary("u2", "r1", start.plusMillis(1),
                                                           MESSAGE, 1, false));
    msgSummaryDao.persistMessageSummary(new MessageSummary("u2", "r1", start.plusMillis(1),
                                                           CHANNEL_JOIN, 1, false));
    msgSummaryDao.persistMessageSummary(new MessageSummary("u1", "r2", start.plusMillis(1),
                                                           MESSAGE, 1, true));
    msgSummaryDao.persistMessageSummary(new MessageSummary("u3", "r2", start.plusMillis(1),
                                                           MESSAGE, 1, false));
    msgSummaryDao.persistMessageSummary(new MessageSummary("u1", "r2", start.plusMillis(1),
                                                           MESSAGE_CHANGED, 1, true));
    Map<String, Double> result = underTest.getActiveColumnsByToMV("username", interval, 100,
                                                                  true);
    assertEquals(2, result.size());
    // u1 has 3 messages and 2 emojis. u2 has 1 message and 1 emoji. u3 has 1 message.
    // Total message volume is 5. u1 should be 2/5 and u2 should be 1/5
    assertEquals(0.4, result.get("u1").doubleValue(), 0);
    assertEquals(0.2, result.get("u2").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.getActiveColumnsByToMV("username", interval, 100, false);
    assertEquals(1, result.size());
    // u1 is a bot. u2 has 1 messages and 1 emoji. u3 has 1 message. Total message volume is 2
    // u1 will get excluded u2 should be 1/2
    assertEquals(0.5, result.get("u2").doubleValue(), 0);
    // check with a smaller interval
    interval = new Interval(start.plusMillis(2), start.plusMillis(6));
    result = underTest.getActiveColumnsByToTV("username", interval, 100, true);
    assertEquals(2, result.size());
    assertEquals(0.5, result.get("u1").doubleValue(), 0);
    assertEquals(0.5, result.get("u2").doubleValue(), 0);
    // check that they're in descending order
    previousValue = Double.MIN_VALUE;
    for (double value : result.values()) {
        assertTrue(Double.compare(value, previousValue) > 0);
    }
    msgSummaryDao.stopAsync().awaitTerminated();
}