Esempio n. 1
0
  @Test
  public void testUpdate() {

    String id = UUID.randomUUID().toString();
    PlayerDAO dao = new PlayerDAO();

    Player p = new Player();
    p.setId(id);
    p.setFirstName("Test");
    p.setLastName("Player");
    p.setNflTeam("Testers");
    p.setPosition("QB");
    p.setJerseyNumber(33);
    p.setHeight(80);
    p.setWeight(215);
    p.setBirthdate(new Date());
    p.setCollege("Penn State");

    assertTrue(dao.store(p));

    Player p2 = dao.getById(id);
    assertEquals(215, p2.getWeight());
    assertEquals(id, p2.getId());

    p2.setWeight(200);
    dao.store(p2);

    Player p3 = dao.getById(id);
    assertEquals(200, p3.getWeight());
    assertEquals(id, p3.getId());

    assertTrue(dao.remove(p3));
  }
Esempio n. 2
0
  private List<Player> getPlayers(Document doc) {

    List<Player> players = new ArrayList<Player>();

    Element docEle = doc.getDocumentElement();
    String team = docEle.getAttribute("name");

    NodeList nl = docEle.getElementsByTagName("player");
    if (nl != null && nl.getLength() > 0) {
      for (int i = 0; i < nl.getLength(); i++) {

        Element el = (Element) nl.item(i);
        Player p = getPlayer(el);
        p.setNflTeam(team);
        players.add(p);
      }
    }

    return players;
  }