allowing(measurementDefinitionManager).findMeasurementDefinitionsByCriteria(with(any(Subject.class)), with(any(MeasurementDefinitionCriteria.class)));
will(returnValue(getFakeMeasurementDefinitions()));
}
});
MetricTemplateSynchronizer exporter = new MetricTemplateSynchronizer(measurementDefinitionManager, measurementScheduleManager);
Set<Synchronizer<?, ?>> exporters = new HashSet<Synchronizer<?, ?>>();
exporters.add(exporter);
InputStream eis = new ExportingInputStream(exporters, new HashMap<String, ExporterMessages>(), 65536, false);
// String exportContents = readAll(new InputStreamReader(eis, "UTF-8"));
//
// LOG.warn("Export contents:\n" + exportContents);
//
// eis = new ByteArrayInputStream(exportContents.getBytes("UTF-8"));
// <?xml version="1.0" ?>
// <configuration-export>
// <validator class="org.rhq.enterprise.server.sync.validators.DeployedAgentPluginsValidator">
// <plugin name="fakePlugin" hash="12345" version="1.0.0.test"></plugin>
// </validator>
// <entities id="org.rhq.enterprise.server.sync.exporters.MetricTemplatesExporter">
// <entity>
// <data>
// <metricTemplate referencedEntityId="1" enabled="false" defaultInterval="0" metricName="m1" resourceTypePlugin="fakePlugin" resourceTypeName="fakeType"></metricTemplate>
// </data>
// </entity>
// <entity>
// <data>
// <metricTemplate referencedEntityId="2" enabled="false" defaultInterval="0" metricName="m2" resourceTypePlugin="fakePlugin" resourceTypeName="fakeType"></metricTemplate>
// </data>
// </entity>
// <entity>
// <data>
// <metricTemplate referencedEntityId="3" enabled="false" defaultInterval="0" metricName="m3" resourceTypePlugin="fakePlugin" resourceTypeName="fakeType"></metricTemplate>
// </data>
// </entity>
// </entities>
// </configuration-export>
DocumentBuilder bld = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = bld.parse(eis);
Element root = doc.getDocumentElement();
List<Node> validators = getDirectChildrenByTagName(root, SynchronizationConstants.VALIDATOR_ELEMENT);
Set<ConsistencyValidator> declaredValidators = exporter.getRequiredValidators();
assertEquals(validators.size(), declaredValidators.size(), "Unexpected number of validators in the export xml");
for (Node v : validators) {
Element validator = (Element) v;