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.junit.Test;

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

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;

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

    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), equalTo(expected));

        assertThat(teams
                .stream()
                .collect(Collectors.toMap(Team::getId, (team) -> team)),
                equalTo(expected));
    }

    private static class Team {
        private final long id;
        private final String name;

        private Team(long id, String name) {
            this.id = id;
            this.name = name;
        }

        private long getId() {
            return id;
        }

        private String getName() {
            return name;
        }

        @Override
        public boolean equals(Object o) {
            if (o instanceof Team) {
                Team that = (Team) o;
                return Objects.equals(id, that.id) && Objects.equals(name, that.name);
            }
            return false;
        }

        @Override
        public int hashCode() {
            return Objects.hash(id, name);
        }


    }
}

@@ -260,16 +260,52 @@
 bjects;%0A
+import java.util.function.Function;%0A
 import j
@@ -526,16 +526,30 @@
  %7B%0A%0A    
+private final 
 List%3CTea
@@ -1089,33 +1089,16 @@
 at(teams
-%0A                
 .stream(
@@ -1099,16 +1099,24 @@
 tream()%0A
+        
         
@@ -1166,22 +1166,27 @@
 Id, 
-(team) -%3E team
+Function.identity()
 )),%0A
@@ -1265,30 +1265,29 @@
  %7B%0A        p
-rivate
+ublic
  final long 
@@ -1295,30 +1295,29 @@
 d;%0A        p
-rivate
+ublic
  final Strin

Update to Function#indentity