results = query.getResultList();
assert results.size() == 1 : "Incorrect number of audit trail entries. Expected: 1, Found: "
+ results.size();
InstalledPackageHistory historyEntity = (InstalledPackageHistory) results.get(0);
assert historyEntity.getStatus() == InstalledPackageHistoryStatus.BEING_INSTALLED : "Incorrect status on first entity. Expected: BEING_INSTALLED, Found: "
+ historyEntity.getStatus();
// Package 2, Version 1
query = em.createNamedQuery(InstalledPackage.QUERY_FIND_BY_RESOURCE_ID_AND_PKG_VER_ID);
query.setParameter("resourceId", resource1.getId());
query.setParameter("packageVersionId", packageVersion2.getId());
results = query.getResultList();
assert results.size() == 0 : "Incorrect number of installed packages for package 2, version 1. Expected: 0, Found: "
+ results.size();
// Check status of audit trail
query = em.createNamedQuery(InstalledPackageHistory.QUERY_FIND_BY_CSR_ID_AND_PKG_VER_ID);
query.setParameter("contentServiceRequestId", request.getId());
query.setParameter("packageVersionId", packageVersion2.getId());
results = query.getResultList();
assert results.size() == 1 : "Incorrect number of audit trail entries. Expected: 1, Found: "
+ results.size();
historyEntity = (InstalledPackageHistory) results.get(0);
assert historyEntity.getStatus() == InstalledPackageHistoryStatus.BEING_INSTALLED : "Incorrect status on second entity. Expected: BEING_INSTALLED, Found: "
+ historyEntity.getStatus();
} finally {
responseLock.notifyAll();
getTransactionManager().rollback();
}
}
// Verify --------------------------------------------
// Give the agent service a second to make sure it finishes out its call
Thread.sleep(1000);
getTransactionManager().begin();
try {
// Content request
Query query = em.createNamedQuery(ContentServiceRequest.QUERY_FIND_BY_RESOURCE);
query.setParameter("resourceId", resource1.getId());
List<?> results = query.getResultList();
assert results.size() == 1 : "Incorrect number of content service requests. Expected: 1, Found: "
+ results.size();
ContentServiceRequest request = (ContentServiceRequest) results.get(0);
assert request.getStatus() == ContentRequestStatus.SUCCESS : "Request status incorrect. Expected: SUCCESS, Found: "
+ request.getStatus();
// Verify a history entry has been added for the completion of the request per package
Set<InstalledPackageHistory> history = request.getInstalledPackageHistory();
assert history.size() == 4 : "Incorrect number of history entries on request. Expected: 4, Found: "
+ history.size();
// Check for Package 1
query = em.createNamedQuery(InstalledPackageHistory.QUERY_FIND_BY_CSR_ID_AND_PKG_VER_ID);
query.setParameter("contentServiceRequestId", request.getId());
query.setParameter("packageVersionId", packageVersion1.getId());
results = query.getResultList();
assert results.size() == 2 : "Incorrect number of history entries. Expected: 2, Found: " + results.size();
InstalledPackageHistory historyEntity = (InstalledPackageHistory) results.get(0);
assert historyEntity.getStatus() == InstalledPackageHistoryStatus.INSTALLED : "Incorrect status on first entity. Expected: INSTALLED, Found: "
+ historyEntity.getStatus();
historyEntity = (InstalledPackageHistory) results.get(1);
assert historyEntity.getStatus() == InstalledPackageHistoryStatus.BEING_INSTALLED : "Incorrect status on first entity. Expected: BEING_INSTALLED, Found: "
+ historyEntity.getStatus();
// Check for Package 2
query = em.createNamedQuery(InstalledPackageHistory.QUERY_FIND_BY_CSR_ID_AND_PKG_VER_ID);
query.setParameter("contentServiceRequestId", request.getId());
query.setParameter("packageVersionId", packageVersion2.getId());
results = query.getResultList();
assert results.size() == 2 : "Incorrect number of history entries. Expected: 2, Found: " + results.size();
historyEntity = (InstalledPackageHistory) results.get(0);
assert historyEntity.getStatus() == InstalledPackageHistoryStatus.INSTALLED : "Incorrect status on first entity. Expected: INSTALLED, Found: "
+ historyEntity.getStatus();
historyEntity = (InstalledPackageHistory) results.get(1);
assert historyEntity.getStatus() == InstalledPackageHistoryStatus.BEING_INSTALLED : "Incorrect status on first entity. Expected: BEING_INSTALLED, Found: "
+ historyEntity.getStatus();
// Add a few tests for the new Criteria Search feature
PackageVersionCriteria criteria = new PackageVersionCriteria();
criteria.addFilterResourceId(resource1.getId());
PageList<PackageVersion> pageList = contentManager.findPackageVersionsByCriteria(overlord, criteria);