Package org.rhq.core.domain.content

Examples of org.rhq.core.domain.content.InstalledPackageHistory


                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);
View Full Code Here


            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();

            // The installed entry should contain the steps that were done in the installation
            List<PackageInstallationStep> installationSteps = historyEntity.getInstallationSteps();

            assert installationSteps != null : "Installation steps were null";
            assert installationSteps.size() == 3 : "Incorrect number of installation steps. Expected: 3, Found: "
                + installationSteps.size();

            PackageInstallationStep step = installationSteps.get(0);

            assert step.getOrder() == 0 : "Incorrect order applied for step";
            assert step.getDescription() != null : "Description not saved";
            assert step.getResult() == ContentResponseResult.SUCCESS : "Incorrect status on step. Expected: SUCCESS, Found: "
                + step.getResult();
            assert step.getErrorMessage() == null : "Error message found on successful step";
            assert step.getInstalledPackageHistory() != null : "Relationship to packge history isn't established";

            step = installationSteps.get(1);

            assert step.getOrder() == 1 : "Incorrect order applied for step";
            assert step.getDescription() != null : "Description not saved";
            assert step.getResult() == ContentResponseResult.NOT_PERFORMED : "Incorrect status on step. Expected: NOT_PERFORMED, Found: "
                + step.getResult();
            assert step.getErrorMessage() == null : "Error message found on skipped step";
            assert step.getInstalledPackageHistory() != null : "Relationship to packge history isn't established";

            step = installationSteps.get(2);

            assert step.getOrder() == 2 : "Incorrect order applied for step";
            assert step.getDescription() != null : "Description not saved";
            assert step.getResult() == ContentResponseResult.FAILURE : "Incorrect status on step. Expected: FAILURE, Found: "
                + step.getResult();
            assert step.getErrorMessage() != null : "Null error message found on error step";
            assert step.getInstalledPackageHistory() != null : "Relationship to packge history isn't established";

            historyEntity = (InstalledPackageHistory) results.get(1);
            assert historyEntity.getStatus() == InstalledPackageHistoryStatus.BEING_INSTALLED : "Incorrect status on first entity. Expected: BEING_INSTALLED, Found: "
                + historyEntity.getStatus();

        } finally {
            getTransactionManager().rollback();
        }
    }
View Full Code Here

            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.FAILED : "Incorrect status on first entity. Expected: FAILED, 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();
        } finally {
            getTransactionManager().rollback();
        }
    }
View Full Code Here

            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.FAILED : "Incorrect status on first entity. Expected: FAILED, 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();
        } finally {
            getTransactionManager().rollback();
        }
    }
View Full Code Here

            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.FAILED : "Incorrect status on first entity. Expected: FAILED, 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();
        } finally {
            getTransactionManager().rollback();
        }
    }
View Full Code Here

            Subject overlord = subjectManager.getOverlord();
            PackageVersion packageVersion = em.find(PackageVersion.class, package3.getVersions().get(0).getId());

            request = new ContentServiceRequest(resource1, overlord.getName(), ContentRequestType.DEPLOY);

            InstalledPackageHistory originalRequestedPackage = new InstalledPackageHistory();
            originalRequestedPackage.setContentServiceRequest(request);
            originalRequestedPackage.setPackageVersion(packageVersion);
            originalRequestedPackage.setStatus(InstalledPackageHistoryStatus.BEING_INSTALLED);
            originalRequestedPackage.setTimestamp(System.currentTimeMillis());
            originalRequestedPackage.setResource(resource1);

            request.addInstalledPackageHistory(originalRequestedPackage);

            em.persist(request);
View Full Code Here

            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.DELETED : "Incorrect status on first entity. Expected: DELETED, Found: "
                + historyEntity.getStatus();

            historyEntity = (InstalledPackageHistory) results.get(1);
            assert historyEntity.getStatus() == InstalledPackageHistoryStatus.BEING_DELETED : "Incorrect status on first entity. Expected: BEING_DELETED, Found: "
                + historyEntity.getStatus();

            // Package 4, Version 2
            query = em.createNamedQuery(InstalledPackage.QUERY_FIND_BY_RESOURCE_ID_AND_PKG_VER_ID);
            query.setParameter("resourceId", resource1.getId());
            query.setParameter("packageVersionId", installedPackage1.getPackageVersion().getId());
View Full Code Here

            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.FAILED : "Incorrect status on first entity. Expected: FAILED, Found: "
                + historyEntity.getStatus();

            historyEntity = (InstalledPackageHistory) results.get(1);
            assert historyEntity.getStatus() == InstalledPackageHistoryStatus.BEING_DELETED : "Incorrect status on first entity. Expected: BEING_DELETED, Found: "
                + historyEntity.getStatus();

            // Package 4, Version 2
            query = em.createNamedQuery(InstalledPackage.QUERY_FIND_BY_RESOURCE_ID_AND_PKG_VER_ID);
            query.setParameter("resourceId", resource1.getId());
            query.setParameter("packageVersionId", installedPackage1.getPackageVersion().getId());
View Full Code Here

            packageVersionQuery.setParameter("resourceTypeId", resourceTypeId);

            PackageVersion packageVersion = (PackageVersion) packageVersionQuery.getSingleResult();

            // Create the history entity
            InstalledPackageHistory history = new InstalledPackageHistory();
            history.setContentServiceRequest(persistedRequest);
            history.setPackageVersion(packageVersion);
            history.setResource(resource);
            history.setTimestamp(timestamp);

            if (singleResponse.getResult() == ContentResponseResult.SUCCESS) {
                history.setStatus(InstalledPackageHistoryStatus.DELETED);

                // We used to remove the InstalledPackage entity here, but now we'll rely on the plugin container
                // to trigger a discovery after the delete request finishes.
            } else {
                history.setStatus(InstalledPackageHistoryStatus.FAILED);
                history.setErrorMessage(singleResponse.getErrorMessage());
            }

            entityManager.persist(history);
            persistedRequest.addInstalledPackageHistory(history);

            // We're closing out the package request for this package version, so remove it from the cache of entries
            // that need to be closed
            inProgressEntries.remove(packageVersion);
        }

        // For any entries that were not closed, add closing entries
        for (InstalledPackageHistory unclosed : inProgressEntries.values()) {
            PackageVersion packageVersion = unclosed.getPackageVersion();

            // Create the history entity
            InstalledPackageHistory history = new InstalledPackageHistory();
            history.setContentServiceRequest(persistedRequest);
            history.setPackageVersion(packageVersion);
            history.setResource(resource);
            history.setTimestamp(timestamp);

            // One option is to create a new status that indicates unknown. For now, just give them the same result
            // as the overall request result
            if (response.getOverallRequestResult() == ContentResponseResult.SUCCESS) {
                history.setStatus(InstalledPackageHistoryStatus.DELETED);
            } else {
                history.setStatus(InstalledPackageHistoryStatus.FAILED);
            }

            entityManager.persist(history);
            persistedRequest.addInstalledPackageHistory(history);
        }
View Full Code Here

        // Load the InstalledPackage to get its package version for the relationship
        InstalledPackage ip = entityManager.find(InstalledPackage.class, installedPackageId);
        PackageVersion packageVersion = ip.getPackageVersion();

        // Create the history entity
        InstalledPackageHistory history = new InstalledPackageHistory();
        history.setContentServiceRequest(persistedRequest);
        history.setPackageVersion(packageVersion);
        history.setResource(resource);
        history.setStatus(InstalledPackageHistoryStatus.BEING_RETRIEVED);
        history.setTimestamp(timestamp);

        persistedRequest.addInstalledPackageHistory(history);

        entityManager.persist(persistedRequest);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.content.InstalledPackageHistory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.