Package es.mahulo.battleship.api.service

Examples of es.mahulo.battleship.api.service.Config


    ships.add(buildShip(shipConfig5,cellShip6));
    ships.add(buildShip(shipConfig5,cellShip7));
  }
 
  @Test(expected=ShipExecption.class) public void isConfigOkNoCellsTest() throws ShipExecption {
    Config configService = new ConfigImpl();

    List<Cell> cells = new ArrayList<Cell>();
    
    Ship ship = new Ship();
    ship.setShipConfig(shipConfigs.get(0));
    ship.setCells(cells);
   
    Player player = new Player();
    player.setShips(new ArrayList<Ship>());
   
    configService.isValid(game, player,ship);
  }
View Full Code Here


   
    configService.isValid(game, player,ship);
  }
 
  @Test(expected=ShipExecption.class) public void isConfigOkShipSizeTest() throws ShipExecption {
    Config configService = new ConfigImpl();
   

    List<Cell> cells = new ArrayList<Cell>();
    Cell cell1 = new Cell();
    cell1.setX(9);
    cell1.setY(1);
    cells.add(cell1);
   

    Ship ship = new Ship();
    ship.setId(1L);
    ship.setShipConfig(shipConfigs.get(0));
    ship.setCells(cells);
   
    Player player = new Player();
    player.setShips(new ArrayList<Ship>());
   
    configService.isValid(game, player,ship);
  }
View Full Code Here

   
    configService.isValid(game, player,ship);
  }
 
  @Test(expected=ShipExecption.class) public void isConfigOkNumberOfShipTest() throws ShipExecption {
    Config configService = new ConfigImpl();
   
    List<Ship> playerShips = new ArrayList<Ship>();
    playerShips.add(buildShip(shipConfigs.get(0), cellShip1));
   
    List<Player>  players = new ArrayList<Player>();
    Player player = new Player();
    player.setShips(playerShips);
    players.add(player);

   
    Game game = new Game();
    game.setStatus(GameStatus.Configuring);
    game.setGameConfig(gameConfig);
    game.setPlayers(players);
   
    Ship ship = buildShip(shipConfigs.get(0), cellShip1);
    
   
    configService.isValid(game, player,ship);
  }
View Full Code Here

   
    configService.isValid(game, player,ship);
  }
 
  @Test(expected=ShipExecption.class) public void isConfigOkOutSideBoardTest() throws ShipExecption {
    Config configService = new ConfigImpl();
   
    List<Cell> cells = new ArrayList<Cell>();
    Cell cell = new Cell();
    cell.setX(11);
    cell.setY(1);
    cells.add(cell);

    List<Ship> ships = new ArrayList<Ship>();
    Ship ship = new Ship();
    ship.setShipConfig(shipConfigs.get(0));
    ship.setCells(cells);
    ships.add(ship);
   
    Player player = new Player();
    player.setShips(new ArrayList<Ship>());
   
    configService.isValid(game, player,ship);
  }
View Full Code Here

   
    configService.isValid(game, player,ship);
  }
 
  @Test(expected=ShipExecption.class) public void isConfigOkCellIsUsedTest() throws ShipExecption {
    Config configService = new ConfigImpl();
   
    List<Cell> cells = new ArrayList<Cell>();
    Cell cell1 = new Cell();
    cell1.setX(9);
    cell1.setY(1);
    cells.add(cell1);
   
    Ship playerShip = new Ship();
    playerShip.setShipConfig(shipConfigs.get(4));
    playerShip.setCells(cells);
   
    List<Ship> ships = new ArrayList<Ship>();
    ships.add(playerShip);
   
    Player player = new Player();
    player.setId(1L);
    player.setShips(ships);
   
   
    cells = new ArrayList<Cell>();
    Cell cell2 = new Cell();
    cell1.setX(10);
    cell1.setY(2);
    cells.add(cell2);
   
    Ship ship = new Ship();
   
    configService.isValid(game, player,ship);
  }
View Full Code Here

  }


 
  @Test public void isConfigValidTest() throws ShipExecption {
    Config configService = new ConfigImpl();
   
    List<Ship> playerShips = new ArrayList<Ship>();
    playerShips.add(buildShip(shipConfigs.get(0),cellShip1));
    playerShips.add(buildShip(shipConfigs.get(1),cellShip2));
    playerShips.add(buildShip(shipConfigs.get(2),cellShip3));
    playerShips.add(buildShip(shipConfigs.get(3),cellShip4));
    playerShips.add(buildShip(shipConfigs.get(3),cellShip5));
    playerShips.add(buildShip(shipConfigs.get(4),cellShip6));


   
    Player player = new Player();
    player.setId(1L);
    player.setShips(playerShips);
   
    Ship ship = buildShip(shipConfigs.get(4),cellShip7);
   
    configService.isValid(game, player,ship);
  }
View Full Code Here

   
    configService.isValid(game, player,ship);
  }
 
  @Test public void isConfigComplete() throws ShipExecption {
    Config configService = new ConfigImpl();
   
   
    List<Ship> playerShips = new ArrayList<Ship>();
    playerShips.add(buildShip(shipConfigs.get(0),cellShip1));
    playerShips.add(buildShip(shipConfigs.get(1),cellShip2));
    playerShips.add(buildShip(shipConfigs.get(2),cellShip3));
    playerShips.add(buildShip(shipConfigs.get(3),cellShip4));
    playerShips.add(buildShip(shipConfigs.get(3),cellShip5));
    playerShips.add(buildShip(shipConfigs.get(4),cellShip6));
    playerShips.add(buildShip(shipConfigs.get(4),cellShip7));


   
    Player player = new Player();
    player.setId(1L);
    player.setShips(ships);
   
   
   
    boolean isConfigComple = configService.isComplete(gameConfig,player);
   
    Assert.assertTrue(isConfigComple);

   
  }
View Full Code Here

   
  }

  @Test public void isConfigNotComplete() throws ShipExecption {
    Config configService = new ConfigImpl();
   
   
    List<Ship> playerShips = new ArrayList<Ship>();
    playerShips.add(buildShip(shipConfigs.get(0),cellShip1));
    playerShips.add(buildShip(shipConfigs.get(1),cellShip2));
    playerShips.add(buildShip(shipConfigs.get(2),cellShip3));
    playerShips.add(buildShip(shipConfigs.get(3),cellShip4));
    playerShips.add(buildShip(shipConfigs.get(3),cellShip5));
    playerShips.add(buildShip(shipConfigs.get(4),cellShip6));
   


   
    Player player = new Player();
    player.setId(1L);
    player.setShips(playerShips);
   
   
   
    boolean isConfigComple = configService.isComplete(gameConfig,player);
   
    Assert.assertFalse(isConfigComple);

   
  }
View Full Code Here

TOP

Related Classes of es.mahulo.battleship.api.service.Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.