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;

/**
 * UserSortTest was created to test sorting list and set.
 * Created on 28.04.2017.
 * @author Matevosyan Vardan
 * @version 1.0
 */

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()));
        }


    }


    @Test
    public void whenPassArrayListThanReturnSortHashCodeList() {

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

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

        ArrayList<User> expected = new ArrayList<>();

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

        expected.add(firsUser);
        expected.add(secondUser);
        expected.add(thirdUser);

        userList = userSort.sortHash(userList);

        Iterator<User> userListValues = userList.iterator();
        Iterator<User> expectedValue = expected.iterator();

        //assert

        while (expectedValue.hasNext() || userListValues.hasNext()) {
            assertFalse(userListValues.next().equals(expectedValue.next()));
        }
    }

    @Test
    public void whenPassArrayListThanReturnSortLengthList() {

        //assign
        User firsUser = new User("VarrrryyLooonnnnggName", 30);
        User secondUser = new User("Aagor", 13);
        User thirdUser = new User("Zova", 26);

        List<User> userList = new ArrayList<>();
        List<User> userList2Save;

        ArrayList<User> expected = new ArrayList<>();

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

        expected.add(thirdUser);
        expected.add(secondUser);
        expected.add(firsUser);

        userList2Save = userSort.sortLength(userList);

        Iterator<User> userListValues = userList2Save.iterator();
        Iterator<User> expectedValue = expected.iterator();

        //assert

        while (expectedValue.hasNext() || userListValues.hasNext()) {
            assertThat(userListValues.next().getName().length(), is(expectedValue.next().getName().length()));
        }
    }

}
@@ -58,17 +58,97 @@
 va.util.
-*
+Iterator;%0Aimport java.util.List;%0Aimport java.util.Set;%0Aimport java.util.ArrayList
 ;%0A%0Aimpor
@@ -282,51 +282,8 @@
 lse;
-%0Aimport static org.junit.Assert.assertTrue;
 %0A%0A/*
@@ -443,24 +443,204 @@
 SortTest %7B%0A%0A
+    /**%0A     * whenPassArrayThanCheckList created to test %7B@link UserSort#sort(List)%7D method.%0A     * passing list, return sorted list by age and check with expected list.%0A     */%0A%0A
     @Test%0A  
@@ -1643,24 +1643,222 @@
      %7D%0A%0A
-%0A
     %7D%0A%0A
+    /**%0A     * whenPassArrayListThanReturnSortHashCodeList created to test %7B@link UserSort#sortHash(List)%7D.%0A     * passing list, return sorted list by hash code and check with expected list.%0A     */%0A
 %0A    @Te
@@ -2794,23 +2794,221 @@
       %7D%0A
-
     %7D%0A%0A
+    /**%0A     * whenPassArrayListThanReturnSortLengthList created to test %7B@link UserSort#sortLength(List)%7D%7D.%0A     * passing list, return sorted list by length and check with expected list.%0A     */%0A%0A
     @Tes

change imports and add javadoc