Matrix { @Override public String toString() { return "Matrix{" + "width=" + width + ", height=" + height + ", matrix=" + matrix + '}'; } Matrix(int height, int width, IntFunction<ArrayList<T>> rowBuilder);  Matrix(Matrix<T> other);  Matrix(int height, int width, ArrayList<ArrayList<T>> matrix); ArrayList<ArrayList<T>> getRows(); ArrayList<T> getRow(int i); void setRow(int i, ArrayList<T> row); int getWidth(); int getHeight(); List<T> getColumn(int i); @Override String toString();  }
@Test public void testToString() { IntFunction<ArrayList<Integer>> mockFunction = mock(IntFunction.class); when(mockFunction.apply(any(int.class))).thenReturn(new ArrayList<>()); Matrix matrix = new Matrix(1, 2, mockFunction); String stringOut = matrix.toString(); Assert.assertTrue(stringOut.contains("width=2,")); Assert.assertTrue(stringOut.contains("height=1,")); Assert.assertTrue(stringOut.contains("matrix=[[]]")); }