EntityDAOImpl extends AbstractIdleService implements IEntityDAO { @Override public Map<String, Double> getActiveRoomsByMethod(Interval interval, ActiveMethod method, int resultSize, boolean withBots) { if (method == ActiveMethod.ToTV) { return occurrenceStatsDAO.getActiveColumnsByToTV("roomName", interval, resultSize, withBots); } else if (method == ActiveMethod.ToMV) { return occurrenceStatsDAO.getActiveColumnsByToMV("roomName", interval, resultSize, withBots); } else { throw new UnsupportedOperationException(String.format("Method %s not supported", method)); } } EntityDAOImpl(EntityManagerFactory entityManagerFactory); @Override void persistEntity(ChatEntity entity); @Override ChatEntity getEntity(ChatEntity entity); @Override List<ChatEntity> getAllMentionsForEntity(String entity,
                                                    Interval interval,
                                                    List<String> roomNames,
                                                    List<String> usernames); @Override List<ChatEntity> getAllMentions(Interval interval,
                                           List<String> roomNames,
                                           List<String> usernames,
                                           boolean withBots); @Override int getTotalMentionsForEntity(String entity,
                                         Interval interval,
                                         List<String> roomNames,
                                         List<String> usernames,
                                         boolean withBots); @Override Map<String, Long> getTopEntities(Interval interval,
                                            List<String> roomNames,
                                            List<String> usernames,
                                            int resultSize,
                                            boolean withBots); @Override LabeledDenseMatrix<String> getRoomSimilaritiesByEntity(Interval interval,
                                                                  boolean withBots); @Override LabeledDenseMatrix<String> getUserSimilaritiesByEntity(Interval interval,
                                                                  boolean withBots); @Override Map<String, Double> getActiveUsersByMethod(Interval interval,
                                                      ActiveMethod method,
                                                      int resultSize,
                                                      boolean withBots); @Override Map<String, Double> getActiveRoomsByMethod(Interval interval,
                                                      ActiveMethod method,
                                                      int resultSize,
                                                      boolean withBots);  }
@Test public void testGetTopRoomsByMethod() { Interval interval = new Interval(mentionDate.minusMillis(1), mentionDate.plusMillis(1)); Map<String, Double> result = underTest.getActiveRoomsByMethod(interval, ActiveMethod.ToTV, 10, true); assertEquals(2, result.size()); assertEquals(0.75, result.get("room1"), 0); assertEquals(0.25, result.get("room2"), 0); result = underTest.getActiveRoomsByMethod(interval, ActiveMethod.ToMV, 10, true); assertEquals(2, result.size()); assertEquals(0.15, result.get("room1"), 0); assertEquals(0.05, result.get("room2"), 0); }