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();
}