示例#1
0
  @Test
  public void testLoadByType() {

    String type = "QB";
    String[] types = {"RB", "WR", "TE"};

    PlayerDAO dao = new PlayerDAO();

    // test single type
    List<Player> players = dao.getByType(type);
    Iterator<Player> i = players.iterator();
    while (i.hasNext()) {
      Player p = i.next();
      assertEquals(type, p.getPosition());
    }

    // test multi-type
    players = dao.getByType(types);
    i = players.iterator();
    while (i.hasNext()) {
      Player p = i.next();
      String pos = p.getPosition();
      assertTrue(pos.equals(types[0]) || pos.equals(types[1]) || pos.equals(types[2]));
    }
  }
示例#2
0
  @Test
  public void testLoadById() {

    String id = "ac568889-d10d-4ccc-89a1-8e4233848086";
    PlayerDAO dao = new PlayerDAO();
    Player p = dao.getById(id);
    assertEquals(id, p.getId());
  }
示例#3
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));
  }