MessageSummaryResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<MessageSummary> getAllMessageSummaries(@QueryParam(START_TIME) String startTimeStr, @QueryParam(END_TIME) String endTimeStr, @QueryParam(USER) List<String> users, @QueryParam(ROOM) List<String> rooms, @QueryParam(MESSAGE_TYPE) String msgTypeStr, @QueryParam(BOT) String botStr) { LOG.debug("Call for msg summaries with starttime={} endtime={} users={} rooms={} botStr={}", startTimeStr, endTimeStr, users, rooms, botStr); Interval interval = DateTimeUtils.getIntervalFromParameters(startTimeStr, endTimeStr, dtz); users = ResourceUtils.getListFromNullable(users); rooms = ResourceUtils.getListFromNullable(rooms); boolean withBots = ResourceUtils.getOptionalForParameterAsBool(botStr).or(false); Optional<String> optMessageType = ResourceUtils.getOptionalForParameter(msgTypeStr); if (optMessageType.isPresent()) { MessageType msgType = MessageType.fromType(optMessageType.get()); return msgSummaryDao.getAllMessageSummariesForType(msgType, interval, rooms, users); } else { return msgSummaryDao.getAllMessageSummaries(interval, rooms, users, withBots); } } MessageSummaryResource(ChatAlyticsConfig config); @GET @Produces(MediaType.APPLICATION_JSON) List<MessageSummary> getAllMessageSummaries(@QueryParam(START_TIME) String startTimeStr,
                                                       @QueryParam(END_TIME) String endTimeStr,
                                                       @QueryParam(USER) List<String> users,
                                                       @QueryParam(ROOM) List<String> rooms,
                                                       @QueryParam(MESSAGE_TYPE) String msgTypeStr,
                                                       @QueryParam(BOT) String botStr); @GET @Path("total") @Produces(MediaType.APPLICATION_JSON) int getTotalMessageSummaries(@QueryParam(START_TIME) String startTimeStr,
                                        @QueryParam(END_TIME) String endTimeStr,
                                        @QueryParam(USER) List<String> users,
                                        @QueryParam(ROOM) List<String> rooms,
                                        @QueryParam(MESSAGE_TYPE) String msgTypeStr,
                                        @QueryParam(BOT) String botStr); @GET @Path("active") @Produces(MediaType.APPLICATION_JSON) Map<String, Double> getActive(@QueryParam(START_TIME) String startTimeStr,
                                         @QueryParam(END_TIME) String endTimeStr,
                                         @QueryParam(DIM) String dimensionStr,
                                         @QueryParam(METHOD) String methodStr,
                                         @QueryParam(TOP_N) String topNStr,
                                         @QueryParam(BOT) String botStr); static final String MESSAGE_SUMMARY_ENDPOINT; static final String MESSAGE_TYPE; static final String DIM; static final String METHOD; }
@Test public void testGetAllMessageTypes() throws Exception { DateTimeFormatter dtf = DateTimeUtils.PARAMETER_WITH_DAY_DTF.withZone(dtZone); String startTimeStr = dtf.print(mentionTime.minusDays(1)); String endTimeStr = dtf.print(mentionTime.plusDays(1)); List<MessageSummary> result = underTest.getAllMessageSummaries(startTimeStr, endTimeStr, null, null, null, null); assertEquals(sums.size(), result.size()); Set<MessageSummary> resultMessageSummarySet = Sets.newHashSet(result); for (MessageSummary expectedMessageSummary : sums) { assertTrue(resultMessageSummarySet.contains(expectedMessageSummary)); } result = underTest.getAllMessageSummaries(startTimeStr, endTimeStr, null, null, BOT_MESSAGE.toString(), null); assertEquals(1, result.size()); assertEquals(BOT_MESSAGE, result.get(0).getValue()); }