Package org.rhq.core.domain.resource

Examples of org.rhq.core.domain.resource.ResourceError


    public void testCreateErrors() throws Exception {
        getTransactionManager().begin();

        try {
            ResourceError re;

            re = new ResourceError(newResource, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION, "test summary",
                "test detail", 12345);

            em.persist(re);

            ResourceError error = em.find(ResourceError.class, re.getId());
            assert error != null;
            assert error.getId() > 0;
            assert error.getResource().getId() == newResource.getId();
            assert error.getErrorType() == ResourceErrorType.INVALID_PLUGIN_CONFIGURATION;
            assert error.getSummary().equals("test summary");
            assert error.getDetail().equals("test detail");
            assert error.getTimeOccurred() == 12345;

            re = new ResourceError(newResource, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION, "test summary 2",
                "test detail 2", 56789);

            em.persist(re);

            error = em.find(ResourceError.class, re.getId());
            assert error != null;
            assert error.getId() > 0;
            assert error.getResource().getId() == newResource.getId();
            assert error.getErrorType() == ResourceErrorType.INVALID_PLUGIN_CONFIGURATION;
            assert error.getSummary().equals("test summary 2");
            assert error.getDetail().equals("test detail 2");
            assert error.getTimeOccurred() == 56789;

            Query q = em.createNamedQuery(ResourceError.QUERY_FIND_BY_RESOURCE_ID);
            q.setParameter("resourceId", newResource.getId());
            assert q.getResultList().size() == 2;
View Full Code Here


        }
    }

    @SuppressWarnings("unchecked")
    public void testQueries() throws Exception {
        ResourceError re;
        Query q;
        List<ResourceError> errors;

        getTransactionManager().begin();

        try {
            q = em.createNamedQuery(ResourceError.QUERY_FIND_BY_RESOURCE_ID);
            q.setParameter("resourceId", newResource.getId());
            errors = q.getResultList();
            assert errors.size() == 0;

            re = new ResourceError(newResource, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION, "test summary",
                "test detail", 12345);

            em.persist(re);
            errors = q.getResultList();
            assert errors.size() == 1;
View Full Code Here

        groupManager = LookupUtil.getResourceGroupManager();
        newGroup = createNewGroup();
    }

    public void testResourceErrors() {
        ResourceError error;
        List<ResourceError> errors;
        DiscoveryServerServiceImpl serverService = new DiscoveryServerServiceImpl();

        errors = resourceManager.findResourceErrors(getOverlord(), newResource.getId(),
            ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
        assert errors.size() == 0;

        error = new ResourceError(newResource, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION, "test summary",
            "test detail", 12345);

        // simulate the agent notifying the server about an error
        // this will exercise the addResourceError in the SLSB
        serverService.setResourceError(error);
        errors = resourceManager.findResourceErrors(getOverlord(), newResource.getId(),
            ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
        assert errors.size() == 1;
        error = errors.get(0);
        assert error.getId() > 0;
        assert error.getSummary().equals("test summary");
        assert error.getDetail().equals("test detail");
        assert error.getErrorType() == ResourceErrorType.INVALID_PLUGIN_CONFIGURATION;
        assert error.getTimeOccurred() == 12345;

        // simulate the agent notifying the server about another error.
        // there will only be a single invalid plugin config allowed; the prior one will be deleted
        // this will exercise the addResourceError and deleteResourceError in the SLSB
        error.setId(0);
        error.setTimeOccurred(567890);
        error.setSummary("another summary");
        error.setDetail("another detail");
        serverService.setResourceError(error);
        errors = resourceManager.findResourceErrors(getOverlord(), newResource.getId(),
            ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
        assert errors.size() == 1;
        error = errors.get(0);
        assert error.getId() > 0;
        assert error.getSummary().equals("another summary");
        assert error.getDetail().equals("another detail");
        assert error.getErrorType() == ResourceErrorType.INVALID_PLUGIN_CONFIGURATION;
        assert error.getTimeOccurred() == 567890;

        resourceManager.deleteResourceError(getOverlord(), error.getId());
        errors = resourceManager.findResourceErrors(getOverlord(), newResource.getId(),
            ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
        assert errors.size() == 0;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.ResourceError

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.