@Test
  public void whenReverseList_thenReversed() {
    final List<String> names = Lists.newArrayList("John", "Adam", "Jane");

    final List<String> reversed = Lists.reverse(names);
    assertThat(reversed, contains("Jane", "Adam", "John"));
  }
  @Test
  public void whenPartitionList_thenPartitioned() {
    final List<String> names = Lists.newArrayList("John", "Jane", "Adam", "Tom", "Viki", "Tyler");
    final List<List<String>> result = Lists.partition(names, 2);

    assertEquals(3, result.size());
    assertThat(result.get(0), contains("John", "Jane"));
    assertThat(result.get(1), contains("Adam", "Tom"));
    assertThat(result.get(2), contains("Viki", "Tyler"));
  }
  @Test
  public void whenCreateCharacterListFromString_thenCreated() {
    final List<Character> chars = Lists.charactersOf("John");

    assertEquals(4, chars.size());
    assertThat(chars, contains('J', 'o', 'h', 'n'));
  }
  @Test
  public void whenRemoveNullFromList_thenRemoved() {
    final List<String> names = Lists.newArrayList("John", null, "Adam", null, "Jane");
    Iterables.removeIf(names, Predicates.isNull());

    assertEquals(3, names.size());
    assertThat(names, contains("John", "Adam", "Jane"));
  }
  @Test
  public void whenRemoveDuplicatesFromList_thenRemoved() {
    final List<Character> chars = Lists.newArrayList('h', 'e', 'l', 'l', 'o');
    assertEquals(5, chars.size());

    final List<Character> result = ImmutableSet.copyOf(chars).asList();
    assertThat(result, contains('h', 'e', 'l', 'o'));
  }
  @Test
  public void whenCreateImmutableList_thenCreated() {
    final List<String> names = Lists.newArrayList("John", "Adam", "Jane");

    names.add("Tom");
    assertEquals(4, names.size());

    final ImmutableList<String> immutable = ImmutableList.copyOf(names);
    assertThat(immutable, contains("John", "Adam", "Jane", "Tom"));
  }
  @Test
  public void whenCreateList_thenCreated() {
    final List<String> names = Lists.newArrayList("John", "Adam", "Jane");

    names.add("Tom");
    assertEquals(4, names.size());

    names.remove("Adam");
    assertThat(names, contains("John", "Jane", "Tom"));
  }
  @Test
  public void whenGetTopUsingMultiSet_thenCorrect() {
    final Multiset<String> names = HashMultiset.create();
    names.add("John");
    names.add("Adam", 5);
    names.add("Jane");
    names.add("Tom", 2);

    final Set<String> sorted = Multisets.copyHighestCountFirst(names).elementSet();
    final List<String> topTwo = Lists.newArrayList(sorted).subList(0, 2);
    assertEquals(2, topTwo.size());
    assertEquals("Adam", topTwo.get(0));
    assertEquals("Tom", topTwo.get(1));
  }
  @Test
  public void whenGroupListUsingMultimap_thenGrouped() {
    final List<String> names = Lists.newArrayList("John", "Adam", "Tom");
    final Function<String, Integer> function =
        new Function<String, Integer>() {
          @Override
          public final Integer apply(final String input) {
            return input.length();
          }
        };
    final Multimap<Integer, String> groups = Multimaps.index(names, function);

    assertThat(groups.get(3), containsInAnyOrder("Tom"));
    assertThat(groups.get(4), containsInAnyOrder("John", "Adam"));
  }