TrendService { @Cacheable("user-trends-cache") public List<Trend> getTrendsForUser(String login) { List<String> tags = userTrendRepository.getRecentTags(login); return calculateTrends(tags); }  @Cacheable("trends-cache") List<Trend> getCurrentTrends(String domain); Collection<String> searchTags(String domain, String startWith, int size); @Cacheable("user-trends-cache") List<Trend> getTrendsForUser(String login);  }
@Test public void testUserTrends() { String login = "currentuser@domain.com"; mockAuthentication(login); Collection<Trend> trends = trendService.getTrendsForUser(login); for (Trend trend : trends) { if (trend.getTag().equals("MyTrend")) { fail("#MyTrend shoud not be trending yet"); } } for (int i = 0; i < 5; i++) { statusUpdateService.postStatus("User trending message " + i + " #MyTrend", false, new ArrayList<String>(), null); } trends = trendService.getTrendsForUser(login); boolean foundTrend = false; for (Trend trend : trends) { if (trend.getTag().equals("MyTrend")) { foundTrend = true; assertTrue(trend.isTrendingUp()); } } if (!foundTrend) { fail("#MyTrend should have been trending"); } }