TrendService { public Collection<String> searchTags(String domain, String startWith, int size) { Assert.hasLength(startWith); Collection<String> allTags = trendRepository.getDomainTags(domain); Collection<String> matchingTags = new ArrayList<String>(); String startWithLowered = startWith.toLowerCase(); int counter = 0; for (String tag : allTags) { if (tag.toLowerCase().startsWith(startWithLowered)) { matchingTags.add(tag); counter++; } if (counter == size) { break; } } return matchingTags; }  @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 testSearchTags() { mockAuthentication("currentuser@domain.com"); String domain = "domain.com"; Collection<String> tags = trendService.searchTags(domain, "Te", 1); assertEquals(0, tags.size()); tags = trendService.searchTags(domain, "Test", 1); assertEquals(0, tags.size()); statusUpdateService.postStatus("Message #Test", false, new ArrayList<String>(), null); tags = trendService.searchTags(domain, "Te", 1); assertEquals(1, tags.size()); tags = trendService.searchTags(domain, "Test", 1); assertEquals(1, tags.size()); }