@Test public void getCDNoProduct() { final RepositoryHandler repoHandler = mock(RepositoryHandler.class); when(repoHandler.getOneByQuery(anyString(), anyString(), any(Class.class))).thenReturn(Optional.empty()); final DataFetchingUtils sut = new DataFetchingUtils(); final Optional<Delivery> result = sut.getCommercialDelivery(repoHandler, "a name", "a version"); assertFalse(result.isPresent()); }
public Optional<Delivery> getCommercialDelivery(final RepositoryHandler repoHandler, final String name, final String version) { final Optional<DbProduct> productOptional = repoHandler.getOneByQuery(DbCollections.DB_PRODUCT, makeQuery(name, version), DbProduct.class); if(!productOptional.isPresent()) { return Optional.empty(); } final DbProduct dbProduct = productOptional.get(); final List<Delivery> filtered = dbProduct.getDeliveries() .stream() .filter(d -> d.getCommercialName().equals(name) && d.getCommercialVersion().equals(version) ) .collect(Collectors.toList()); if(filtered.isEmpty()) { return Optional.empty(); } if (filtered.size() > 1 && LOG.isWarnEnabled()) { LOG.warn(String.format("Multiple commercial version entries found for [%s] [%s]", name, version)); } return Optional.of(filtered.get(0)); }
DataFetchingUtils { public Optional<Delivery> getCommercialDelivery(final RepositoryHandler repoHandler, final String name, final String version) { final Optional<DbProduct> productOptional = repoHandler.getOneByQuery(DbCollections.DB_PRODUCT, makeQuery(name, version), DbProduct.class); if(!productOptional.isPresent()) { return Optional.empty(); } final DbProduct dbProduct = productOptional.get(); final List<Delivery> filtered = dbProduct.getDeliveries() .stream() .filter(d -> d.getCommercialName().equals(name) && d.getCommercialVersion().equals(version) ) .collect(Collectors.toList()); if(filtered.isEmpty()) { return Optional.empty(); } if (filtered.size() > 1 && LOG.isWarnEnabled()) { LOG.warn(String.format("Multiple commercial version entries found for [%s] [%s]", name, version)); } return Optional.of(filtered.get(0)); } }
DataFetchingUtils { public Optional<Delivery> getCommercialDelivery(final RepositoryHandler repoHandler, final String name, final String version) { final Optional<DbProduct> productOptional = repoHandler.getOneByQuery(DbCollections.DB_PRODUCT, makeQuery(name, version), DbProduct.class); if(!productOptional.isPresent()) { return Optional.empty(); } final DbProduct dbProduct = productOptional.get(); final List<Delivery> filtered = dbProduct.getDeliveries() .stream() .filter(d -> d.getCommercialName().equals(name) && d.getCommercialVersion().equals(version) ) .collect(Collectors.toList()); if(filtered.isEmpty()) { return Optional.empty(); } if (filtered.size() > 1 && LOG.isWarnEnabled()) { LOG.warn(String.format("Multiple commercial version entries found for [%s] [%s]", name, version)); } return Optional.of(filtered.get(0)); }  }
DataFetchingUtils { public Optional<Delivery> getCommercialDelivery(final RepositoryHandler repoHandler, final String name, final String version) { final Optional<DbProduct> productOptional = repoHandler.getOneByQuery(DbCollections.DB_PRODUCT, makeQuery(name, version), DbProduct.class); if(!productOptional.isPresent()) { return Optional.empty(); } final DbProduct dbProduct = productOptional.get(); final List<Delivery> filtered = dbProduct.getDeliveries() .stream() .filter(d -> d.getCommercialName().equals(name) && d.getCommercialVersion().equals(version) ) .collect(Collectors.toList()); if(filtered.isEmpty()) { return Optional.empty(); } if (filtered.size() > 1 && LOG.isWarnEnabled()) { LOG.warn(String.format("Multiple commercial version entries found for [%s] [%s]", name, version)); } return Optional.of(filtered.get(0)); }  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 Optional<Delivery> getCommercialDelivery(final RepositoryHandler repoHandler, final String name, final String version) { final Optional<DbProduct> productOptional = repoHandler.getOneByQuery(DbCollections.DB_PRODUCT, makeQuery(name, version), DbProduct.class); if(!productOptional.isPresent()) { return Optional.empty(); } final DbProduct dbProduct = productOptional.get(); final List<Delivery> filtered = dbProduct.getDeliveries() .stream() .filter(d -> d.getCommercialName().equals(name) && d.getCommercialVersion().equals(version) ) .collect(Collectors.toList()); if(filtered.isEmpty()) { return Optional.empty(); } if (filtered.size() > 1 && LOG.isWarnEnabled()) { LOG.warn(String.format("Multiple commercial version entries found for [%s] [%s]", name, version)); } return Optional.of(filtered.get(0)); }  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);  }