@Test public void testAddServiceReposToOperatingSystemEntities_RepoAlreadExists() { List<OperatingSystemEntity> operatingSystems = new ArrayList<>(); for (String os: OPERATING_SYSTEMS) { RepositoryEntity repo1 = repoEntity("HDP", "HDP-2.3", "http: RepositoryEntity repo2 = repoEntity("HDP-UTILS", "HDP-UTILS-1.1.0", "http: RepositoryEntity repo3 = repoEntity("MSFT_R", "MSFT_R-8.1", "http: operatingSystems.add(osEntity(os, repo1, repo2, repo3)); } ListMultimap<String, RepositoryInfo> serviceRepos = serviceRepos(ImmutableList.of("redhat6"), "MSFT_R", "MSFT_R-8.2", "http: RepoUtil.addServiceReposToOperatingSystemEntities(operatingSystems, serviceRepos); for (OperatingSystemEntity os: operatingSystems) { Optional<RepositoryEntity> msft_r_orig = findRepoEntityById(os.getRepositories(), "MSFT_R-8.1"); Optional<RepositoryEntity> msft_r_new = findRepoEntityById(os.getRepositories(), "MSFT_R-8.2"); Assert.assertTrue("Original repo is missing", msft_r_orig.isPresent()); Assert.assertTrue("Service repo with duplicate name should not have been added", !msft_r_new.isPresent()); } }
public static void addServiceReposToOperatingSystemEntities(List<OperatingSystemEntity> operatingSystems, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> addedRepos = new HashSet<>(); for (OperatingSystemEntity os : operatingSystems) { List<RepositoryInfo> serviceReposForOs = stackReposByOs.get(os.getOsType()); ImmutableSet<String> repoNames = ImmutableSet.copyOf(Lists.transform(os.getRepositories(), REPO_ENTITY_TO_NAME)); for (RepositoryInfo repoInfo : serviceReposForOs) if (!repoNames.contains(repoInfo.getRepoName())) { os.getRepositories().add(toRepositoryEntity(repoInfo)); addedRepos.add(String.format("%s (%s)", repoInfo.getRepoId(), os.getOsType())); } } LOG.info("Added {} service repos: {}", addedRepos.size(),Iterables.toString(addedRepos)); }
RepoUtil { public static void addServiceReposToOperatingSystemEntities(List<OperatingSystemEntity> operatingSystems, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> addedRepos = new HashSet<>(); for (OperatingSystemEntity os : operatingSystems) { List<RepositoryInfo> serviceReposForOs = stackReposByOs.get(os.getOsType()); ImmutableSet<String> repoNames = ImmutableSet.copyOf(Lists.transform(os.getRepositories(), REPO_ENTITY_TO_NAME)); for (RepositoryInfo repoInfo : serviceReposForOs) if (!repoNames.contains(repoInfo.getRepoName())) { os.getRepositories().add(toRepositoryEntity(repoInfo)); addedRepos.add(String.format("%s (%s)", repoInfo.getRepoId(), os.getOsType())); } } LOG.info("Added {} service repos: {}", addedRepos.size(),Iterables.toString(addedRepos)); } }
RepoUtil { public static void addServiceReposToOperatingSystemEntities(List<OperatingSystemEntity> operatingSystems, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> addedRepos = new HashSet<>(); for (OperatingSystemEntity os : operatingSystems) { List<RepositoryInfo> serviceReposForOs = stackReposByOs.get(os.getOsType()); ImmutableSet<String> repoNames = ImmutableSet.copyOf(Lists.transform(os.getRepositories(), REPO_ENTITY_TO_NAME)); for (RepositoryInfo repoInfo : serviceReposForOs) if (!repoNames.contains(repoInfo.getRepoName())) { os.getRepositories().add(toRepositoryEntity(repoInfo)); addedRepos.add(String.format("%s (%s)", repoInfo.getRepoId(), os.getOsType())); } } LOG.info("Added {} service repos: {}", addedRepos.size(),Iterables.toString(addedRepos)); }  }
RepoUtil { public static void addServiceReposToOperatingSystemEntities(List<OperatingSystemEntity> operatingSystems, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> addedRepos = new HashSet<>(); for (OperatingSystemEntity os : operatingSystems) { List<RepositoryInfo> serviceReposForOs = stackReposByOs.get(os.getOsType()); ImmutableSet<String> repoNames = ImmutableSet.copyOf(Lists.transform(os.getRepositories(), REPO_ENTITY_TO_NAME)); for (RepositoryInfo repoInfo : serviceReposForOs) if (!repoNames.contains(repoInfo.getRepoName())) { os.getRepositories().add(toRepositoryEntity(repoInfo)); addedRepos.add(String.format("%s (%s)", repoInfo.getRepoId(), os.getOsType())); } } LOG.info("Added {} service repos: {}", addedRepos.size(),Iterables.toString(addedRepos)); }  static RepositoryFolderAndXml parseRepoFile(File directory,
                                                 Collection<String> subDirs,
                                                 ModuleFileUnmarshaller unmarshaller); static void addServiceReposToOperatingSystemEntities(List<OperatingSystemEntity> operatingSystems,
      ListMultimap<String, RepositoryInfo> stackReposByOs); static List<RepositoryInfo> getServiceRepos(List<RepositoryInfo> vdfRepos,
                                                   ListMultimap<String, RepositoryInfo> stackReposByOs); static List<RepositoryResponse> asResponses(List<RepositoryInfo> repositoryInfos,
                                                     @Nullable String versionDefinitionId,
                                                     @Nullable String stackName,
                                                     @Nullable String stackVersion); }
RepoUtil { public static void addServiceReposToOperatingSystemEntities(List<OperatingSystemEntity> operatingSystems, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> addedRepos = new HashSet<>(); for (OperatingSystemEntity os : operatingSystems) { List<RepositoryInfo> serviceReposForOs = stackReposByOs.get(os.getOsType()); ImmutableSet<String> repoNames = ImmutableSet.copyOf(Lists.transform(os.getRepositories(), REPO_ENTITY_TO_NAME)); for (RepositoryInfo repoInfo : serviceReposForOs) if (!repoNames.contains(repoInfo.getRepoName())) { os.getRepositories().add(toRepositoryEntity(repoInfo)); addedRepos.add(String.format("%s (%s)", repoInfo.getRepoId(), os.getOsType())); } } LOG.info("Added {} service repos: {}", addedRepos.size(),Iterables.toString(addedRepos)); }  static RepositoryFolderAndXml parseRepoFile(File directory,
                                                 Collection<String> subDirs,
                                                 ModuleFileUnmarshaller unmarshaller); static void addServiceReposToOperatingSystemEntities(List<OperatingSystemEntity> operatingSystems,
      ListMultimap<String, RepositoryInfo> stackReposByOs); static List<RepositoryInfo> getServiceRepos(List<RepositoryInfo> vdfRepos,
                                                   ListMultimap<String, RepositoryInfo> stackReposByOs); static List<RepositoryResponse> asResponses(List<RepositoryInfo> repositoryInfos,
                                                     @Nullable String versionDefinitionId,
                                                     @Nullable String stackName,
                                                     @Nullable String stackVersion);  }