Examples of MetricTemplateImporter


Examples of org.rhq.enterprise.server.sync.importers.MetricTemplateImporter

                one(msm).updateDefaultCollectionIntervalAndEnablementForMeasurementDefinitions(with(any(Subject.class)),
                    with(new int[] { 1 }), with(1000L), with(true), with(false));
            }
        });

        MetricTemplateImporter importer =
            new MetricTemplateImporter(null, prereqs.getEntityManager(), prereqs.getMeasurementScheduleManager());

        MetricTemplate nonMatching = new MetricTemplate();
        nonMatching.setResourceTypeName("asf");
        nonMatching.setResourceTypePlugin("asfd");
        nonMatching.setMetricName("asf");
       
        MetricTemplate matching = new MetricTemplate(def);

        importer.configure(null);

        ExportedEntityMatcher<MeasurementDefinition, MetricTemplate> matcher = importer.getExportedEntityMatcher();

        assertNull(matcher.findMatch(nonMatching), "The non-matching metric template shouldn't have been matched.");
        assertSame(matcher.findMatch(matching), def,
            "The matching metric template should have found the defined measurement definition");

        //this is the "meat" of the test..
        //we call update() twice but only get 1 actual change pour down to database
        //and the importer not choking on this.
        importer.update(null, nonMatching);
        importer.update(def, matching);

        //this should invoke the mocked measurement schedule manager and the expectations should check it gets called
        //correctly by the importer.
        importer.finishImport();
    }
View Full Code Here

Examples of org.rhq.enterprise.server.sync.importers.MetricTemplateImporter

                one(msm).updateDefaultCollectionIntervalAndEnablementForMeasurementDefinitions(with(any(Subject.class)),
                    with(new int[] { 2 }), with(2000L), with(false), with(false));
            }
        });

        MetricTemplateImporter importer =
            new MetricTemplateImporter(null, prereqs.getEntityManager(), prereqs.getMeasurementScheduleManager());

        importer.configure(null);

        ExportedEntityMatcher<MeasurementDefinition, MetricTemplate> matcher = importer.getExportedEntityMatcher();

        MetricTemplate match1 = new MetricTemplate(defToEnable);
        MetricTemplate match2 = new MetricTemplate(defToDisable);

        assertSame(matcher.findMatch(match1), defToEnable,
            "The matching metric template should have found the defined measurement definition");
        assertSame(matcher.findMatch(match2), defToDisable,
            "The matching metric template should have found the defined measurement definition");

        importer.update(defToEnable, match1);
        importer.update(defToDisable, match2);

        //this should invoke the mocked measurement schedule manager and the expectations should check it gets called
        //correctly by the importer.
        importer.finishImport();

    }
View Full Code Here

Examples of org.rhq.enterprise.server.sync.importers.MetricTemplateImporter

                one(msm).updateDefaultCollectionIntervalAndEnablementForMeasurementDefinitions(with(any(Subject.class)),
                    with(new int[] { 1 }), with(1000L), with(true), with(true));
            }
        });

        MetricTemplateImporter importer =
            new MetricTemplateImporter(null, prereqs.getEntityManager(), prereqs.getMeasurementScheduleManager());

        Configuration importConfig = new Configuration();
        importConfig.put(new PropertySimple(MetricTemplateImporter.UPDATE_ALL_SCHEDULES_PROPERTY, true));

        importer.configure(importConfig);

        ExportedEntityMatcher<MeasurementDefinition, MetricTemplate> matcher = importer.getExportedEntityMatcher();

        MetricTemplate template = new MetricTemplate(def);

        assertSame(matcher.findMatch(template), def,
            "The matching metric template should have found the defined measurement definition");

        importer.update(def, template);

        //this should invoke the mocked measurement schedule manager and the expectations should check it gets called
        //correctly by the importer.
        importer.finishImport();
    }
View Full Code Here

Examples of org.rhq.enterprise.server.sync.importers.MetricTemplateImporter

                one(msm).updateDefaultCollectionIntervalAndEnablementForMeasurementDefinitions(with(any(Subject.class)),
                    with(new int[] { 2 }), with(2000L), with(true), with(false));
            }
        });

        MetricTemplateImporter importer =
            new MetricTemplateImporter(null, prereqs.getEntityManager(), prereqs.getMeasurementScheduleManager());

        Configuration importConfig = new Configuration();

        //this is the default, but let's be specific here so that this doesn't start failing if we change the
        //default in the future.
        importConfig.put(new PropertySimple(MetricTemplateImporter.UPDATE_ALL_SCHEDULES_PROPERTY, false));

        //set the def to update the schedules anyway
        PropertyList list = new PropertyList(MetricTemplateImporter.METRIC_UPDATE_OVERRIDES_PROPERTY);
        importConfig.put(list);
        PropertyMap map = new PropertyMap(MetricTemplateImporter.METRIC_UPDATE_OVERRIDE_PROPERTY);
        list.add(map);
        map.put(new PropertySimple(MetricTemplateImporter.METRIC_NAME_PROPERTY, "def"));
        map.put(new PropertySimple(MetricTemplateImporter.RESOURCE_TYPE_NAME_PROPERTY, FAKE_RESOURCE_TYPE.getName()));
        map.put(new PropertySimple(MetricTemplateImporter.RESOURCE_TYPE_PLUGIN_PROPERTY, FAKE_RESOURCE_TYPE.getPlugin()));
        map.put(new PropertySimple(MetricTemplateImporter.UPDATE_SCHEDULES_PROPERTY, true));

        importer.configure(importConfig);

        ExportedEntityMatcher<MeasurementDefinition, MetricTemplate> matcher = importer.getExportedEntityMatcher();

        MetricTemplate template1 = new MetricTemplate(updatedDef);
        MetricTemplate template2 = new MetricTemplate(notUpdatedDef);

        assertSame(matcher.findMatch(template1), updatedDef,
            "The matching metric template should have found the defined measurement definition");
        assertSame(matcher.findMatch(template2), notUpdatedDef,
            "The matching metric template should have found the defined measurement definition");

        importer.update(updatedDef, template1);
        importer.update(notUpdatedDef, template2);

        //this should invoke the mocked measurement schedule manager and the expectations should check it gets called
        //correctly by the importer.
        importer.finishImport();
    }
View Full Code Here

Examples of org.rhq.enterprise.server.sync.importers.MetricTemplateImporter

                one(msm).updateDefaultCollectionIntervalAndEnablementForMeasurementDefinitions(with(any(Subject.class)),
                    with(new int[] { 2 }), with(2000L), with(false), with(false));
            }
        });

        MetricTemplateImporter importer =
            new MetricTemplateImporter(null, prereqs.getEntityManager(), prereqs.getMeasurementScheduleManager());

        importer.configure(null);

        ExportedEntityMatcher<MeasurementDefinition, MetricTemplate> matcher = importer.getExportedEntityMatcher();

        MetricTemplate template1 = new MetricTemplate(normalDef);
        MetricTemplate template2 = new MetricTemplate(perMinuteDef);

        assertSame(matcher.findMatch(template1), normalDef,
            "The matching metric template should have found the defined measurement definition");
        assertSame(matcher.findMatch(template2), perMinuteDef,
            "The matching metric template should have found the defined measurement definition");

        importer.update(normalDef, template1);
        importer.update(perMinuteDef, template2);

        //this should invoke the mocked measurement schedule manager and the expectations should check it gets called
        //correctly by the importer.
        importer.finishImport();
    }
View Full Code Here

Examples of org.rhq.enterprise.server.sync.importers.MetricTemplateImporter

            {
                prereqs.addExpectations(this);
            }
        });

        MetricTemplateImporter importer =
            new MetricTemplateImporter(null, prereqs.getEntityManager(), prereqs.getMeasurementScheduleManager());

        importer.configure(null);

        importer.configure(null);

        MetricTemplate unmatched = new MetricTemplate();
        unmatched.setMetricName("made-up");
        unmatched.setResourceTypeName("made-up");
        unmatched.setResourceTypePlugin("made-up");

        ExportedEntityMatcher<MeasurementDefinition, MetricTemplate> matcher = importer.getExportedEntityMatcher();

        assertNull(matcher.findMatch(unmatched));

        importer.update(null, unmatched);

        String notes = importer.finishImport();

        String expectedNotes =
            MetricTemplateImporter.getUnmatchedMetricTemplatesReport(Collections.singleton(unmatched));

        assertEquals(notes, expectedNotes);
View Full Code Here

Examples of org.rhq.enterprise.server.sync.importers.MetricTemplateImporter

        return new MetricTemplateExporter(subject, measurementDefinitionManager);
    }

    @Override
    public Importer<MeasurementDefinition, MetricTemplate> getImporter() {
        return new MetricTemplateImporter(subject, entityManager, measurementScheduleManager);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.