private void createHostVersions(RepositoryVersionEntity targetRepoVersion,
      String hostName) throws AmbariException {
    Cluster c = clusters.getCluster(clusterName);

    // create a single host with the UPGRADED HostVersionEntity
    HostDAO hostDAO = m_injector.getInstance(HostDAO.class);

    HostVersionEntity entity = new HostVersionEntity(hostDAO.findByName(hostName),
        targetRepoVersion, RepositoryVersionState.INSTALLED);

    hostVersionDAO.create(entity);

    // verify the UPGRADED host versions were created successfully
    List<HostVersionEntity> hostVersions = hostVersionDAO.findHostVersionByClusterAndRepository(
        c.getClusterId(), targetRepoVersion);

    assertEquals(1, hostVersions.size());
    assertEquals(RepositoryVersionState.INSTALLED, hostVersions.get(0).getState());
  }
Tests upgrade-related server side actions
ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java