Example #1
0
  @Test
  public void shouldReturnAllStacksWhenSearchingWithoutTags() throws Exception {
    final List<StackImpl> found = stackDao.searchStacks(null, null, 0, 0);
    found.forEach(s -> Collections.sort(s.getTags()));
    for (StackImpl stack : stacks) {
      Collections.sort(stack.getTags());
    }

    assertEquals(new HashSet<>(found), new HashSet<>(asList(stacks)));
  }
Example #2
0
  @Test(dependsOnMethods = "shouldUpdateStack")
  public void shouldFindStacksWithSpecifiedTags() throws Exception {
    stacks[0].getTags().addAll(asList("search-tag1", "search-tag2"));
    stacks[1].getTags().addAll(asList("search-tag1", "non-search-tag"));
    stacks[2].getTags().addAll(asList("non-search-tag", "search-tag2"));
    stacks[3].getTags().addAll(asList("search-tag1", "search-tag2", "another-tag"));
    updateAll();

    final List<StackImpl> found =
        stackDao.searchStacks(null, asList("search-tag1", "search-tag2"), 0, 0);
    found.forEach(s -> Collections.sort(s.getTags()));
    for (StackImpl stack : stacks) {
      Collections.sort(stack.getTags());
    }

    assertEquals(new HashSet<>(found), new HashSet<>(asList(stacks[0], stacks[3])));
  }