static MetricRegistry getMetricRegistryFromCamelRegistry(Registry camelRegistry, String registryName) {
        MetricRegistry registry = camelRegistry.lookupByNameAndType(registryName, MetricRegistry.class);
        if (registry != null) {
            return registry;
        } else {
            Set<MetricRegistry> registries = camelRegistry.findByType(MetricRegistry.class);
            if (registries.size() == 1) {
                return registries.iterator().next();
            }
        }
        return null;
    }
@Test
    public void testGetMetricRegistryFromCamelRegistry() {
        when(camelRegistry.lookupByNameAndType("name", MetricRegistry.class)).thenReturn(metricRegistry);
        MetricRegistry result = MetricsComponent.getMetricRegistryFromCamelRegistry(camelRegistry, "name");
        assertThat(result, is(metricRegistry));
        inOrder.verify(camelRegistry, times(1)).lookupByNameAndType("name", MetricRegistry.class);
        inOrder.verifyNoMoreInteractions();
    }