@Test public void testGetServiceRepos() { List<RepositoryInfo> vdfRepos = Lists.newArrayList(repoInfo("HDP", "HDP-2.3", "redhat6"), repoInfo("HDP-UTILS", "HDP-UTILS-1.1.0.20", "redhat6"), repoInfo("HDP", "HDP-2.3", "redhat5"), repoInfo("HDP-UTILS", "HDP-UTILS-1.1.0.20", "redhat5")); List<RepositoryInfo> stackRepos = Lists.newArrayList(vdfRepos); stackRepos.add(repoInfo("MSFT_R", "MSFT_R-8.1", "redhat6")); ImmutableListMultimap<String, RepositoryInfo> stackReposByOs = Multimaps.index(stackRepos, RepositoryInfo.GET_OSTYPE_FUNCTION); List<RepositoryInfo> serviceRepos = RepoUtil.getServiceRepos(vdfRepos, stackReposByOs); Assert.assertEquals("Expected 1 service repo", 1, serviceRepos.size()); Assert.assertEquals("Expected MSFT_R service repo", "MSFT_R", serviceRepos.get(0).getRepoName()); }
public static List<RepositoryInfo> getServiceRepos(List<RepositoryInfo> vdfRepos, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> serviceRepoIds = new HashSet<>(); List<RepositoryInfo> serviceRepos = new ArrayList<>(); ListMultimap<String, RepositoryInfo> vdfReposByOs = Multimaps.index(vdfRepos, RepositoryInfo.GET_OSTYPE_FUNCTION); for(String os: vdfReposByOs.keySet()) { Set<String> vdfRepoNames = Sets.newHashSet( Lists.transform(vdfReposByOs.get(os), RepositoryInfo.GET_REPO_NAME_FUNCTION)); for (RepositoryInfo repo: stackReposByOs.get(os)) { if (!vdfRepoNames.contains(repo.getRepoName())) { serviceRepos.add(repo); serviceRepoIds.add(repo.getRepoId()); } } } LOG.debug("Found {} service repos: {}", serviceRepoIds.size(),Iterables.toString(serviceRepoIds)); return serviceRepos; }
RepoUtil { public static List<RepositoryInfo> getServiceRepos(List<RepositoryInfo> vdfRepos, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> serviceRepoIds = new HashSet<>(); List<RepositoryInfo> serviceRepos = new ArrayList<>(); ListMultimap<String, RepositoryInfo> vdfReposByOs = Multimaps.index(vdfRepos, RepositoryInfo.GET_OSTYPE_FUNCTION); for(String os: vdfReposByOs.keySet()) { Set<String> vdfRepoNames = Sets.newHashSet( Lists.transform(vdfReposByOs.get(os), RepositoryInfo.GET_REPO_NAME_FUNCTION)); for (RepositoryInfo repo: stackReposByOs.get(os)) { if (!vdfRepoNames.contains(repo.getRepoName())) { serviceRepos.add(repo); serviceRepoIds.add(repo.getRepoId()); } } } LOG.debug("Found {} service repos: {}", serviceRepoIds.size(),Iterables.toString(serviceRepoIds)); return serviceRepos; } }
RepoUtil { public static List<RepositoryInfo> getServiceRepos(List<RepositoryInfo> vdfRepos, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> serviceRepoIds = new HashSet<>(); List<RepositoryInfo> serviceRepos = new ArrayList<>(); ListMultimap<String, RepositoryInfo> vdfReposByOs = Multimaps.index(vdfRepos, RepositoryInfo.GET_OSTYPE_FUNCTION); for(String os: vdfReposByOs.keySet()) { Set<String> vdfRepoNames = Sets.newHashSet( Lists.transform(vdfReposByOs.get(os), RepositoryInfo.GET_REPO_NAME_FUNCTION)); for (RepositoryInfo repo: stackReposByOs.get(os)) { if (!vdfRepoNames.contains(repo.getRepoName())) { serviceRepos.add(repo); serviceRepoIds.add(repo.getRepoId()); } } } LOG.debug("Found {} service repos: {}", serviceRepoIds.size(),Iterables.toString(serviceRepoIds)); return serviceRepos; }  }
RepoUtil { public static List<RepositoryInfo> getServiceRepos(List<RepositoryInfo> vdfRepos, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> serviceRepoIds = new HashSet<>(); List<RepositoryInfo> serviceRepos = new ArrayList<>(); ListMultimap<String, RepositoryInfo> vdfReposByOs = Multimaps.index(vdfRepos, RepositoryInfo.GET_OSTYPE_FUNCTION); for(String os: vdfReposByOs.keySet()) { Set<String> vdfRepoNames = Sets.newHashSet( Lists.transform(vdfReposByOs.get(os), RepositoryInfo.GET_REPO_NAME_FUNCTION)); for (RepositoryInfo repo: stackReposByOs.get(os)) { if (!vdfRepoNames.contains(repo.getRepoName())) { serviceRepos.add(repo); serviceRepoIds.add(repo.getRepoId()); } } } LOG.debug("Found {} service repos: {}", serviceRepoIds.size(),Iterables.toString(serviceRepoIds)); return serviceRepos; }  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 List<RepositoryInfo> getServiceRepos(List<RepositoryInfo> vdfRepos, ListMultimap<String, RepositoryInfo> stackReposByOs) { Set<String> serviceRepoIds = new HashSet<>(); List<RepositoryInfo> serviceRepos = new ArrayList<>(); ListMultimap<String, RepositoryInfo> vdfReposByOs = Multimaps.index(vdfRepos, RepositoryInfo.GET_OSTYPE_FUNCTION); for(String os: vdfReposByOs.keySet()) { Set<String> vdfRepoNames = Sets.newHashSet( Lists.transform(vdfReposByOs.get(os), RepositoryInfo.GET_REPO_NAME_FUNCTION)); for (RepositoryInfo repo: stackReposByOs.get(os)) { if (!vdfRepoNames.contains(repo.getRepoName())) { serviceRepos.add(repo); serviceRepoIds.add(repo.getRepoId()); } } } LOG.debug("Found {} service repos: {}", serviceRepoIds.size(),Iterables.toString(serviceRepoIds)); return serviceRepos; }  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);  }