示例#1
0
  @Test
  public void testFindTroopByName() {
    Troop troopE = new Troop();
    troopE.setName("E");
    troopE.setMoney(BigDecimal.ZERO);
    troopE.setMission("mise E");
    troopDao.createTroop(troopE);
    Troop t1 = troopDao.findTroopById(troopE.getId());

    Assert.assertEquals(t1.getName(), "E");
    Assert.assertEquals(t1.getMission(), "mise E");
  }
示例#2
0
  @Test
  public void testCreateTroop() {
    EntityManager entityManager = emf.createEntityManager();
    entityManager.getTransaction().begin();
    Troop troopC = new Troop();
    troopC.setName("Testers");
    troopC.setMoney(new BigDecimal("30"));
    troopC.setMission("mise C");
    entityManager.getTransaction().commit();
    entityManager.close();

    troopDao.createTroop(troopC);

    Troop t1 = troopDao.findTroopById(troopC.getId());
    Assert.assertEquals(t1.getName(), "Testers");
    Assert.assertEquals(t1.getMoney().compareTo(new BigDecimal("30")), 0);
    Assert.assertEquals(t1.getMission(), "mise C");
  }
示例#3
0
  @BeforeClass
  public void setup() {

    troopA = new Troop();
    troopA.setName("Angels");
    troopA.setMoney(BigDecimal.ZERO);
    troopA.setMission("mise A");

    troopB = new Troop();
    troopB.setName("Bulls");
    troopB.setMission("mise B");
    troopB.setMoney(new BigDecimal("5"));
  }