q = em.createNamedQuery(PackageVersion.QUERY_FIND_METADATA_BY_RESOURCE_ID);
q.setParameter("resourceId", resource.getId());
List<PackageVersionMetadataComposite> metadataList = q.getResultList();
assert metadataList.size() == 1 : "-->" + metadataList;
PackageVersionMetadataComposite composite = metadataList.get(0);
assert composite.getPackageVersionId() == pv.getId();
assert new String(composite.getMetadata()).equals(new String(pv.getMetadata()));
assert new String(composite.getPackageDetailsKey().getName()).equals(pkg.getName());
assert new String(composite.getPackageDetailsKey().getVersion()).equals(pv.getVersion());
assert new String(composite.getPackageDetailsKey().getPackageTypeName()).equals(pt.getName());
assert new String(composite.getPackageDetailsKey().getArchitectureName()).equals(arch.getName());
em.clear();
// remove cs from pv
pvcs = em.find(PackageVersionContentSource.class, pvcs.getPackageVersionContentSourcePK());
em.remove(pvcs);