### Question:
UpdateActiveRepoVersionOnStartup { @Transactional public void process() throws AmbariException { LOG.info("Updating existing repo versions with service repos."); try { List<ClusterEntity> clusters = clusterDao.findAll(); for (ClusterEntity cluster: clusters) { for (ClusterServiceEntity service : cluster.getClusterServiceEntities()) { RepositoryVersionEntity repositoryVersion = service.getServiceDesiredStateEntity().getDesiredRepositoryVersion(); StackId stackId = repositoryVersion.getStackId(); StackInfo stack = stackManager.getStack(stackId.getStackName(), stackId.getStackVersion()); if (stack !=null) { if (updateRepoVersion(stack, repositoryVersion)) { repositoryVersionDao.merge(repositoryVersion); } } else { throw new AmbariException(String.format("Stack %s %s was not found on the file system. In the event that it was removed, " + "please ensure that it exists before starting Ambari Server.", stackId.getStackName(), stackId.getStackVersion())); } } } } catch(Exception ex) { throw new AmbariException( "An error occured during updating current repository versions with stack repositories.", ex); } } @Inject  UpdateActiveRepoVersionOnStartup(ClusterDAO clusterDao,
      RepositoryVersionDAO repositoryVersionDao,
      RepositoryVersionHelper repositoryVersionHelper,
      AmbariMetaInfo metaInfo); @Transactional void process();  }### Answer:
@Test public void addAServiceRepoToExistingRepoVersion() throws Exception { init(true); activeRepoUpdater.process(); verifyRepoIsAdded(); }
@Test public void missingClusterVersionShouldNotCauseException() throws Exception { init(false); activeRepoUpdater.process(); }