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

}
@@ -2360,9 +2360,730 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void whenPassArraysInListThanCheckArrayList() %7B%0A%0A        //assign%0A        int%5B%5D firstArray = new int%5B%5D%7B1, 2%7D;%0A        int%5B%5D secondArray = new int%5B%5D%7B3, 4, 5%7D;%0A        List%3CInteger%3E expectedArrayList = new ArrayList%3C%3E();%0A        List%3CInteger%3E actualIntList = new ArrayList%3C%3E();%0A        List%3Cint%5B%5D%3E actualArray = new ArrayList%3C%3E();%0A        ConvertList convertList = new ConvertList();%0A%0A        //act%0A        for (int i = 1; i %3C 6; i++) %7B%0A            expectedArrayList.add(i);%0A        %7D%0A        actualArray.add(firstArray);%0A        actualArray.add(secondArray);%0A%0A        actualIntList = convertList.convert(actualArray);%0A%0A        //assert%0A        assertThat(actualIntList, is(expectedArrayList));%0A    %7D%0A%0A
 %7D

add test method whenPassArraysInListThanCheckArrayList