private RepositoryVersionEntity addRepoVersion(String INSTALLED_VERSION, StackId stackId) throws AmbariException {
    // Register and install new version
    RepositoryVersionEntity repositoryVersionEntity = helper.getOrCreateRepositoryVersion(stackId,
            INSTALLED_VERSION);
    helper.createHostVersion("h1", repositoryVersionEntity, RepositoryVersionState.INSTALLED);
    assertRepoVersionState(INSTALLED_VERSION, RepositoryVersionState.INSTALLED);

    // Add new host and verify that it has all host versions present
    List<HostVersionEntity> h2Versions = hostVersionDAO.findAll();

    // Check before adding service
    for (HostVersionEntity hostVersionEntity : h2Versions) {
      if (hostVersionEntity.getRepositoryVersion().getVersion().equals(INSTALLED_VERSION)) {
        assertEquals(hostVersionEntity.getState(), RepositoryVersionState.INSTALLED);
      }
    }

    return repositoryVersionEntity;
  }
Adds yet another repo version to existing cluster
Shared between several test cases.
@param INSTALLED_VERSION Version to add as INSTALLED
@param stackId Stack Id to use
@throws AmbariException
ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java