Package org.rhq.core.domain.event

Examples of org.rhq.core.domain.event.EventDefinition


                    resourceType.addMetricDefinition(def);
                }
            }

            for (EventDescriptor eventDescriptor : resourceDescriptor.getEvent()) {
                EventDefinition eventDefinition = EventsMetadataParser.parseEventsMetadata(eventDescriptor,
                    resourceType);
                resourceType.addEventDefinition(eventDefinition);
            }

            for (OperationDescriptor operationDescriptor : resourceDescriptor.getOperation()) {
View Full Code Here


*
* @author Ian Springer
*/
public class EventsMetadataParser {
    public static EventDefinition parseEventsMetadata(EventDescriptor eventDescriptor, ResourceType resourceType) {
        EventDefinition eventDefinition = new EventDefinition(resourceType, eventDescriptor.getName());
        if (eventDescriptor.getDisplayName() != null) {
            eventDefinition.setDisplayName(eventDescriptor.getDisplayName());
        } else {
            eventDefinition.setDisplayName(StringUtils.deCamelCase(eventDescriptor.getName()));
        }
        eventDefinition.setDescription(eventDescriptor.getDescription());
        return eventDefinition;
    }
View Full Code Here

        Resource res = resources.get(0);
        if (!(res.getResourceType().getCategory() == ResourceCategory.PLATFORM))
            res = resourceManager.getPlaformOfResource(overlord, res.getId());
        ResourceType type = res.getResourceType();

        EventDefinition def;
        Set<EventDefinition> eventDefs = type.getEventDefinitions();
        if (eventDefs != null && !eventDefs.isEmpty()) {
            def = eventDefs.iterator().next();
        } else {
            throw new RuntimeException("No event definition found, should not happen");
View Full Code Here

            platform = em.find(ResourceType.class, platform.getId());

            Set<EventDefinition> eDefs = platform.getEventDefinitions();
            assert eDefs != null;
            assert eDefs.size() == 1;
            EventDefinition hugo = eDefs.iterator().next();
            assert hugo.getDescription().equals("One");
            assert hugo.getDisplayName().equals("HugoOne");
            getTransactionManager().rollback();

            System.out.println("==> Done with v1");

            registerPlugin("event1-2.xml");
            platform = getResourceType("events");
            getTransactionManager().begin();
            em = getEntityManager();
            platform = em.find(ResourceType.class, platform.getId());

            eDefs = platform.getEventDefinitions();
            assert eDefs != null;
            assert eDefs.size() == 2 : "Did not find 2 EventDefinitions, but " + eDefs.size();
            Iterator<EventDefinition> eIter = eDefs.iterator();
            while (eIter.hasNext()) {
                EventDefinition def = eIter.next();
                if (def.getName().equals("hugo")) {
                    assert def.getDescription().equals("Two") : "Expected 'Two', but got : " + def.getDescription();
                    assert def.getDisplayName().equals("HugoTwo");
                }
            }
            getTransactionManager().rollback();

            System.out.println("==> Done with v2");
View Full Code Here

            platform = em.find(ResourceType.class, platform.getId());

            Set<EventDefinition> eDefs = platform.getEventDefinitions();
            assert eDefs != null;
            assert eDefs.size() == 1;
            EventDefinition hugo = eDefs.iterator().next();
            assert hugo.getDescription().equals("One");
            assert hugo.getDisplayName().equals("HugoOne");
            getTransactionManager().rollback();

            System.out.println("==> Done with v1");

            registerPlugin("event1-1.xml", "2.0");
            platform = getResourceType("events");
            assert platform != null;
            getTransactionManager().begin();
            em = getEntityManager();
            platform = em.find(ResourceType.class, platform.getId());

            eDefs = platform.getEventDefinitions();
            assert eDefs != null;
            assert eDefs.size() == 1;
            hugo = eDefs.iterator().next();
            assert hugo.getDescription().equals("One");
            assert hugo.getDisplayName().equals("HugoOne");

            System.out.println("==> Done with v2");
        } finally {
            if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
                getTransactionManager().rollback();
View Full Code Here

            assert eDefs.size() == 2 : "Did not find the expected 2 eventDefinitions, but " + eDefs.size();
            Iterator<EventDefinition> eIter = eDefs.iterator();
            boolean found = false;
            Map<EventSource, Set<Event>> events = new HashMap<EventSource, Set<Event>>(1);
            while (eIter.hasNext()) {
                EventDefinition def = eIter.next();
                if (def.getName().equals("hans")) {
                    found = true;
                    // We got the definition that will vanish later, so attach some stuff to it
                    EventSource source = new EventSource("test location", def, testResource);
                    em.persist(source);

                    Event ev = new Event(def.getName(), source.getLocation(), System.currentTimeMillis(),
                        EventSeverity.INFO, "This is a test");
                    Set<Event> evSet = new HashSet<Event>(1);
                    evSet.add(ev);
                    events.put(source, evSet);
                }
            }
            assert found : "Hans was not found";
            getTransactionManager().commit();
            eventManager.addEventData(events);

            /*
             * --- done with the setup ---
             * Now check that the event source + events are gone.
             */
            registerPlugin("event1-1.xml", "3.0");
            platform = getResourceType("events");
            getTransactionManager().begin();
            platform = em.find(ResourceType.class, platform.getId());

            eDefs = platform.getEventDefinitions();
            assert eDefs != null;
            assert eDefs.size() == 1 : "Did not find 1 EventDefinition, but " + eDefs.size();
            EventDefinition hugo = eDefs.iterator().next();
            assert hugo.getDescription().equals("One");
            assert hugo.getDisplayName().equals("HugoOne");

        } finally {
            if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
                getTransactionManager().rollback();
            }
View Full Code Here

                                          EventSourceRest esr) {

        Resource resource = fetchResource(resourceId);
        ResourceType rt = resource.getResourceType();
        Set<EventDefinition> eventDefinitions = rt.getEventDefinitions();
        EventDefinition eventDefinition=null;
        for (EventDefinition ed : eventDefinitions) {
            if (ed.getName().equals(esr.getName())) {
                eventDefinition = ed;
                break;
            }
View Full Code Here

            asList("event1", "event2"));
    }

    @Test(groups = { "plugin.metadata", "Events.NewPlugin" }, dependsOnMethods = { "persistNewEventDefs" })
    public void persistNewEventDefProperties() {
        EventDefinition eventDef = loadEventDef("event1", "EventServer1");

        assertEquals("Failed to set EventDefinition.name", "event1", eventDef.getName());
        assertEquals("Failed to set EventDefinition.description", "Event 1", eventDef.getDescription());
    }
View Full Code Here

    @Test(groups = { "plugin.metadata", "Events.UpgradePlugin" }, dependsOnMethods = { "upgradeEventsPlugin" })
    public void updateExistingEventDefs() throws Exception {
        assertResourceTypeAssociationEquals("EventServer4", "EventMetadataManagerBeanTestPlugin", "eventDefinitions",
            asList("event1", "event3"));

        EventDefinition eventDef = loadEventDef("event1", "EventServer4");
        assertEquals("The description property should have been updated", "EVENT ONE", eventDef.getDescription());
    }
View Full Code Here

        PropertyGroupDefinition group;
        PropertyDefinition prop;
        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);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.event.EventDefinition

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.