Package org.rhq.core.domain.bundle

Examples of org.rhq.core.domain.bundle.Bundle


        assert btNames.contains(bt2.getName());
    }

    @Test(enabled = TESTS_ENABLED)
    public void testCreateBundle() throws Exception {
        Bundle b1 = createBundle("one");
        assertNotNull(b1);
    }
View Full Code Here


        assertNotNull(b1);
    }

    @Test(enabled = TESTS_ENABLED)
    public void testCreateBundleVersion() throws Exception {
        Bundle b1 = createBundle("one");
        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        assertEquals("1.0", bv1.getVersion());
        assert 0 == bv1.getVersionOrder();
        BundleVersion bv2 = createBundleVersion(b1.getName() + "-2", null, b1);
        assertNotNull(bv2);
        assertEquals("1.1", bv2.getVersion());
        assert 1 == bv2.getVersionOrder();
    }
View Full Code Here

        // add bg1 to the role with group create
        addRoleBundleGroup(role, bundleGroup1);
        addRolePermissions(role, Permission.CREATE_BUNDLES_IN_GROUP);

        // allow bundle creation in bg1 (has create perm)
        Bundle bundle = createBundle(subject, TEST_PREFIX + ".bundle", bundleGroup1.getId());

        // allow delete, global perm
        addRolePermissions(role, Permission.DELETE_BUNDLES);
        deleteBundleVersion(subject, bundle);
View Full Code Here

        // add bg to the role with group create
        addRoleBundleGroup(role, bundleGroup);
        addRolePermissions(role, Permission.CREATE_BUNDLES_IN_GROUP);

        // allow bundle creation in bg (has create perm)
        Bundle b1 = createBundle(subject, "one", bundleGroup.getId());
        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(subject, b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull(platformResourceGroup);

        // deny destination create (no view of resource group)
View Full Code Here

        // add bg to the role with group create
        addRoleBundleGroup(role, bundleGroup);
        addRolePermissions(role, Permission.CREATE_BUNDLES_IN_GROUP);

        // allow bundle creation in bg (has create perm)
        Bundle b1 = createBundle(subject, "one", bundleGroup.getId());
        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(subject, b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull(platformResourceGroup);
        LookupUtil.getRoleManager().addResourceGroupsToRole(overlord, role.getId(),
            new int[] { platformResourceGroup.getId() });
View Full Code Here

        return createBundle(subject, name, bt, bundleGroupIds);
    }

    private Bundle createBundle(Subject subject, String name, BundleType bt, int[] bundleGroupIds) throws Exception {
        final String fullName = TEST_PREFIX + "-bundle-" + name;
        Bundle b = bundleManager.createBundle(subject, fullName, fullName + "-desc", bt.getId(), bundleGroupIds);

        assert b.getId() > 0;
        assert b.getName().endsWith(fullName);
        return b;
    }
View Full Code Here

        assertNotNull("Cannot create bundle. Unable to find resource type for [name: " + resourceTypeName
            + ", plugin: " + pluginName + "]", resourceType);

        BundleType bundleType = bundleMgr.getBundleType(subjectMgr.getOverlord(), bundleTypeName);
        assertNotNull("Cannot create bundle. Unable to find bundle type for [name: " + bundleTypeName + "]", bundleType);
        Bundle bundle = bundleMgr.createBundle(subjectMgr.getOverlord(), bundleName, "test bundle: " + bundleName,
            bundleType.getId(), null);

        assertNotNull("Failed create bundle for [name: " + bundleName + "]", bundle);
    }
View Full Code Here

        assert 1 == bv2.getVersionOrder();
    }

    @Test(enabled = TESTS_ENABLED)
    public void testDeleteBundle() throws Exception {
        Bundle b1 = createBundle("one");
        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        assertEquals("1.0", bv1.getVersion());
        BundleVersion bv2 = createBundleVersion(b1.getName() + "-2", null, b1);
        assertNotNull(bv2);
        assertEquals("1.1", bv2.getVersion());

        // let's add a bundle file so we can ensure our deletion will also delete the file too
        bundleManager.addBundleFileViaByteArray(overlord, bv2.getId(), "testDeleteBundle", "1.0", new Architecture(
            "noarch"), "content".getBytes());
        BundleFileCriteria bfCriteria = new BundleFileCriteria();
        bfCriteria.addFilterBundleVersionId(bv2.getId());
        bfCriteria.fetchPackageVersion(true);
        PageList<BundleFile> files = bundleManager.findBundleFilesByCriteria(overlord, bfCriteria);
        assert files.size() == 1 : files;
        assert files.get(0).getPackageVersion().getGeneralPackage().getName().equals("testDeleteBundle") : files;

        bundleManager.deleteBundle(overlord, b1.getId());

        BundleCriteria bCriteria = new BundleCriteria();
        bCriteria.addFilterId(b1.getId());
        PageList<Bundle> bResults = bundleManager.findBundlesByCriteria(overlord, bCriteria);
        assert bResults.size() == 0;
    }
View Full Code Here

        assert bResults.size() == 0;
    }

    @Test(enabled = TESTS_ENABLED)
    public void testDeleteBundleDeployment() throws Exception {
        Bundle b1 = createBundle("one");
        assertNotNull("Instance of newly created bundle should not be null", b1);
        BundleVersion bv1 = createBundleVersion(b1.getName() + "-1", null, b1);
        assertNotNull("Instance of newly created bundle version should not be null", bv1);

        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull("Instance of newly created resource group should not be null", platformResourceGroup);
        BundleDestination dest1 = createDestination(b1, "one", "/test", platformResourceGroup);
        assertNotNull("Instance of newly created bundle destination should not be null", dest1);

        BundleDeployment deployment1 = createDeployment("one", bv1, dest1,
            Configuration.builder().addSimple("bundletest.property", "bundletest.property value").build());
        assertNotNull("Instance of newly created bundle deployment should not be null", deployment1);
        getTransactionManager().begin();
        deployment1.setStatus(BundleDeploymentStatus.SUCCESS);
        em.merge(deployment1);
        getTransactionManager().commit();

        BundleDeployment deployment2 = createDeployment("two", bv1, dest1,
            Configuration.builder().addSimple("bundletest.property", "bundletest.property value").build());
        assertNotNull("Instance of newly created bundle deployment should not be null", deployment2);
        getTransactionManager().begin();
        deployment2.setStatus(BundleDeploymentStatus.SUCCESS);
        deployment2.setReplacedBundleDeploymentId(deployment1.getId());
        em.merge(deployment2);
        getTransactionManager().commit();

        BundleDeployment deployment3 = createDeployment("three", bv1, dest1,
            Configuration.builder().addSimple("bundletest.property", "bundletest.property value").build());
        assertNotNull("Instance of newly created bundle deployment should not be null", deployment3);
        getTransactionManager().begin();
        deployment3.setStatus(BundleDeploymentStatus.SUCCESS);
        deployment3.setReplacedBundleDeploymentId(deployment2.getId());
        em.merge(deployment3);
        getTransactionManager().commit();

        BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
        criteria.addFilterBundleId(b1.getId());
        List<BundleDeployment> deployments = bundleManager.findBundleDeploymentsByCriteria(
            subjectManager.getOverlord(), criteria);
        assertNotNull("List of bundle deployments should not be null", deployments);
        assertEquals(3, deployments.size());
View Full Code Here

        assertEquals("No bundle deployments should be found, all were deleted.", 0, deployments.size());
    }

    @Test(enabled = TESTS_ENABLED)
    public void testDeleteBundleVersion() throws Exception {
        Bundle b1 = createBundle("one");
        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        assertEquals("1.0", bv1.getVersion());
        BundleVersion bv2 = createBundleVersion(b1.getName() + "-2", null, b1);
        assertNotNull(bv2);
        assertEquals("1.1", bv2.getVersion());

        // let's add a bundle file so we can ensure our deletion will also delete the file too
        bundleManager.addBundleFileViaByteArray(overlord, bv2.getId(), "testDeleteBundleVersion", "1.0",
            new Architecture("noarch"), "content".getBytes());
        BundleFileCriteria bfCriteria = new BundleFileCriteria();
        bfCriteria.addFilterBundleVersionId(bv2.getId());
        bfCriteria.fetchPackageVersion(true);
        PageList<BundleFile> files = bundleManager.findBundleFilesByCriteria(overlord, bfCriteria);
        assert files.size() == 1 : files;
        assert files.get(0).getPackageVersion().getGeneralPackage().getName().equals("testDeleteBundleVersion") : files;

        BundleVersionCriteria bvCriteria = new BundleVersionCriteria();
        BundleCriteria bCriteria = new BundleCriteria();

        // delete the first one - this deletes the BV but the bundle should remain intact
        bundleManager.deleteBundleVersion(overlord, bv2.getId(), true);
        bvCriteria.addFilterId(bv2.getId());
        PageList<BundleVersion> bvResults = bundleManager.findBundleVersionsByCriteria(overlord, bvCriteria);
        assert bvResults.size() == 0;
        bCriteria.addFilterId(b1.getId());
        PageList<Bundle> bResults = bundleManager.findBundlesByCriteria(overlord, bCriteria);
        assert bResults.size() == 1 : "Should not have deleted bundle yet, 1 version still exists";

        // delete the second one - this deletes last BV thus the bundle should also get deleted
        bundleManager.deleteBundleVersion(overlord, bv1.getId(), true);
        bvCriteria.addFilterId(bv1.getId());
        bvResults = bundleManager.findBundleVersionsByCriteria(overlord, bvCriteria);
        assert bvResults.size() == 0;
        bCriteria.addFilterId(b1.getId());
        bResults = bundleManager.findBundlesByCriteria(overlord, bCriteria);
        assert bResults.size() == 0 : "Should have deleted bundle since no versions exists anymore";

        // make sure our composite query is OK and can show us 0 bundles, too
        PageList<BundleWithLatestVersionComposite> composites;
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.bundle.Bundle

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.