assert results.get(0).getBundleName().equals(b1.getName());
assert results.get(0).getBundleDescription().equals(b1.getDescription());
assert results.get(0).getLatestVersion().equals("2.0");
assert results.get(0).getVersionsCount().longValue() == 3L;
BundleVersionCriteria c = new BundleVersionCriteria();
PageList<BundleVersion> bvs;
c.addFilterId(bv1.getId()); // 1.0
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
assertNotNull(bvs);
assertEquals(1, bvs.size());
assert bvs.get(0).getVersionOrder() == 0; // 1st is the 1.0 version
c.addFilterId(bv2.getId()); // 2.0
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
assertNotNull(bvs);
assertEquals(1, bvs.size());
assert bvs.get(0).getVersionOrder() == 2; // 3rd is the 2.0 version
c.addFilterId(bv3.getId()); // 1.5
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
assertNotNull(bvs);
assertEquals(1, bvs.size());
assert bvs.get(0).getVersionOrder() == 1; // 2nd is the 1.5 version
// see that we can create a really old bundle and versionOrder gets updated properly
BundleVersion bv4 = createBundleVersion(b1.getName() + "-4", "0.5", b1);
assertNotNull(bv4);
assertEquals("0.5", bv4.getVersion());
c.addFilterId(bv4.getId()); //0.5
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
assertNotNull(bvs);
assertEquals(1, bvs.size());
assert bvs.get(0).getVersionOrder() == 0; // 1st is the 0.5 version
c.addFilterId(bv1.getId()); // 1.0
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
assertNotNull(bvs);
assertEquals(1, bvs.size());
assert bvs.get(0).getVersionOrder() == 1; // 2nd is the 1.0 version
c.addFilterId(bv3.getId()); // 1.5
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
assertNotNull(bvs);
assertEquals(1, bvs.size());
assert bvs.get(0).getVersionOrder() == 2; // 3nd is the 1.5 version
c.addFilterId(bv2.getId()); // 2.0
bvs = bundleManager.findBundleVersionsByCriteria(overlord, c);
assertNotNull(bvs);
assertEquals(1, bvs.size());
assert bvs.get(0).getVersionOrder() == 3; // 4th is the 2.0 version