Package org.rhq.core.domain.measurement

Examples of org.rhq.core.domain.measurement.MeasurementDefinition


        platform2 = new Resource("platform2", "testProblemResources Platform Two", platformType);
        platform2.setUuid("" + new Random().nextInt());
        platform2.setInventoryStatus(InventoryStatus.COMMITTED);
        em.persist(platform2);

        measDef = new MeasurementDefinition(platformType, "testProblemResourcesMeasurement");
        measDef.setDefaultOn(true);
        measDef.setDisplayName("testProblemResources Measurement Display Name");
        measDef.setMeasurementType(NumericType.DYNAMIC);
        em.persist(measDef);
View Full Code Here


             */

            ResourceType resourceType = new ResourceType("fake platform", "fake plugin", ResourceCategory.PLATFORM,
                null);
            getEntityManager().persist(resourceType);
            MeasurementDefinition md = new MeasurementDefinition(resourceType, "Heiko");
            md.setDefaultOn(true);
            getEntityManager().persist(md);
            getEntityManager().flush();
        } finally {
            getTransactionManager().rollback();
        }
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testNewSchedule() throws Exception {
        getTransactionManager().begin();
        try {
            EntityManager em = getEntityManager();
            MeasurementDefinition def = setupTables(em);
            int id = def.getId();

            MeasurementDefinition d = em.find(MeasurementDefinition.class, id);
            assert d != null : "Did not find the definition previously persisted";

            assert d.isDefaultOn();

            assert d.getSchedules() != null;

            MeasurementSchedule ms = d.getSchedules().get(0);
            assert ms != null;

            assert ms.isEnabled();

            assert ms.getBaseline() != null;
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testUpdateBaseline() throws Exception {
        getTransactionManager().begin();
        try {
            EntityManager em = getEntityManager();
            MeasurementDefinition def = setupTables(em);
            int id = def.getId();

            MeasurementDefinition md = em.find(MeasurementDefinition.class, id);
            List<MeasurementSchedule> schedules = md.getSchedules();
            MeasurementSchedule sch = schedules.get(0);
            MeasurementBaseline mb = sch.getBaseline();
            mb.setMax(3D);
            em.flush();
        } finally {
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testScheduleUpdates() throws Exception {
        getTransactionManager().begin();
        EntityManager em = getEntityManager();
        try {
            MeasurementDefinition def = setupTables(em);
            Query q = em.createQuery("SELECT ms FROM MeasurementSchedule ms WHERE ms.definition = :def");
            q.setParameter("def", def);
            List<MeasurementSchedule> scheds = q.getResultList();

            assert scheds.size() == 2;
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testFindScheduleByResourceAndDefinition() throws Exception {
        getTransactionManager().begin();
        EntityManager em = getEntityManager();
        try {
            MeasurementDefinition def = setupTables(em);
            List<MeasurementSchedule> schedules = def.getSchedules();
            MeasurementSchedule sched = schedules.get(0);
            Resource res = sched.getResource();

            Query q = em.createNamedQuery(MeasurementSchedule.FIND_BY_RESOURCE_IDS_AND_DEFINITION_IDS);
            q.setParameter("definitionIds", ArrayUtils.wrapInList(new int[] { def.getId() }));
            q.setParameter("resourceIds", ArrayUtils.wrapInList(new int[] { res.getId() }));
            List<MeasurementSchedule> scheds = q.getResultList();

            assert scheds.size() == 1 : "Did not find 1 schedule, but " + scheds.size();

            int rid = res.getId();
            q = em.createNamedQuery(MeasurementSchedule.FIND_BY_RESOURCE_IDS_AND_DEFINITION_IDS);
            q.setParameter("definitionIds", ArrayUtils.wrapInList(new int[] { def.getId() }));
            q.setParameter("resourceIds", ArrayUtils.wrapInList(new int[] { rid, rid, rid, rid }));
            scheds = q.getResultList();

            assert scheds.size() == 1 : "Did not find 1 schedule, but " + scheds.size();
        } finally {
View Full Code Here

    @Test(groups = "integration.ejb3")
    public void testAddAvailability() throws Exception {
        getTransactionManager().begin();
        EntityManager em = getEntityManager();
        try {
            MeasurementDefinition def = setupTables(em);

            Resource res = def.getSchedules().get(0).getResource();

            List<Availability> avails = res.getAvailability();
            assert avails != null : "should have initial avail";
            assert avails.size() == 1 : "should have initial avail";
            Availability initialAvail = avails.get(0);
View Full Code Here

    public void testTraitQuery() throws Exception {
        System.out.println("testTraitQuery ...");
        getTransactionManager().begin();
        EntityManager em = getEntityManager();
        try {
            MeasurementDefinition def = setupTables(em);
            MeasurementSchedule sched = def.getSchedules().get(0);
            Resource resource = sched.getResource();
            int resourceId = resource.getId();

            MeasurementDataPK pk = new MeasurementDataPK(sched.getId());
            MeasurementDataTrait mdt = new MeasurementDataTrait(pk, "Hello World");
View Full Code Here

        em.persist(platform);
        Resource platform2 = new Resource("org.jboss.on.TestPlatform2", "Fake Platform2", resourceType);
        platform2.setUuid("" + new Random().nextInt());
        em.persist(platform2);

        MeasurementDefinition md = new MeasurementDefinition(resourceType, "Heiko");
        md.setDefaultOn(true);
        md.setDisplayName("Fake display name");
        md.setMeasurementType(NumericType.DYNAMIC);
        MeasurementSchedule sched = new MeasurementSchedule(md, platform);
        sched.setEnabled(true);
        MeasurementSchedule sched2 = new MeasurementSchedule(md, platform2);

        platform.addSchedule(sched);
        platform2.addSchedule(sched2);

        md.getSchedules().add(sched);
        md.getSchedules().add(sched2);
        em.persist(md);
        em.persist(sched);
        em.persist(sched2);

        em.flush();

        int id = md.getId();

        assert id != 0 : "id of MeasurementDefinition is 0, but should not be";

        em.persist(sched);
        MeasurementBaseline bl = new MeasurementBaseline();
View Full Code Here

        return executeInTransaction(false, new TransactionCallbackReturnable<MeasurementSchedule>() {
            @Override
            public MeasurementSchedule execute() throws Exception {
                EntityManager em = getEntityManager();

                MeasurementDefinition definition = new MeasurementDefinition(resourceType, DYNAMIC_DEF_NAME
                    + measurementDefs.size());
                definition.setDefaultOn(true);
                definition.setDataType(MEASUREMENT);
                definition.setMeasurementType(DYNAMIC);
                em.persist(definition);

                MeasurementSchedule schedule = new MeasurementSchedule(definition, resource);
                schedule.setEnabled(true);
                resource.addSchedule(schedule);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.measurement.MeasurementDefinition

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.