public void testCreatePackageUpdateActionWithName() throws Exception {
    User usr = UserTestUtils.findNewUser("testUser", "testOrg" + this.getClass().getSimpleName());

    PackageAction testAction =
        (PackageAction) ActionFactoryTest.createAction(usr, ActionFactory.TYPE_PACKAGES_UPDATE);
    PackageActionDetailsTest.createTestDetailsWithName(usr, testAction);
    ActionFactory.save(testAction);
    flushAndEvict(testAction);
    /** Get action back out of db and make sure it committed correctly */
    Action same = ActionFactory.lookupById(testAction.getId());
    assertTrue(same instanceof PackageAction);
    PackageAction sameAction = (PackageAction) same;

    assertNotNull(sameAction.getDetails());
    assertEquals(sameAction.getDetails().size(), 2);
    assertNotNull(sameAction.getDetails().toArray()[0]);
    assertNotNull(sameAction.getDetails().toArray()[1]);
    assertEquals(sameAction.getName(), testAction.getName());
    assertEquals(sameAction.getId(), testAction.getId());
  }
  /**
   * Test fetching a PackageAction
   *
   * @throws Exception
   */
  public void testLookupPackageAction() throws Exception {

    Action newA =
        ActionFactoryTest.createAction(
            UserTestUtils.createUser(
                "testUser", UserTestUtils.createOrg("testOrg" + this.getClass().getSimpleName())),
            ActionFactory.TYPE_PACKAGES_VERIFY);
    assertNotNull(newA.getId());
    assertTrue(newA instanceof PackageAction);
    PackageAction p = (PackageAction) newA;
    assertNotNull(p.getDetails());
    assertEquals(p.getDetails().size(), 1);
    PackageActionDetails firstDetail = (PackageActionDetails) p.getDetails().toArray()[0];

    /** Make sure PackageEvr was set & committed correctly */
    Set details = p.getDetails();
    Iterator ditr = details.iterator();
    while (ditr.hasNext()) {
      PackageActionDetails detail = (PackageActionDetails) ditr.next();
      assertNotNull(detail.getEvr().getId());
    }

    User user = UserTestUtils.findNewUser("TEST USER", "TEST ORG");
    Server testserver = ServerFactoryTest.createTestServer(user);

    PackageActionResult result = new PackageActionResult();
    result.setServer(testserver);
    result.setDetails(firstDetail);
    result.setResultCode(new Long(42));
    result.setCreated(new Date());
    result.setModified(new Date());

    firstDetail.addResult(result);

    ActionFactory.save(p);

    PackageAction p2 = (PackageAction) ActionFactory.lookupById(p.getId());

    assertNotNull(p2.getDetails());
    assertEquals(p2.getDetails().size(), 1);
    assertNotNull(p2.getDetails().toArray()[0]);
    firstDetail = (PackageActionDetails) p2.getDetails().toArray()[0];
    assertNotNull(firstDetail.getResults());
    assertEquals(firstDetail.getResults().size(), 1);
  }