package com.github.arteam.jgcompare;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import org.assertj.core.api.Assertions;
import org.junit.Test;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Date: 5/15/14
 * Time: 12:06 AM
 *
 * @author Artem Prigoda
 */
public class MapsTest {

    private final List<Team> teams = ImmutableList.of(
            new Team(12, "Chicago Blackhawks"),
            new Team(42, "St. Louis Blues"),
            new Team(88, "Colorado Avalanche"));

    @Test
    public void testUniqueIndex() {
        Map<Long, Team> expected = ImmutableMap.of(
                12L, new Team(12, "Chicago Blackhawks"),
                42L, new Team(42, "St. Louis Blues"),
                88L, new Team(88, "Colorado Avalanche"));
        assertThat(Maps.uniqueIndex(teams, Team::getId)).isEqualTo(expected);

        assertThat(teams.stream().collect(Collectors.toMap(Team::getId, Function.identity())))
                .isEqualTo(expected);
    }
}

@@ -68,107 +68,9 @@
 ect.
-ImmutableList;%0Aimport com.google.common.collect.ImmutableMap;%0Aimport com.google.common.collect.Maps
+*
 ;%0Aim
@@ -148,20 +148,17 @@
 va.util.
-List
+*
 ;%0Aimport
@@ -172,37 +172,31 @@
 til.
-Map;%0Aimport java.util.Objects
+function.BinaryOperator
 ;%0Aim
@@ -1103,11 +1103,1136 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testAsNavigableMap() %7B%0A        Map%3CInteger, String%3E teams = ImmutableMap.%3CInteger, String%3Ebuilder()%0A                .put(21, %22Boston Bruins%22)%0A                .put(24, %22Los Angeles Kings%22)%0A                .put(12, %22Chicago Blackhawks%22)%0A                .put(42, %22St. Louis Blues%22)%0A                .put(29, %22Arizona Coyotes%22)%0A                .put(92, %22Winnipeg Jets%22)%0A                .put(88, %22Colorado Avalanche%22)%0A                .build();%0A        Map%3CInteger, String%3E expected = ImmutableSortedMap.of(12, %22Chicago Blackhawks%22, 42, %22St. Louis Blues%22, 88, %22Colorado Avalanche%22);%0A%0A        Set%3CInteger%3E source = ImmutableSortedSet.of(42, 88, 12);%0A        assertThat(Maps.asMap(source, teams::get)).isEqualTo(expected);%0A%0A        Map%3CInteger, String%3E result = source.stream()%0A                .collect(Collectors.toMap(Function.identity(), teams::get,%0A                        (s1, s2) -%3E %7B%0A                            throw new IllegalArgumentException(%22Two values for the same key%22);%0A                        %7D,%0A                        TreeMap::new));%0A        assertThat(result).isEqualTo(expected);%0A    %7D
 %0A%7D%0A

Add Maps.asMap for NavigableSet