TrendService { @Cacheable("trends-cache") public List<Trend> getCurrentTrends(String domain) { List<String> tags = trendRepository.getRecentTags(domain); 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 testCurrentTrends() { mockAuthentication("currentuser@domain.com"); String domain = "domain.com"; Collection<Trend> trends = trendService.getCurrentTrends(domain); for (Trend trend : trends) { if (trend.getTag().equals("TheTrend")) { fail("#TheTrend shoud not be trending yet"); } } for (int i = 0; i < 5; i++) { statusUpdateService.postStatus("Trending message " + i + " #Trending", false, new ArrayList<String>(), null); } trends = trendService.getCurrentTrends(domain); boolean foundTrend = false; for (Trend trend : trends) { if (trend.getTag().equals("Trending")) { foundTrend = true; assertTrue(trend.isTrendingUp()); } } if (!foundTrend) { fail("#Trending should have been trending"); } for (int i = 0; i < 7; i++) { statusUpdateService.postStatus("New trending message " + i + " #NewTrend", false, new ArrayList<String>(), null); } trends = trendService.getCurrentTrends(domain); foundTrend = false; boolean foundNewTrend = false; for (Trend trend : trends) { if (trend.getTag().equals("Trending")) { foundTrend = true; assertFalse(trend.isTrendingUp()); } else if (trend.getTag().equals("NewTrend")) { foundNewTrend = true; assertTrue(trend.isTrendingUp()); } } if (!foundTrend) { fail("#Trending should have been trending"); } if (!foundNewTrend) { fail("#NewTrend should have been trending"); } }