UpdateDatabase implements ProgressTask<PackageListUpdateReport> { protected List<Package> collectOutdatedPackages(Source source, List<Package> newPackageList) { List<Package> existingPackages = db.getPackageRepository().findBySource(source); return collectOutdatedPackages(newPackageList, existingPackages); } UpdateDatabase(PackageManagerConfiguration configuration, SourcesList sourcesList, PackageManagerDatabase db, DownloadManager downloadManager); @Override ProgressTaskDescription getDescription(Locale locale); @Override PackageListUpdateReport execute(ProgressReceiver progressReceiver);  }
@Test public void testCollectedOutdatedPackages() { final Source source = new Source(); final List<Package> existing = Arrays.asList( createPackage("foo", "2.0-1", false, source), createPackage("foo", "2.1-1", false, source), createPackage("foo", "2.2-1", false, source), createPackage("bar", "3.5-1", false, source) ); final List<Package> newPackageList = Arrays.asList( createPackage("foo", "2.1-1", false, source), createPackage("foo", "2.2-1", false, source), createPackage("bar", "3.5-1", false, source) ); final UpdateDatabase updater = createUpdateDatabase(); final List<Package> outdated = updater.collectOutdatedPackages(newPackageList, existing); assertEquals(1, outdated.size()); assertEquals("foo", outdated.get(0).getName()); assertEquals(Version.parse("2.0-1"), outdated.get(0).getVersion()); }