### Question:
Pawn extends Figure { public Cell[] way(Cell source, Cell dest) throws ImpossibleMoveException { int differenceX = Math.abs(dest.getX() - source.getX()); boolean sourceXEqualTwo = source.getX() == 2; boolean doneDependingPosition = (sourceXEqualTwo ? differenceX == 2 || differenceX == 1 : differenceX == 1); if (dest.getX() < 0 && dest.getX() > 9 && dest.getY() != source.getY() && !doneDependingPosition) { throw new ImpossibleMoveException("Пешка так не ходит"); } Cell[] result; if (sourceXEqualTwo && differenceX == 2) { result = new Cell[]{new Cell(source.getX() + 1, source.getY()), dest}; } else { result = new Cell[]{dest}; } return result; } Pawn(Cell position); Cell[] way(Cell source, Cell dest); Figure copy(Cell dest);  }### Answer:
@Test public void ifPawnGoingFromPointTwoTwoToPointFourTwo() throws ImpossibleMoveException { Pawn testPawn = new Pawn(new Cell(2, 2)); Cell[] result = testPawn.way(new Cell(2, 2), new Cell(4, 2)); assertThat(result, is(new Cell[]{new Cell(3, 2), new Cell(4, 2)})); }
@Test public void ifPawnGoingFromPointThreeTwoToPointFourTwo() throws ImpossibleMoveException { Pawn testPawn = new Pawn(new Cell(3, 2)); Cell[] result = testPawn.way(new Cell(3, 2), new Cell(4, 2)); assertThat(result, is(new Cell[]{new Cell(4, 2)})); }
@Test public void ifWrongWayThenReturnImeException() { Pawn testPawn = new Pawn(new Cell(4, 4)); try { testPawn.way(new Cell(4, 4), new Cell(6, 4)); } catch (ImpossibleMoveException ime) { assertThat("Пешка так не ходит", is(ime.getMessage())); } }