@Test public void testFindDomains() throws Exception { service.addDomainUrl("d1", "url1", 1); service.addDomainUrl("d2", "url2", 2); List<DomainURL> domains = service.findDomains(new PageRequest(0, 100)); assertEquals(2, domains.size()); List<String> urlsFound = new ArrayList<>(); for (DomainURL domain : domains) { urlsFound.add(domain.getAddress()); } assertTrue(urlsFound.containsAll(Arrays.asList("url1", "url2"))); }
@Override public List<DomainURL> findDomains(Pageable pageable) { Iterable<MongoDomainURL> domains = domainRepo.find().skip(pageable.getOffset()).limit(pageable.getPageSize()).as(MongoDomainURL.class); List<DomainURL> result = new ArrayList<>(); for (MongoDomainURL mongoDomainURL : domains) { result.add(new DomainURL(mongoDomainURL.getName(), mongoDomainURL.getAddress(), mongoDomainURL.getCoolDownPeriod())); } return result; }
MongoUrlServiceImpl implements UrlService { @Override public List<DomainURL> findDomains(Pageable pageable) { Iterable<MongoDomainURL> domains = domainRepo.find().skip(pageable.getOffset()).limit(pageable.getPageSize()).as(MongoDomainURL.class); List<DomainURL> result = new ArrayList<>(); for (MongoDomainURL mongoDomainURL : domains) { result.add(new DomainURL(mongoDomainURL.getName(), mongoDomainURL.getAddress(), mongoDomainURL.getCoolDownPeriod())); } return result; } }
MongoUrlServiceImpl implements UrlService { @Override public List<DomainURL> findDomains(Pageable pageable) { Iterable<MongoDomainURL> domains = domainRepo.find().skip(pageable.getOffset()).limit(pageable.getPageSize()).as(MongoDomainURL.class); List<DomainURL> result = new ArrayList<>(); for (MongoDomainURL mongoDomainURL : domains) { result.add(new DomainURL(mongoDomainURL.getName(), mongoDomainURL.getAddress(), mongoDomainURL.getCoolDownPeriod())); } return result; }  }
MongoUrlServiceImpl implements UrlService { @Override public List<DomainURL> findDomains(Pageable pageable) { Iterable<MongoDomainURL> domains = domainRepo.find().skip(pageable.getOffset()).limit(pageable.getPageSize()).as(MongoDomainURL.class); List<DomainURL> result = new ArrayList<>(); for (MongoDomainURL mongoDomainURL : domains) { result.add(new DomainURL(mongoDomainURL.getName(), mongoDomainURL.getAddress(), mongoDomainURL.getCoolDownPeriod())); } return result; }  @PostConstruct void init(); DomainURL addDomainUrl(String domainName, String domainUrl, long coolDownPeriod); @Override void addSimpleUrls(List<String> urls, String status, String domainURL, String sourceDomainName); @Override void addDomainLinks(List<DomainLink> domainLinks); @Override List<DomainURL> findDomains(Pageable pageable); @Override Collection<SimpleURL> findURLs(String address, String status, int pageNo, int pageSize); @Override Collection<SimpleURL> findExternalURLs(String address, String status, int pageNo, int pageSize); void removeSimpleUrl(String url); @Override void updateSimpleUrlsStatus(List<String> urls, String status); @Override void updateSimpleUrlErrorStatus(String url, int errorDelta); void removeDomainUrl(String domainURL); @Override void removeDomains(); @Override List<Entries> query(String query); @Override long countAllNodes(); @Override long countAllDomains(); @Override long countAllLinks(); @Override long countDomainLinks(String domainUrl); }
MongoUrlServiceImpl implements UrlService { @Override public List<DomainURL> findDomains(Pageable pageable) { Iterable<MongoDomainURL> domains = domainRepo.find().skip(pageable.getOffset()).limit(pageable.getPageSize()).as(MongoDomainURL.class); List<DomainURL> result = new ArrayList<>(); for (MongoDomainURL mongoDomainURL : domains) { result.add(new DomainURL(mongoDomainURL.getName(), mongoDomainURL.getAddress(), mongoDomainURL.getCoolDownPeriod())); } return result; }  @PostConstruct void init(); DomainURL addDomainUrl(String domainName, String domainUrl, long coolDownPeriod); @Override void addSimpleUrls(List<String> urls, String status, String domainURL, String sourceDomainName); @Override void addDomainLinks(List<DomainLink> domainLinks); @Override List<DomainURL> findDomains(Pageable pageable); @Override Collection<SimpleURL> findURLs(String address, String status, int pageNo, int pageSize); @Override Collection<SimpleURL> findExternalURLs(String address, String status, int pageNo, int pageSize); void removeSimpleUrl(String url); @Override void updateSimpleUrlsStatus(List<String> urls, String status); @Override void updateSimpleUrlErrorStatus(String url, int errorDelta); void removeDomainUrl(String domainURL); @Override void removeDomains(); @Override List<Entries> query(String query); @Override long countAllNodes(); @Override long countAllDomains(); @Override long countAllLinks(); @Override long countDomainLinks(String domainUrl); @Autowired
    public MetricsConfig metricsConfig; @Autowired
    public MongoConfig mongoConfig; public MongoCollection domainRepo; public MongoCollection urlRepo; }