Package org.rhq.core.domain.drift.DriftDefinition

Examples of org.rhq.core.domain.drift.DriftDefinition.BaseDirectory


        ProcessScan processScan;
        OperationDefinition op;
        MeasurementDefinition metric;
        EventDefinition event;
        DriftDefinitionTemplate drift;
        BaseDirectory driftBasedir;
        ResourceTypeBundleConfiguration bundle;
        BundleDestinationBaseDirectory bundleBasedir;

        assert resourceType.getChildSubCategories() == null;

        assert resourceType.getPluginConfigurationDefinition().getGroupDefinitions().size() == 1;
        group = resourceType.getPluginConfigurationDefinition().getGroupDefinitions().get(0);
        assert group.getName().equals(PC_GROUP);
        assert group.isDefaultHidden() == PC_GROUP_HIDDEN;
        prop = resourceType.getPluginConfigurationDefinition().get(PC_PROP);
        assert prop != null;
        assert prop.getName().equals(PC_PROP);
        assert prop.isRequired() == PC_PROP_REQUIRED;
        assert prop.getPropertyGroupDefinition().getName().equals(PC_GROUP);

        assert resourceType.getProcessScans().size() == 1;
        processScan = resourceType.getProcessScans().iterator().next();
        assert processScan.getName().equals(PROCESS_SCAN_NAME);
        assert processScan.getQuery().equals(PROCESS_SCAN_QUERY);

        assert resourceType.getOperationDefinitions().size() == 1;
        op = resourceType.getOperationDefinitions().iterator().next();
        assert op.getName().equals(OP_NAME);
        assert op.getTimeout().intValue() == OP_TIMEOUT;
        assert op.getDescription().equals(OP_DESC);

        assert resourceType.getMetricDefinitions().size() == 2; // include built-in Availability metric
        metric = resourceType.getMetricDefinitions().iterator().next();
        assert metric.getName().equals(METRIC_PROP);
        assert metric.getDefaultInterval() == METRIC_DEFAULT_INTERVAL;

        assert resourceType.getEventDefinitions().size() == 1;
        event = resourceType.getEventDefinitions().iterator().next();
        assert event.getName().equals(EVENT_NAME);
        assert event.getDescription().equals(EVENT_DESC);

        assert resourceType.getResourceConfigurationDefinition().getGroupDefinitions().size() == 0;
        prop = resourceType.getResourceConfigurationDefinition().get(RC_PROP);
        assert prop != null;
        assert prop.getName().equals(RC_PROP);
        assert prop.isRequired() == RC_PROP_REQUIRED;

        assert resourceType.getDriftDefinitionTemplates().size() == 1;
        drift = resourceType.getDriftDefinitionTemplates().iterator().next();
        assert drift.getTemplateDefinition().getName().equals(DRIFT_DEF_NAME);
        driftBasedir = drift.getTemplateDefinition().getBasedir();
        assert driftBasedir.getValueContext().equals(DRIFT_DEF_BASEDIR_CONTEXT);
        assert driftBasedir.getValueName().equals(DRIFT_DEF_BASEDIR_VALUE);

        bundle = resourceType.getResourceTypeBundleConfiguration();
        assert bundle.getBundleDestinationBaseDirectories().size() == 1;
        bundleBasedir = bundle.getBundleDestinationBaseDirectories().iterator().next();
        assert bundleBasedir.getName().equals(BUNDLE_TARGET_NAME);
View Full Code Here


        assert resourceType.getDriftDefinitionTemplates().size() == 2;
        for (DriftDefinitionTemplate drift : resourceType.getDriftDefinitionTemplates()) {
            DriftDefinition def = drift.getTemplateDefinition();
            seen.add(def.getName());
            if (def.getName().equals(CHANGED_DRIFT_DEF_NAME)) {
                BaseDirectory driftBasedir = def.getBasedir();
                assert driftBasedir.getValueContext().equals(CHANGED_DRIFT_DEF_BASEDIR_CONTEXT);
                assert driftBasedir.getValueName().equals(CHANGED_DRIFT_DEF_BASEDIR_VALUE);
            } else if (def.getName().equals(NEW_DRIFT_DEF_NAME)) {
                BaseDirectory driftBasedir = def.getBasedir();
                assert driftBasedir.getValueContext().equals(NEW_DRIFT_DEF_BASEDIR_CONTEXT);
                assert driftBasedir.getValueName().equals(NEW_DRIFT_DEF_BASEDIR_VALUE);
            } else {
                assert false : "Unexpected drift def [" + def.getName() + "]:" + def;
            }
        }
        if (seen.size() != 2) {
View Full Code Here

    public void testDriftDef() throws Exception {
        Configuration config = new Configuration();
        DriftDefinition driftDefPojo = new DriftDefinition(config);
        driftDefPojo.setName("testDriftDef");
        driftDefPojo.setInterval(60L);
        driftDefPojo.setBasedir(new BaseDirectory(BaseDirValueContext.fileSystem, "foo/bar"));

        driftManager.updateDriftDefinition(overlord, EntityContext.forResource(newResource.getId()), driftDefPojo);

        DriftDefinitionCriteria c = new DriftDefinitionCriteria();
        c.addFilterResourceIds(newResource.getId());
        c.fetchConfiguration(true);
        List<DriftDefinition> driftDefs = driftManager.findDriftDefinitionsByCriteria(overlord, c);
        assertNotNull(driftDefs);
        assertEquals(3, driftDefs.size());
        DriftDefinition driftDef = null;
        for (Iterator<DriftDefinition> i = driftDefs.iterator(); i.hasNext();) {
            driftDef = i.next();
            if (driftDefPojo.getName().equals(driftDef.getName()))
                break;
        }
        assertTrue(driftDef.getConfiguration().getId() > 0); // persisted
        assertEquals(driftDefPojo.getName(), driftDef.getName());
        assertEquals(driftDefPojo.getBasedir(), driftDef.getBasedir());
        assertEquals(driftDefPojo.getInterval(), driftDef.getInterval());

        driftDefPojo.setInterval(120L);
        driftManager.updateDriftDefinition(overlord, EntityContext.forResource(newResource.getId()), driftDefPojo);

        driftDefs = driftManager.findDriftDefinitionsByCriteria(overlord, c);
        assertNotNull(driftDefs);
        assertEquals(3, driftDefs.size());
        driftDef = null;
        for (Iterator<DriftDefinition> i = driftDefs.iterator(); i.hasNext();) {
            driftDef = i.next();
            if (driftDefPojo.getName().equals(driftDef.getName()))
                break;
        }
        assertEquals(driftDefPojo.getName(), driftDef.getName());
        assertTrue(driftDef.getConfiguration().getId() > 0); // persisted
        assertEquals(driftDefPojo.getBasedir(), driftDef.getBasedir());
        assertEquals(120L, driftDef.getInterval());

        driftDefPojo = new DriftDefinition(driftDef.getConfiguration().deepCopyWithoutProxies());
        driftDefPojo.setName("testDriftDef-2");
        driftDefPojo.setInterval(30L);
        driftDefPojo.setBasedir(new BaseDirectory(BaseDirValueContext.fileSystem, "foo/baz"));

        driftManager.updateDriftDefinition(overlord, EntityContext.forResource(newResource.getId()), driftDefPojo);

        driftDefs = driftManager.findDriftDefinitionsByCriteria(overlord, c);
        assertNotNull(driftDefs);
View Full Code Here

                DriftDefinitionTemplate template = new DriftDefinitionTemplate();
                template.setName("drift1");
                template.setDescription("drift def template");
                Configuration config = new Configuration();
                DriftDefinition driftDef = new DriftDefinition(config);
                driftDef.setBasedir(new BaseDirectory(BaseDirValueContext.fileSystem, "/"));
                driftDef.setName("drift1");
                template.setTemplateDefinition(driftDef);
                resourceType.addDriftDefinitionTemplate(template);
            }
        };
        ResourceCreator rCreator = new ResourceCreator() {
            public void modifyResourceToPersist(Resource resource) {
                Configuration config = new Configuration();
                DriftDefinition driftDef = new DriftDefinition(config);
                driftDef.setBasedir(new BaseDirectory(BaseDirValueContext.fileSystem, "/boo"));
                driftDef.setName("drift-def-name");
                resource.addDriftDefinition(driftDef);
            }
        };
View Full Code Here

    public static void validateDriftDefinition(DriftDefinition driftDef) {
        if (!driftDef.getName().matches(DriftConfigurationDefinition.PROP_NAME_REGEX_PATTERN)) {
            throw new IllegalArgumentException("Drift definition name contains invalid characters: "
                + driftDef.getName());
        }
        BaseDirectory baseDir = driftDef.getBasedir();
        if (null == baseDir
            || !baseDir.getValueName().matches(DriftConfigurationDefinition.PROP_BASEDIR_PATH_REGEX_PATTERN)) {
            throw new IllegalArgumentException(
                "Drift definition base directory is null or contains invalid characters: " + baseDir);
        }
        List<List<Filter>> filtersList = new ArrayList<List<Filter>>(2);
        filtersList.add(driftDef.getIncludes());
View Full Code Here

        verifyDriftDefinition(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
            @Override
            public void assertDriftTemplate(DriftDefinitionTemplate driftTemplate) throws Exception {
                DriftDefinition dc = new DriftDefinition(driftTemplate.getConfiguration());
                BaseDirectory basedir = dc.getBasedir();
                assertEquals(basedir.getValueContext(), BaseDirValueContext.pluginConfiguration, "Bad value context");
                assertEquals(basedir.getValueName(), "var.lib.test1", "Bad value name");
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.drift.DriftDefinition.BaseDirectory

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.