@Transactional
  void createCommands(Cluster cluster, Long upgradeRequestId, Long stageId) {
    HostEntity h1 = hostDAO.findByName("h1");

    RequestEntity requestEntity = requestDAO.findByPK(upgradeRequestId);

    // Create the stage and add it to the request
    StageEntity stageEntity = new StageEntity();
    stageEntity.setRequest(requestEntity);
    stageEntity.setClusterId(cluster.getClusterId());
    stageEntity.setRequestId(upgradeRequestId);
    stageEntity.setStageId(stageId);
    requestEntity.setStages(Collections.singletonList(stageEntity));
    stageDAO.create(stageEntity);
    requestDAO.merge(requestEntity);

    // Create the task and add it to the stage
    HostRoleCommandEntity hrc1 = new HostRoleCommandEntity();

    hrc1.setStage(stageEntity);
    hrc1.setStatus(HostRoleStatus.COMPLETED);
    hrc1.setRole(Role.ZOOKEEPER_SERVER);
    hrc1.setRoleCommand(RoleCommand.RESTART);
    hrc1.setHostEntity(h1);

    stageEntity.setHostRoleCommands(new ArrayList<>());
    stageEntity.getHostRoleCommands().add(hrc1);
    h1.getHostRoleCommandEntities().add(hrc1);

    hrcDAO.create(hrc1);
    hostDAO.merge(h1);
  }
Create a request, stage, and completed task.
@param cluster
@param upgradeRequestId
@param stageId
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java