package ru.matevosyan;

import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class UserConverterTest {

    @Test
    public void whenPassArrayThanCheckList() {

        //assign
        User admin = new User(1, "Tom", "LA");
        User firsUser = new User(2, "Vova", "Moscow");
        User secondUser = new User(3, "Vardan", "Dzhanfida");

        List<User> userList = new ArrayList<>();
        HashMap<Integer, User> actualUserMap;

        UserConverter convertList = new UserConverter();

        //act
        userList.add(admin);
        userList.add(firsUser);
        userList.add(secondUser);

        actualUserMap = convertList.process(userList);


        Iterator<Map.Entry<Integer, User>> hashMap = actualUserMap.entrySet().iterator();
        Iterator<User> userValues = userList.iterator();

        //assert
        while (hashMap.hasNext() && userValues.hasNext()) {

            Map.Entry<Integer, User> userEntry = hashMap.next();
            User userArrayList = userValues.next();

            assertThat(userEntry.getKey(), is(userArrayList.getId()));
            assertThat(userEntry.getValue().getName(), is(userArrayList.getName()));

        }

    }



}
@@ -266,40 +266,371 @@
 s;%0A%0A
-public class UserConverterTest %7B
+/**%0A * Created UserConverterTest to test UserConverter class.%0A * Created on 28.04.2017.%0A * @author Matevosyan Vardan%0A * @version 1.0%0A */%0A%0Apublic class UserConverterTest %7B%0A%0A    /**%0A     * whenPassArrayThanCheckList was created to test converting method which return map.%0A     * and check with passing list to the %7B@link UserConverter#process(List)%7D method.%0A     */
 %0A%0A  
@@ -1187,17 +1187,16 @@
 List);%0A%0A
-%0A
         

add javadoc