### Question:
ExtendedBeanDefinitionRegistryImpl implements ExtendedBeanDefinitionRegistry { @Override public Set<BeanDefinitionMetadata> getBeanDefinitionsForClass(Class<?> clazz) { Set<BeanDefinitionMetadata> result = new HashSet<>(); for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition beanDefinition = registry.getBeanDefinition(beanName); if (beanDefinition instanceof AbstractBeanDefinition) { Class<?> beanClass = BeanDefinitions.extractClass((AbstractBeanDefinition) beanDefinition); if (clazz.isAssignableFrom(beanClass)) { result.add(new ImmutableBeanDefinitionMetadata( this, beanName, beanClass, (AbstractBeanDefinition) beanDefinition, new BeanDefinitionModifier((AbstractBeanDefinition) beanDefinition))); } } } return result; } ExtendedBeanDefinitionRegistryImpl(BeanDefinitionRegistry registry); @Override Set<BeanDefinitionMetadata> getBeanDefinitionsForClass(Class<?> clazz); @Override void registerBeanDefinition(String beanName, BeanDefinition beanDefinition);  }### Answer:
@Test void list_bean_definitions_by_type() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ExtendedBeanDefinitionRegistryImplTest.TestConfiguration.class); ExtendedBeanDefinitionRegistry extendedRegistry = new ExtendedBeanDefinitionRegistryImpl(context); Set<ExtendedBeanDefinitionRegistry.BeanDefinitionMetadata> beanDefinitions = extendedRegistry.getBeanDefinitionsForClass(Stream.class); assertThat(beanDefinitions) .hasOnlyOneElementSatisfying(beanDefinitionMetadata -> { assertThat(beanDefinitionMetadata.name()).isEqualTo("testBean"); assertThat(beanDefinitionMetadata.beanClass()).isEqualTo(Stream.class); assertThat(beanDefinitionMetadata.beanDefinition()).isNotNull(); assertThat(beanDefinitionMetadata.beanDefinitionModifier()).isNotNull(); }); }
@Test void register_linked_bean_definition_delegates() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ExtendedBeanDefinitionRegistryImplTest.TestConfiguration.class); ExtendedBeanDefinitionRegistry extendedRegistry = new ExtendedBeanDefinitionRegistryImpl(context); Set<ExtendedBeanDefinitionRegistry.BeanDefinitionMetadata> beanDefinitions = extendedRegistry.getBeanDefinitionsForClass(Stream.class); assertThat(beanDefinitions).hasSize(1); ExtendedBeanDefinitionRegistry.BeanDefinitionMetadata metadata = beanDefinitions.iterator().next(); String linkedBeanName = metadata.registerLinkedBeanDefinition(String.class); AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) context.getBeanDefinition(linkedBeanName); assertThat(linkedBeanName).contains(metadata.name()); assertThat(beanDefinition.getBeanClassName()).isEqualTo(String.class.getName()); assertThat(beanDefinition.getQualifiers()).hasSize(1); AutowireCandidateQualifier qualifier = beanDefinition.getQualifiers().iterator().next(); assertThat(qualifier.getTypeName()).isEqualTo(Qualifier.class.getName()); assertThat(qualifier.getAttribute(AutowireCandidateQualifier.VALUE_KEY)).isEqualTo("testQ"); }