RepoSyncResults results = new RepoSyncResults(repo);
results = repoManager.persistRepoSyncResults(results);
assert results != null;
// this report will add a mapping to PV->CS
PackageSyncReport report = new PackageSyncReport();
ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey("testARUFoo", "testARUVer",
packageType1.getName(), architecture1.getName(), resourceType1.getName(), resourceType1.getPlugin());
ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
details.setLocation("dummy-location-aru");
details.setFileSize(1234L); // lazy load is on, this should not matter
report.addNewPackage(details);
Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous;
previous = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>();
// ADD: merge the report!
results = contentSourceManager.mergePackageSyncReport(contentSource, repo, report, previous, results);
assert results != null;
// see the package version has been assigned to the content source
inCS = contentSourceManager.getPackageVersionsFromContentSource(overlord, contentSourceId, pc);
assert inCS != null;
assert inCS.size() == 1 : inCS;
// confirm that we didn't load the bits yet
List<PackageVersionContentSource> unloaded;
unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord,
contentSourceId, repoId, pc);
assert unloaded != null;
assert unloaded.size() == 1;
// check the count
long pvcscount = contentSourceManager.getPackageVersionCountFromContentSource(overlord, contentSourceId);
assert (pvcscount == 1) : "-->" + pvcscount;
// this is the new one we just added - we'll pass this to our next merge as the previous state
PackageVersionContentSource addedPVCS = unloaded.get(0);
assert addedPVCS.getPackageVersionContentSourcePK().getPackageVersion().getFileSize() == 1234L;
previous.put(key, addedPVCS);
System.out.println("content source merge ADD works!");
// create a new report that updates the one we just added
report = new PackageSyncReport();
details.setFileSize(9999L);
report.addUpdatedPackage(details);
// UPDATE: merge the report!
results = contentSourceManager.mergePackageSyncReport(contentSource, repo, report, previous, results);
assert results != null;
// see the package version is still assigned to the content source
inCS = contentSourceManager.getPackageVersionsFromContentSource(overlord, contentSourceId, pc);
assert inCS != null;
assert inCS.size() == 1 : inCS;
// it should still be unloaded, make sure and check that it really was updated
unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord,
contentSourceId, repoId, pc);
assert unloaded != null;
assert unloaded.size() == 1;
assert unloaded.get(0).getPackageVersionContentSourcePK().getPackageVersion().getFileSize() == 9999L;
System.out.println("content source merge UPDATE works!");
// create a report that removes the one we added/updated, our 'previous' map is still valid
report = new PackageSyncReport();
report.addDeletePackage(details);
// REMOVE: merge the report!
results = contentSourceManager.mergePackageSyncReport(contentSource, repo, report, previous, results);
assert results != null;