package ru.matevosyan;

import org.junit.Test;

import java.util.*;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class UserSortTest {

    @Test
    public void whenPassArrayThanCheckList() {

        //assign
        User firsUser = new User("Vanya", 30);
        User secondUser = new User("Igor", 13);
        User thirdUser = new User("Vova", 26);
        User foursUser = new User("Vova", 26);

        List<User> userList = new ArrayList<>();
        Set<User> treeSet;

        ArrayList<Integer> expectedAge = new ArrayList<>();

        UserSort userSort = new UserSort();
        //act
        userList.add(firsUser);
        userList.add(secondUser);
        userList.add(thirdUser);
        userList.add(foursUser);

        expectedAge.add(13);
        expectedAge.add(26);
        expectedAge.add(30);

        treeSet = userSort.sort(userList);

        Iterator<User> userTreeValues = treeSet.iterator();
        Iterator<Integer> userAge = expectedAge.iterator();

        //assert

        while (userAge.hasNext() || userTreeValues.hasNext()) {
            assertThat(userTreeValues.next().getAge(), is(userAge.next()));
        }


    }



}
@@ -1296,11 +1296,2008 @@
 %0A    %7D%0A%0A
+%0A    @Test%0A    public void whenPassArrayListThanReturnSortHashCodeList() %7B%0A%0A        //assign%0A        User firsUser = new User(%22Vanya%22, 30);%0A        User secondUser = new User(%22Igor%22, 13);%0A        User thirdUser = new User(%22Vova%22, 26);%0A%0A        List%3CUser%3E userList = new ArrayList%3C%3E();%0A%0A        ArrayList%3CUser%3E expected = new ArrayList%3C%3E();%0A%0A        UserSort userSort = new UserSort();%0A        //act%0A        userList.add(firsUser);%0A        userList.add(secondUser);%0A        userList.add(thirdUser);%0A%0A        expected.add(firsUser);%0A        expected.add(secondUser);%0A        expected.add(thirdUser);%0A%0A        userList = userSort.sortHash(userList);%0A%0A        Iterator%3CUser%3E userListValues = userList.iterator();%0A        Iterator%3CUser%3E expectedValue = expected.iterator();%0A%0A        //assert%0A%0A        while (expectedValue.hasNext() %7C%7C userListValues.hasNext()) %7B%0A            assertFalse(userListValues.next().equals(expectedValue.next()));%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void whenPassArrayListThanReturnSortLengthList() %7B%0A%0A        //assign%0A        User firsUser = new User(%22VarrrryyLooonnnnggName%22, 30);%0A        User secondUser = new User(%22Aagor%22, 13);%0A        User thirdUser = new User(%22Zova%22, 26);%0A%0A        List%3CUser%3E userList = new ArrayList%3C%3E();%0A        List%3CUser%3E userList2Save;%0A%0A        ArrayList%3CUser%3E expected = new ArrayList%3C%3E();%0A%0A        UserSort userSort = new UserSort();%0A        //act%0A        userList.add(firsUser);%0A        userList.add(secondUser);%0A        userList.add(thirdUser);%0A%0A        expected.add(thirdUser);%0A        expected.add(secondUser);%0A        expected.add(firsUser);%0A%0A        userList2Save = userSort.sortLength(userList);%0A%0A        Iterator%3CUser%3E userListValues = userList2Save.iterator();%0A        Iterator%3CUser%3E expectedValue = expected.iterator();%0A%0A        //assert%0A%0A        while (expectedValue.hasNext() %7C%7C userListValues.hasNext()) %7B%0A            assertThat(userListValues.next().getName().length(), is(expectedValue.next().getName().length()));%0A        %7D%0A    %7D
 %0A%0A%7D

add 2 test methods