@Test
  public void testPersistCommandsWithStages() throws Exception {
    ActionDBAccessor db = injector.getInstance(ActionDBAccessorImpl.class);

    populateActionDBWithTwoCommands(db, hostname);

    List<Stage> stages = db.getAllStages(requestId);
    assertEquals(1, stages.size());
    Stage stage = stages.get(0);

    StageEntityPK pk = new StageEntityPK();
    pk.setRequestId(stage.getRequestId());
    pk.setStageId(stage.getStageId());

    StageDAO dao = injector.getInstance(StageDAO.class);
    StageEntity stageEntity = dao.findByPK(pk);
    assertNotNull(stageEntity);

    Collection<HostRoleCommandEntity> commandEntities = stageEntity.getHostRoleCommands();
    assertTrue(CollectionUtils.isNotEmpty(commandEntities));
  }
Tests whether {@link ActionDBAccessor#persistActions(Request)} associates tasks with their
stages.  Improvements to {@code Stage} processing exposed the fact that the association wasn't
being made, and JPA didn't know of the Stage-to-Tasks child relationship.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java