public void testValidateAssassinWithBombAndEliminations() {
    EntityManager em = createEntityManager();

    Assassin assassin = em.find(Assassin.class, assassinId);
    assertNotNull("The assassin could not be read back.", assassin);
    assassin.getEliminations();
    assertFalse("The assassin didn't have any eliminations", assassin.getEliminations().isEmpty());

    Weapon weapon = assassin.getWeapon();
    assertNotNull("The assassin's weapon was null", weapon);
    assertTrue("The assassin's weapon was not an indirect weapon", weapon.isIndirectWeapon());
    assertTrue("The assassin's weapon was not a bomb", ((IndirectWeapon) weapon).isBomb());

    closeEntityManager(em);
  }
  public void testAddIndirectElimination() {
    EntityManager em = createEntityManager();

    try {
      beginTransaction(em);

      Assassin assassin = em.find(Assassin.class, assassinId);

      Bomb bomb = new Bomb();
      bomb.setBombType(Bomb.BOMBTYPE.DIRTY);
      bomb.setDescription("Nasty blasty");
      em.persist(bomb);

      // Must set the correct weapon before an elimination.
      assassin.setWeapon(bomb);

      IndirectElimination indirectElimination = new IndirectElimination();
      indirectElimination.setId(new Long(System.currentTimeMillis()).intValue());
      indirectElimination.setName("Jill Smuck");
      indirectElimination.setDescription("Because she has a big mouth");
      indirectElimination.setAssassin(assassin);
      em.persist(indirectElimination);
      indirectEliminationPK = indirectElimination.getPK();

      assassin.getEliminations().add(indirectElimination);

      commitTransaction(em);
    } catch (Exception e) {
      fail("Error adding new indirect elimination: " + e.getMessage());
    } finally {
      closeEntityManager(em);
    }
  }
  public void testAddDirectElimination() {
    EntityManager em = createEntityManager();

    try {
      beginTransaction(em);
      Assassin assassin = em.find(Assassin.class, assassinId);

      // Assassin already has a gun, therefore, correct weapon already set
      // for a direct elimination.
      DirectElimination directElimination = new DirectElimination();
      directElimination.setId(new Long(System.currentTimeMillis()).intValue());
      directElimination.setName("Joe Smuck");
      directElimination.setDescription("Because he has a big mouth");
      directElimination.setAssassin(assassin);
      em.persist(directElimination);
      directEliminationPK = directElimination.getPK();

      assassin.getEliminations().add(directElimination);

      commitTransaction(em);
    } catch (Exception e) {
      fail("Error adding new direct elimination: " + e.getMessage());
    } finally {
      closeEntityManager(em);
    }
  }