### Question:
Bishop { public static int findShortestWay(String start, String end) { if (start == null || !BOARD_CELL_PATTERN.matcher(start).matches()) { throw new IllegalArgumentException("Start position should be 2-char string [a-h][1-8], not " + start); } if (end == null || !BOARD_CELL_PATTERN.matcher(end).matches()) { throw new IllegalArgumentException("End position should be 2-char string [a-h][1-8], not " + end); } int sh = start.charAt(0) - 'a'; int sg = start.charAt(1) - '1'; int eh = end.charAt(0) - 'a'; int eg = end.charAt(1) - '1'; NonDirectedGraph graph = new NonDirectedGraph(BOARD_SIZE * BOARD_SIZE); for (int i = 0; i < BOARD_SIZE; i++) { for (int j = 0; j < BOARD_SIZE; j++) { for (int k = 1; k < BOARD_SIZE; k++) { if (i + k < BOARD_SIZE && j + k < BOARD_SIZE) { graph.addEdge(BOARD_SIZE * i + j, BOARD_SIZE * (i + k) + (j + k)); } if (i + k < BOARD_SIZE && j - k >= 0) { graph.addEdge(BOARD_SIZE * i + j, BOARD_SIZE * (i + k) + (j - k)); } } } } return graph.bfs(sh * BOARD_SIZE + sg, eh * BOARD_SIZE + eg); }  static int findShortestWay(String start, String end);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testFindShortestWayStartIsNull() { findShortestWay(null, "h8"); }
@Test(expected = IllegalArgumentException.class) public void testFindShortestWayStartIsEmpty() { findShortestWay("", "h8"); }
@Test(expected = IllegalArgumentException.class) public void testFindShortestWayStartTooShort() { findShortestWay("a", "h8"); }
@Test(expected = IllegalArgumentException.class) public void testFindShortestWayStartTooLong() { findShortestWay("a11", "h8"); }
@Test(expected = IllegalArgumentException.class) public void testFindShortestWayEndIsNull() { findShortestWay("a1", null); }
@Test(expected = IllegalArgumentException.class) public void testFindShortestWayEndIsEmpty() { findShortestWay("a1", ""); }
@Test(expected = IllegalArgumentException.class) public void testFindShortestWayEndTooShort() { findShortestWay("a1", "h"); }
@Test(expected = IllegalArgumentException.class) public void testFindShortestWayEndTooLong() { findShortestWay("a11", "h88"); }
@Test public void testFindShortestWay() { assertThat("Shortest way from " + from + " to " + to + " is not expected", findShortestWay(from, to), is(expected)); }