### Question:
MoveCorrectness extends AbstractGameRules { public boolean isMoveValid(GameAction gameAction) { return isCellUnoccupied(gameAction) && isPlayerCurrent(gameAction) && isActionBeforeGameExpired(gameAction) && isBordersWithPlayerCell(gameAction) && !isTypeOccupiedByOtherPlayers(gameAction); }  boolean isMoveValid(GameAction gameAction);  }### Answer:
@Test public void rejectIfNoNeighborOwnedCell() { gameAction.setX(0); gameAction.setY(0); boolean actual = gameRules.isMoveValid(gameAction); assertFalse(actual); }
@Test public void rejectIfAlreadyOccupied() { gameAction.setX(2); gameAction.setY(1); boolean actual = gameRules.isMoveValid(gameAction); assertFalse(actual); }
@Test public void rejectIfAlreadyOwnedByOtherPlayer() { int otherPlayerCellX = 3; int otherPlayerCellY = 1; setOtherPlayerCell(otherPlayerCellX, otherPlayerCellY); boolean actual = gameRules.isMoveValid(gameAction); assertFalse(actual); }
@Test public void rejectIfPlayerNotCurrent() { gameAction.setX(capturingNeighborCell.getKey()); gameAction.setY(capturingNeighborCell.getValue()); gameAction.getGame().setCurrentPlayer(getOtherPlayer()); boolean actual = gameRules.isMoveValid(gameAction); assertFalse(actual); }
@Test public void rejectIfOpponentAlreadyOccupiedSuchType() { int opponentCellX = 0, opponentCellY = 2; Cell opponentCell = gameAction.findCell(opponentCellX, opponentCellY); opponentCell.setOwner(getOtherPlayer().getId()); gameAction.setX(capturingNeighborCell.getKey()); gameAction.setY(capturingNeighborCell.getValue()); boolean actual = gameRules.isMoveValid(gameAction); assertFalse(actual); }
@Test public void approve() { gameAction.findCell(4, 2).setType(100); neighborCells.forEach(closeCell -> { gameAction.setX(closeCell.getKey()); gameAction.setY(closeCell.getValue()); boolean actual = gameRules.isMoveValid(gameAction); assertTrue(actual); }); }
@Test public void rejectIfObliquely() { List<Pair<Integer, Integer>> obliquelyCells = new ArrayList<>(); obliquelyCells.add(new Pair<>(OWNED_CELL_X - 1, OWNED_CELL_Y - 1)); obliquelyCells.add(new Pair<>(OWNED_CELL_X - 1, OWNED_CELL_Y + 1)); obliquelyCells.add(new Pair<>(OWNED_CELL_X + 1, OWNED_CELL_Y - 1)); obliquelyCells.add(new Pair<>(OWNED_CELL_X + 1, OWNED_CELL_Y + 1)); obliquelyCells.forEach(obliquelyCell -> { gameAction.setX(obliquelyCell.getKey()); gameAction.setY(obliquelyCell.getValue()); boolean actual = gameRules.isMoveValid(gameAction); assertFalse(actual); }); }