### Question:
King extends Figure { public Cell[] way(Cell source, Cell dest) throws ImpossibleMoveException { if (dest.getX() < 0 && dest.getY() < 0 && dest.getX() > 9 && dest.getY() > 9 && (Math.abs(dest.getX() - source.getX()) != 1 || Math.abs(dest.getY() - source.getY()) != 1)) { throw new ImpossibleMoveException("Король так не ходит"); } return new Cell[]{dest}; } King(Cell position); Cell[] way(Cell source, Cell dest); Figure copy(Cell dest);  }### Answer:
@Test public void ifKingGoingFromPointFourFourToPointThreeThree() throws ImpossibleMoveException { King testKing = new King(new Cell(4, 4)); Cell[] result = testKing.way(new Cell(4, 4), new Cell(3, 3)); Cell[] expect = {new Cell(3, 3)}; assertThat(result, is(expect)); }
@Test public void ifKingGoingFromPointFourFourToPointFiveFive() throws ImpossibleMoveException { Bishop bishop = new Bishop(new Cell(4, 4)); Cell[] result = bishop.way(new Cell(4, 4), new Cell(5, 5)); Cell[] expect = {new Cell(5, 5)}; assertThat(result, is(expect)); }
@Test public void ifKingGoingFromPointFourFourToPointFiveThree() throws ImpossibleMoveException { Bishop bishop = new Bishop(new Cell(4, 4)); Cell[] result = bishop.way(new Cell(4, 4), new Cell(5, 3)); Cell[] expect = {new Cell(5, 3)}; assertThat(result, is(expect)); }
@Test public void ifKingGoingFromPointFourFourToPointThreeFive() throws ImpossibleMoveException { Bishop bishop = new Bishop(new Cell(4, 4)); Cell[] result = bishop.way(new Cell(4, 4), new Cell(3, 5)); Cell[] expect = {new Cell(3, 5)}; assertThat(result, is(expect)); }
@Test public void ifWrongWayThenReturnImeException() { Bishop bishop = new Bishop(new Cell(4, 4)); try { bishop.way(new Cell(4, 4), new Cell(5, 7)); } catch (ImpossibleMoveException ime) { assertThat("Король так не ходит", is(ime.getMessage())); } }