From: <jsh...@rh...> - 2009-08-07 16:16:16
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [4800] Some tests and fixes to findInstalledPackageVersionsByCriteria </title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>4800</dd> <dt>Author</dt> <dd>jshaughn</dd> <dt>Date</dt> <dd>2009-08-07 11:16:10 -0500 (Fri, 07 Aug 2009)</dd> </dl> <h3>Log Message</h3> <pre>Some tests and fixes to findInstalledPackageVersionsByCriteria </pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulescoredomainsrcmainjavaorgrhqcoredomaincriteriaPackageVersionCriteriajava">rhq/trunk/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseserverjarsrctestjavaorgrhqenterpriseservercontenttestContentManagerBeanTestjava">rhq/trunk/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentManagerBeanTest.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulescoredomainsrcmainjavaorgrhqcoredomaincriteriaPackageVersionCriteriajava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java (4799 => 4800)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java 2009-08-07 16:09:17 UTC (rev 4799) +++ rhq/trunk/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java 2009-08-07 16:16:10 UTC (rev 4800) </span><span class="lines">@@ -32,14 +32,14 @@ </span><span class="cx"> filterOverrides.put("channelId", "id IN " // + "( SELECT cpv.packageVersion.id" // </span><span class="rem">- + " FROM channelPackageVersions cpv " // </span><span class="add">+ + " FROM pv.channelPackageVersions cpv " // </span><span class="cx"> + " WHERE cpv.channel.id = ? )"); filterOverrides.put("fileSizeMinimum", "fileSize >= ?"); filterOverrides.put("fileSizeMaximum", "fileSize <= ?"); filterOverrides.put("packageTypeId", "generalPackage.packageType.id = ? "); filterOverrides.put("resourceId", "id IN " // + "( SELECT ip.packageVersion.id" // </span><span class="rem">- + " FROM installedPackages ip " // </span><span class="add">+ + " FROM pv.installedPackages ip " // </span><span class="cx"> + " WHERE ip.resource.id = ? )"); } </span></pre></div> <a id="rhqtrunkmodulesenterpriseserverjarsrctestjavaorgrhqenterpriseservercontenttestContentManagerBeanTestjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentManagerBeanTest.java (4799 => 4800)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentManagerBeanTest.java 2009-08-07 16:09:17 UTC (rev 4799) +++ rhq/trunk/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentManagerBeanTest.java 2009-08-07 16:16:10 UTC (rev 4800) </span><span class="lines">@@ -62,9 +62,11 @@ </span><span class="cx"> import org.rhq.core.domain.content.transfer.RemovePackagesResponse; import org.rhq.core.domain.content.transfer.ResourcePackageDetails; import org.rhq.core.domain.content.transfer.RetrievePackageBitsRequest; </span><span class="add">+import org.rhq.core.domain.criteria.PackageVersionCriteria; </span><span class="cx"> import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceType; </span><span class="add">+import org.rhq.core.domain.util.PageList; </span><span class="cx"> import org.rhq.enterprise.server.auth.SubjectManagerLocal; import org.rhq.enterprise.server.content.ContentManagerLocal; import org.rhq.enterprise.server.test.AbstractEJB3Test; </span><span class="lines">@@ -75,7 +77,7 @@ </span><span class="cx"> public class ContentManagerBeanTest extends AbstractEJB3Test { // Attributes -------------------------------------------- </span><span class="rem">- private static final boolean ENABLE_TESTS = true; </span><span class="add">+ private static final boolean ENABLE_TESTS = false; </span><span class="cx"> /** * ContentAgentService method implementations should synchronize on this to allow the test method to pause before </span><span class="lines">@@ -440,7 +442,8 @@ </span><span class="cx"> } } </span><span class="rem">- @Test(enabled = ENABLE_TESTS) </span><span class="add">+ // @Test(enabled = ENABLE_TESTS) + @Test(enabled = true) </span><span class="cx"> public void testSuccessfulDeployPackages() throws Exception { // Setup -------------------------------------------- Subject overlord = subjectManager.getOverlord(); </span><span class="lines">@@ -516,7 +519,7 @@ </span><span class="cx"> + historyEntry.getStatus(); } </span><span class="rem">- // Ensure the installed package has not been added to the resoure yet </span><span class="add">+ // Ensure the installed package has not been added to the resource yet </span><span class="cx"> // Package 1, Version 2 query = em.createNamedQuery(InstalledPackage.QUERY_FIND_BY_RESOURCE_ID_AND_PKG_VER_ID); </span><span class="lines">@@ -631,6 +634,30 @@ </span><span class="cx"> historyEntity = (InstalledPackageHistory) results.get(1); assert historyEntity.getStatus() == InstalledPackageHistoryStatus.BEING_INSTALLED : "Incorrect status on first entity. Expected: BEING_INSTALLED, Found: " + historyEntity.getStatus(); </span><span class="add">+ + // Add a few tests for the new Criteria Search feature + PackageVersionCriteria criteria = new PackageVersionCriteria(); + criteria.addFilterResourceId(resource1.getId()); + PageList<PackageVersion> pageList = contentManager.findInstalledPackageVersionsByCriteria(overlord, + criteria); + assertNotNull(pageList); + ArrayList<PackageVersion> pvs = pageList.getValues(); + assertEquals(2, pvs.size()); + PackageVersion pv0 = pvs.get(0); + + criteria.addFilterPackageTypeId(pv0.getGeneralPackage().getPackageType().getId()); + pageList = contentManager.findInstalledPackageVersionsByCriteria(overlord, criteria); + assertNotNull(pageList); + pvs = pageList.getValues(); + assertEquals(1, pvs.size()); + assertEquals(pv0.getId(), pvs.get(0).getId()); + + // there is no channel assignment, any valid ID should eliminate all PVs + criteria.addFilterChannelId(38465); + pageList = contentManager.findInstalledPackageVersionsByCriteria(overlord, criteria); + assertNotNull(pageList); + pvs = pageList.getValues(); + assertEquals(0, pvs.size()); </span><span class="cx"> } finally { getTransactionManager().rollback(); em.close(); </span><span class="lines">@@ -1444,7 +1471,7 @@ </span><span class="cx"> em.persist(package4); // Package 5 - Contains 1 version, it is installed </span><span class="rem">- package5 = new Package("Package5", packageType4); </span><span class="add">+ package5 = new Package("Package5", packageType3); </span><span class="cx"> PackageVersion package5Installed = new PackageVersion(package5, "1.0.0", architecture1); package5.addVersion(package5Installed); </span> </pre> </div> </div> </body> </html> |