Package org.rhq.core.domain.resource

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


        assert contentResource != null : "Could not load test-scheduler.properties as package content";

        InputStream packageInputStream = contentResource.openStream();

        // Test
        CreateResourceHistory history1 = resourceFactoryManager.createResource(overlord, parentResource.getId(),
            contentBackedChildResourceType.getId(), "newResource", null, packageName, packageVersion, architectureId,
            deploymentTimeConfiguration, packageInputStream);

        // Verify
        try {
            getTransactionManager().begin();

            Resource parent = em.find(Resource.class, parentResource.getId());
            List<CreateResourceHistory> historyList = parent.getCreateChildResourceRequests();

            assert historyList.size() == 1 : "Incorrect number of children found. Expected: 1, Found: "
                + historyList.size();

            CreateResourceHistory historyItem = historyList.get(0);

            assert historyItem.getStatus() == CreateResourceStatus.SUCCESS : "Incorrect status for history item. Expected: Success, Found: "
                + historyItem.getStatus();
            assert historyItem.getNewResourceKey().equals("mockResourceKey") : "Incorrect resource key for history item. Expected: mockResourceKey, Found: "
                + historyItem.getNewResourceKey();
            assert historyItem.getErrorMessage() == null : "Error message found for successful call";
        } finally {
            getTransactionManager().rollback();
        }

        // Invoke the same callbacks the plugin container would to actually commit the new Resource to inventory.
        resourceFactoryManager.completeCreateResource(new CreateResourceResponse(history1.getId(), "newResource",
            "key", CreateResourceStatus.SUCCESS, null, new Configuration()));
        Resource resource = new Resource(2000000);
        resource.setUuid(UUID.randomUUID().toString());
        resource.setResourceType(contentBackedChildResourceType);
        long randomLong = UUID.randomUUID().getLeastSignificantBits();
        resource.setResourceKey(String.valueOf("key-" + randomLong));
        resource.setName("name-" + randomLong);
        resource.setParentResource(parentResource);
        discoveryBoss.addResource(resource, overlord.getId());

        // Now try to create another Resource of the same singleton type - this should fail.
        try {
            CreateResourceHistory history2 = resourceFactoryManager.createResource(overlord, parentResource.getId(),
                contentBackedChildResourceType.getId(), "newResource2", null, packageName, packageVersion,
                architectureId, deploymentTimeConfiguration, packageInputStream);
            fail("Creating a singleton that already existed succeeded: " + history2);
        } catch (EJBException e) {
            assertEquals(String.valueOf(e.getCause()), RuntimeException.class, e.getCause().getClass());
View Full Code Here


        PageList<CreateResourceHistory> historyList = resourceFactoryManager.findCreateChildResourceHistory(overlord,
            parentResource.getId(), null, null, new PageControl(0, 1000));
        int historyItemId = historyList.get(0).getId();

        // Test
        CreateResourceHistory historyItem = resourceFactoryManager.getCreateHistoryItem(historyItemId);

        // Verify
        assert historyItem != null : "Null history item returned from call";
        assert historyItem.getCreatedResourceName().equals("NewResource");
    }
View Full Code Here

TOP

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

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.