EntitiesResource { @GET @Path("trending") @Produces(MediaType.APPLICATION_JSON) public Map<String, Long> getTrendingTopics(@QueryParam(START_TIME) String startTimeStr, @QueryParam(END_TIME) String endTimeStr, @QueryParam(USER) List<String> users, @QueryParam(ROOM) List<String> rooms, @QueryParam(TOP_N) String topNStr, @QueryParam(BOT) String botStr) throws JsonGenerationException, JsonMappingException, IOException { LOG.debug("Trending topics query for starttime={}, endtime={}, users={}, rooms={}, botStr={}", startTimeStr, endTimeStr, users, rooms, botStr); int topN = ResourceUtils.getOptionalForParameterAsInt(topNStr).or(MAX_RESULTS); boolean withBots = ResourceUtils.getOptionalForParameterAsBool(botStr).or(false); Interval interval = DateTimeUtils.getIntervalFromParameters(startTimeStr, endTimeStr, dtz); users = ResourceUtils.getListFromNullable(users); rooms = ResourceUtils.getListFromNullable(rooms); return entityDao.getTopEntities(interval, rooms, users, topN, withBots); } EntitiesResource(ChatAlyticsConfig config); @GET @Path("trending") @Produces(MediaType.APPLICATION_JSON) Map<String, Long> getTrendingTopics(@QueryParam(START_TIME) String startTimeStr,
                                               @QueryParam(END_TIME) String endTimeStr,
                                               @QueryParam(USER) List<String> users,
                                               @QueryParam(ROOM) List<String> rooms,
                                               @QueryParam(TOP_N) String topNStr,
                                               @QueryParam(BOT) String botStr); @GET @Produces(MediaType.APPLICATION_JSON) List<ChatEntity> getAllEntites(@QueryParam(START_TIME) String startTimeStr,
                                          @QueryParam(END_TIME) String endTimeStr,
                                          @QueryParam(USER) List<String> users,
                                          @QueryParam(ROOM) List<String> rooms,
                                          @QueryParam(BOT) String botStr); @GET @Path("similarities") @Produces(MediaType.APPLICATION_JSON) LabeledDenseMatrix<String> getSimilarities(
            @QueryParam(START_TIME) String startTimeStr,
            @QueryParam(END_TIME) String endTimeStr,
            @QueryParam(FIRST_SIMILARITY_DIM) String firstDimStr,
            @QueryParam(SECOND_SIMILARITY_DIM) String secondDimStr,
            @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 ENTITIES_ENDPOINT; static final String FIRST_SIMILARITY_DIM; static final String SECOND_SIMILARITY_DIM; static final String DIM; static final String METHOD; }
@Test public void testGetTrendingTopics() 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)); Map<String, Long> response = underTest.getTrendingTopics(startTimeStr, endTimeStr, ImmutableList.of("u1"), ImmutableList.of("r1"), null, null); Map<String, Long> expected = Maps.newHashMap(); expected.put("e1", 5L); expected.put("e2", 1L); assertEquals(expected, response); response = underTest.getTrendingTopics(startTimeStr, endTimeStr, ImmutableList.of("u1"), null, null, null); expected.clear(); expected.put("e1", 5L); expected.put("e4", 3L); expected.put("e2", 1L); assertEquals(expected, response); response = underTest.getTrendingTopics(startTimeStr, endTimeStr, null, null, null, null); expected.clear(); expected.put("e2", 14L); expected.put("e1", 11L); expected.put("e3", 6L); expected.put("e4", 3L); assertEquals(expected, response); }