@SuppressWarnings("unchecked")
@Test(enabled = ENABLE_TESTS)
public void testInventoryMerge() throws Exception {
// Setup --------------------------------------------
ContentDiscoveryReport report = new ContentDiscoveryReport();
report.setResourceId(resource1.getId());
// Package version that exists
PackageDetailsKey key1 = new PackageDetailsKey(package1.getName(), "2.0.0",
package1.getPackageType().getName(), architecture1.getName());
ResourcePackageDetails package1 = new ResourcePackageDetails(key1);
report.addDeployedPackage(package1);
// Package version number that doesn't exist
PackageDetailsKey key2 = new PackageDetailsKey(package2.getName(), "3.0.0", this.package2.getPackageType()
.getName(), architecture1.getName());
ResourcePackageDetails package2 = new ResourcePackageDetails(key2);
report.addDeployedPackage(package2);
// Package with same version number but different architecture
PackageDetailsKey key3 = new PackageDetailsKey(package3.getName(), "1.0.0", this.package3.getPackageType()
.getName(), architecture2.getName());
ResourcePackageDetails package3 = new ResourcePackageDetails(key3);
report.addDeployedPackage(package3);
// Package where entire package does not exist
PackageDetailsKey key4 = new PackageDetailsKey("PackageX", "1.0.0", packageType4.getName(),
architecture1.getName());
ResourcePackageDetails package4 = new ResourcePackageDetails(key4);
// Fully populate this version to make sure the translation from details -> domain model works
// Don't need to do this on all packages
package4.setClassification("Package X1 Category");
package4.setDisplayName("Package X1 Display Name");
package4.setDisplayVersion("Package X1 Display Version");
package4.setFileCreatedDate(System.currentTimeMillis());
package4.setFileName("package4.tar.gz");
package4.setFileSize(1000L);
package4.setLicenseName("GPL");
package4.setLicenseVersion("2");
package4.setLongDescription("Package X1 Long Description");
package4.setMD5("7bf1adec93fdb899aeca248a38603d58");
package4.setSHA256("935f051cab5240b979bba87ce58183d50f592a962202ca683f12a7966414fe6c");
package4.setShortDescription("Package X1 Short Description");
String package4Metadata = "Package X1 Metadata";
package4.setMetadata(package4Metadata.getBytes());
Configuration package4DeploymentConfiguration = new Configuration();
package4DeploymentConfiguration.put(new PropertySimple("property1", "value1"));
package4.setDeploymentTimeConfiguration(package4DeploymentConfiguration);
Configuration package4ExtraProperties = new Configuration();
package4ExtraProperties.put(new PropertySimple("property2", "value2"));
package4.setExtraProperties(package4ExtraProperties);
report.addDeployedPackage(package4);
// Upgraded package to package version known to the system
PackageDetailsKey key5 = new PackageDetailsKey("Package4", "2.0.0", this.package4.getPackageType().getName(),
architecture1.getName());
ResourcePackageDetails package5 = new ResourcePackageDetails(key5);
report.addDeployedPackage(package5);
// In most cases, the same package report will come back from the agent (i.e. no changes). This is a simple way
// of testing that to ensure we're not messing up and adding multiple installed packages.
for (int ii = 0; ii < 2; ii++) {
// Test --------------------------------------------