package ru.matevosyan;

import org.junit.Test;

import java.util.List;
import java.util.ArrayList;

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


public class ConvertListTest {

    @Test
    public void whenPassArrayThanCheckList() {

        //assign
       int[][] arrayToList = new int[][]{{1, 2 ,3}, {4, 5, 6}, {7, 8, 9}};
       List<Integer> expectedArrayList = new ArrayList<>();
       List<Integer> actualArrayList = new ArrayList<>();

       ConvertList convertList = new ConvertList();

        //act
        actualArrayList = convertList.toList(arrayToList);

        for (int i = 1; i < actualArrayList.size() + 1; i++) {
            expectedArrayList.add(i);
        }
        //assert

        for (int i = 0; i < actualArrayList.size(); i++) {
            assertThat(actualArrayList.toString(), is(expectedArrayList.toString()));
        }
    }

    @Test
    public void whenPassSquareListThanCheckArray() {

        //assign
        int[][] expectedArray = new int[][]{{1, 2 ,3}, {4, 5, 6}, {7, 0, 0}};
        int[][] actualArray;
        List<Integer> arrayList = new ArrayList<>();

        ConvertList convertList = new ConvertList();

        //act
        //array values is 1,2,3,4,5,6,7
        for (int i = 1; i < 8; i++) {
            arrayList.add(i);
        }

        actualArray = convertList.toArray(arrayList, 3);
        //assert

        for (int i = 0; i < expectedArray.length; i++) {
            for (int f = 0; f < expectedArray.length; f++) {
                assertThat(actualArray[i][f], is(expectedArray[i][f]));

            }
        }
    }

    @Test
    public void whenPassRectangleListThanCheckArray() {

        //assign
        int[][] expectedArray = new int[][]{{1, 2 ,3, 4}, {5, 6, 7, 0}};
        int[][] actualArray;
        List<Integer> arrayList = new ArrayList<>();

        ConvertList convertList = new ConvertList();

        //act
        //array values is 1,2,3,4,5,6,7
        for (int i = 1; i < 8; i++) {
            arrayList.add(i);
        }

        actualArray = convertList.toArray(arrayList, 2);
        //assert

        for (int i = 0; i < expectedArray.length - 2; i++) {
            for (int f = 0; f < expectedArray.length; f++) {
                assertThat(actualArray[i][f], is(expectedArray[i][f]));
            }
        }
    }

    @Test
    public void whenPassArraysInListThanCheckArrayList() {

        //assign
        int[] firstArray = new int[]{1, 2};
        int[] secondArray = new int[]{3, 4, 5};
        List<Integer> expectedArrayList = new ArrayList<>();
        List<Integer> actualIntList = new ArrayList<>();
        List<int[]> actualArray = new ArrayList<>();
        ConvertList convertList = new ConvertList();

        //act
        for (int i = 1; i < 6; i++) {
            expectedArrayList.add(i);
        }
        actualArray.add(firstArray);
        actualArray.add(secondArray);

        actualIntList = convertList.convert(actualArray);

        //assert
        assertThat(actualIntList, is(expectedArrayList));
    }

}
@@ -191,39 +191,288 @@
 s;%0A%0A
-%0Apublic class ConvertListTest %7B
+/**%0A * ConvertListTest was created to test ConvertList class.%0A * Created on 28.04.2017.%0A * @author Matevosyan Vardan%0A * @version 1.0%0A */%0A%0Apublic class ConvertListTest %7B%0A%0A    /**%0A     * whenPassArrayThanCheckList was created for testing %7B@link ConvertList#toList(int%5B%5D%5B%5D)%7D.%0A     */
 %0A%0A  
@@ -1148,32 +1148,193 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * whenPassSquareListThanCheckArray was created for testing %7B@link ConvertList#toArray(List, int)%7D.%0A     * with passing odd number of rows.%0A     */%0A%0A
     @Test%0A    pu
@@ -2035,32 +2035,197 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * whenPassRectangleListThanCheckArray was created for testing %7B@link ConvertList#toArray(List, int)%7D.%0A     * with passing even number of rows.%0A     */%0A%0A
     @Test%0A    pu
@@ -2931,24 +2931,228 @@
    %7D%0A    %7D%0A%0A
+    /**%0A     * whenPassArraysInListThanCheckArrayList was created to test %7B@link ConvertList#convert(List)%7D.%0A     * that convert list of an arrays of different dimensions to one list of Integer.%0A     */%0A%0A
     @Test%0A  

add javadoc