package ru.job4j.collections.sort;

import org.junit.Test;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import static org.junit.Assert.assertThat;
import static org.hamcrest.core.Is.is;

/**
 * This class test SortUser class.
 *
 * @author Kucykh Vasily (mailto:basil135@mail.ru)
 * @version $Id$
 * @since 10.05.2017
 */
public class SortUserTest {

    /**
     * method tests method sort at SortUser class.
     */
    @Test
    public void whenListOfUserContainsofFiveUsersThenSortByAge() {

        SortUser sort = new SortUser();

        User din = new User("Din", 23);
        User sam = new User("Sam", 15);
        User john = new User("John", 31);
        User sara = new User("Sara", 25);
        User greg = new User("Greg", 28);

        List<User> users = new LinkedList<>();

        users.add(din);
        users.add(sam);
        users.add(john);
        users.add(sara);
        users.add(greg);

        Set<User> expectedSet = new TreeSet<>();

        expectedSet.add(sam);
        expectedSet.add(din);
        expectedSet.add(sara);
        expectedSet.add(greg);
        expectedSet.add(john);

        Set<User> actualSet = sort.sort(users);

        assertThat(actualSet, is(expectedSet));

    }

}

@@ -1275,10 +1275,1375 @@
 %0A    %7D%0A%0A
+    /**%0A     * method tests method sortLength.%0A     */%0A    @Test%0A    public void whenListOfUsersWithDifferentNamesThenSortLengthSortsUsersByLengthOfName() %7B%0A%0A        SortUser sort = new SortUser();%0A%0A        List%3CUser%3E test = new LinkedList%3C%3E();%0A%0A        User basil = new User(%22Basil%22, 27);%0A        User alex = new User(%22Alex%22, 31);%0A        User sam = new User(%22Sam%22, 33);%0A%0A        test.add(basil);%0A        test.add(alex);%0A        test.add(sam);%0A%0A        List%3CUser%3E expected = new LinkedList%3C%3E();%0A%0A        expected.add(sam);%0A        expected.add(alex);%0A        expected.add(basil);%0A%0A        List%3CUser%3E actual = sort.sortLength(test);%0A%0A        assertThat(actual, is(expected));%0A%0A    %7D%0A%0A    /**%0A     * method tests method sortHash.%0A     */%0A    @Test%0A    public void whenListOfUsersWithDifferentNamesAndAgesThenSortHashSortsUsersByHashcode() %7B%0A%0A        SortUser sort = new SortUser();%0A%0A        List%3CUser%3E test = new LinkedList%3C%3E();%0A%0A        User basil = new User(%22Basil%22, 27);%0A        User alex = new User(%22Alex%22, 31);%0A        User sam = new User(%22Sam%22, 33);%0A%0A        test.add(basil);%0A        test.add(alex);%0A        test.add(sam);%0A%0A        List%3CUser%3E expected = new LinkedList%3C%3E();%0A%0A        expected.add(sam);%0A        expected.add(alex);%0A        expected.add(basil);%0A%0A        List%3CUser%3E actual = sort.sortHash(test);%0A%0A        assertThat(actual, is(expected));%0A%0A    %7D%0A%0A
 %7D%0A

Refactor SortUserTest.java added test of sortHash and test of sort Length