@Test public void getDDMultipleModulesAvoidDuplicates() { final Delivery delivery = DataModelFactory.createDelivery( SAMPLE_NAME, SAMPLE_VERSION, "Today", Arrays.asList("one", "two")); final DbModule m1 = makeModule("one"); final DbModule m2 = makeModule("two"); final RepositoryHandler repoHandler = makeRepoHandler(m1, m2); final DependencyHandler depHandler = mock(DependencyHandler.class); withDeps(depHandler, "one", "one_a", "common_dep"); withDeps(depHandler, "two", "two_a", "two_b", "common_dep"); final DataFetchingUtils sut = new DataFetchingUtils(); final Set<String> results = sut.getDeliveryDependencies(repoHandler, depHandler, delivery); assertEquals(2 + 3 - 1, results.size()); assertTrue(results.contains(makeGAVC("one_a"))); assertTrue(results.contains(makeGAVC("two_a"))); assertTrue(results.contains(makeGAVC("two_b"))); assertTrue(results.contains(makeGAVC("common_dep"))); }
public Set<String> getDeliveryDependencies(final RepositoryHandler repoHandler, final DependencyHandler depHandler, final Delivery delivery) { final FiltersHolder filters = new FiltersHolder(); filters.getDecorator().setShowCorporate(Boolean.FALSE); filters.getDecorator().setShowThirdparty(Boolean.TRUE); Set<String> deps = new HashSet<>(); delivery.getDependencies().forEach(d -> { final DbModule module = repoHandler.getModule(d); if (module != null) { final List<Dependency> allDependencies = depHandler.getModuleDependencies(module.getId(), filters); allDependencies.forEach(dep -> deps.add(dep.getTarget().getGavc())); } else { if(isFullGAVC(d)) { deps.add(strip(d, 2)); } else { deps.add(d); } } }); return deps; }
DataFetchingUtils { public Set<String> getDeliveryDependencies(final RepositoryHandler repoHandler, final DependencyHandler depHandler, final Delivery delivery) { final FiltersHolder filters = new FiltersHolder(); filters.getDecorator().setShowCorporate(Boolean.FALSE); filters.getDecorator().setShowThirdparty(Boolean.TRUE); Set<String> deps = new HashSet<>(); delivery.getDependencies().forEach(d -> { final DbModule module = repoHandler.getModule(d); if (module != null) { final List<Dependency> allDependencies = depHandler.getModuleDependencies(module.getId(), filters); allDependencies.forEach(dep -> deps.add(dep.getTarget().getGavc())); } else { if(isFullGAVC(d)) { deps.add(strip(d, 2)); } else { deps.add(d); } } }); return deps; } }
DataFetchingUtils { public Set<String> getDeliveryDependencies(final RepositoryHandler repoHandler, final DependencyHandler depHandler, final Delivery delivery) { final FiltersHolder filters = new FiltersHolder(); filters.getDecorator().setShowCorporate(Boolean.FALSE); filters.getDecorator().setShowThirdparty(Boolean.TRUE); Set<String> deps = new HashSet<>(); delivery.getDependencies().forEach(d -> { final DbModule module = repoHandler.getModule(d); if (module != null) { final List<Dependency> allDependencies = depHandler.getModuleDependencies(module.getId(), filters); allDependencies.forEach(dep -> deps.add(dep.getTarget().getGavc())); } else { if(isFullGAVC(d)) { deps.add(strip(d, 2)); } else { deps.add(d); } } }); return deps; }  }
DataFetchingUtils { public Set<String> getDeliveryDependencies(final RepositoryHandler repoHandler, final DependencyHandler depHandler, final Delivery delivery) { final FiltersHolder filters = new FiltersHolder(); filters.getDecorator().setShowCorporate(Boolean.FALSE); filters.getDecorator().setShowThirdparty(Boolean.TRUE); Set<String> deps = new HashSet<>(); delivery.getDependencies().forEach(d -> { final DbModule module = repoHandler.getModule(d); if (module != null) { final List<Dependency> allDependencies = depHandler.getModuleDependencies(module.getId(), filters); allDependencies.forEach(dep -> deps.add(dep.getTarget().getGavc())); } else { if(isFullGAVC(d)) { deps.add(strip(d, 2)); } else { deps.add(d); } } }); return deps; }  List<DbProduct> getProductWithCommercialDeliveries(final RepositoryHandler repoHandler); Optional<Delivery> getCommercialDelivery(final RepositoryHandler repoHandler,
                                                    final String name,
                                                    final String version); Set<String> getDeliveryDependencies(final RepositoryHandler repoHandler,
                                               final DependencyHandler depHandler,
                                               final Delivery delivery); void initCorporateIDs(final RepositoryHandler repoHandler,
                                 final String orgName); boolean isThirdParty(final DbArtifact artifact); }
DataFetchingUtils { public Set<String> getDeliveryDependencies(final RepositoryHandler repoHandler, final DependencyHandler depHandler, final Delivery delivery) { final FiltersHolder filters = new FiltersHolder(); filters.getDecorator().setShowCorporate(Boolean.FALSE); filters.getDecorator().setShowThirdparty(Boolean.TRUE); Set<String> deps = new HashSet<>(); delivery.getDependencies().forEach(d -> { final DbModule module = repoHandler.getModule(d); if (module != null) { final List<Dependency> allDependencies = depHandler.getModuleDependencies(module.getId(), filters); allDependencies.forEach(dep -> deps.add(dep.getTarget().getGavc())); } else { if(isFullGAVC(d)) { deps.add(strip(d, 2)); } else { deps.add(d); } } }); return deps; }  List<DbProduct> getProductWithCommercialDeliveries(final RepositoryHandler repoHandler); Optional<Delivery> getCommercialDelivery(final RepositoryHandler repoHandler,
                                                    final String name,
                                                    final String version); Set<String> getDeliveryDependencies(final RepositoryHandler repoHandler,
                                               final DependencyHandler depHandler,
                                               final Delivery delivery); void initCorporateIDs(final RepositoryHandler repoHandler,
                                 final String orgName); boolean isThirdParty(final DbArtifact artifact);  }