Example #1
0
  @Test
  public void testInsert() throws Exception {
    Fight fight =
        new Fight(
            UUID.fromString("df40ccf7-6fd8-4c13-8eef-7742a87a55b0"),
            BasicScenario.Player1.PLAYER.getId(),
            BasicScenario.Player2.PLAYER.getId(),
            BasicScenario.Player2.Planet1.PLANET.getId(),
            new Ships(new Ship(ShipType.MOSQUITO, 5), new Ship(ShipType.MULE, 1)),
            new Ships(new Ship(ShipType.DAEDALUS, 1)),
            new Ships(new Ship(ShipType.MOSQUITO, 1)),
            new Ships(new Ship(ShipType.DAEDALUS, 1)),
            10,
            new Resources(10, 20, 0));
    sut.insert(fight);

    List<Map<String, Object>> fightRows = select("SELECT * FROM fight WHERE id = ?", fight.getId());
    List<Map<String, Object>> fightShipsRows =
        select("SELECT * FROM fight_ships WHERE fight_id = ?", fight.getId());

    assertThat(fightRows, hasSize(1));
    verifyFightRow(fightRows.get(0), fight);

    assertThat(fightShipsRows, hasSize(5));
    verifyFightShipsRows(fightShipsRows, fight);
  }