I have the following test:
@Test public void whenRoadGoodThenReturnCellArrWithRoad() for (int i = 0; i != 8 ; i++) { Board.desc[i][i] = new Place(new Cell(i,i),""); } Board.desc[4][4] = new Officer(new Cell(4,4),"white"); Cell[] result = Board.desc[4][4].move(new Cell(7,7)); Cell[] check = new Cell[2]; check[0] = new Cell(5,5); check[1] = new Cell(6,6); assertThat(check[0].getX(), is(result[0].getX())); assertThat(check[0].getY(), is(result[0].getY())); assertThat(check[1].getX(), is(result[1].getX())); assertThat(check[1].getY(), is(result[1].getY())); assertThat(check.length, is(result.length)); } That is: there are two result and check arrays, both of which are filled with objects of the Cell type, and these objects store two fields (coordinates), х and у . I need to compare these two arrays by the value of the coordinates stored in each Cell .
What I wrote in principle works, but I want to do it in a shorter, if possible in one line.