private void createStage(long startStageId, int count, HostEntity hostEntity,
      RequestEntity requestEntity, HostRoleStatus status, boolean skipStage,
      boolean supportsAutoSkipOnFailure, boolean autoSkipFailedCommandsInStage) {
    long stageId = startStageId;

    ClusterEntity clusterEntity = m_clusterDAO.findByName("test_cluster1");

    StageEntity stageEntity = new StageEntity();
    stageEntity.setClusterId(clusterEntity.getClusterId());
    stageEntity.setRequest(requestEntity);
    stageEntity.setStageId(stageId);
    stageEntity.setHostRoleCommands(new ArrayList<>());
    stageEntity.setSkippable(skipStage);
    stageEntity.setAutoSkipFailureSupported(supportsAutoSkipOnFailure);

    m_stageDAO.create(stageEntity);
    requestEntity.getStages().add(stageEntity);

    for (int i = 0; i < count; i++) {
      HostRoleCommandEntity commandEntity = new HostRoleCommandEntity();
      commandEntity.setRequestId(requestEntity.getRequestId());
      commandEntity.setStageId(stageId);
      commandEntity.setRoleCommand(RoleCommand.INSTALL);
      commandEntity.setStatus(status);
      commandEntity.setRole(Role.DATANODE);
      commandEntity.setHostEntity(hostEntity);
      commandEntity.setStage(stageEntity);
      commandEntity.setAutoSkipOnFailure(
          autoSkipFailedCommandsInStage && skipStage && supportsAutoSkipOnFailure);

      m_hostRoleCommandDAO.create(commandEntity);

      hostEntity.getHostRoleCommandEntities().add(commandEntity);
      hostEntity = m_hostDAO.merge(hostEntity);

      stageEntity.getHostRoleCommands().add(commandEntity);
      m_stageDAO.merge(stageEntity);
    }
  }
Creates a single stage with the specified number of commands.

@param startStageId
@param count
@param hostEntity
@param requestEntity
@param status
@param skipStage
@param supportsAutoSkipOnFailure
@return
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAOTest.java