### Question:
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { <F extends CEKHandleConditionMatcherFactory<M, A>, M extends CEKHandleConditionMatcher, A extends Annotation> M createHandleConditionMatcher(Class<F> factoryType, Collection<A> annotations) { F factory; try { factory = beanFactory.getBean(factoryType); } catch (NoSuchBeanDefinitionException e) { factory = BeanUtils.instantiateClass(factoryType); } return factory.create(annotations); }  @Override void afterPropertiesSet();  }### Answer:
@Test @SuppressWarnings("unchecked") public void createHandleConditionMatcher_Method_SingletonFactory() throws Exception { Set<DummyCondition> annotations = AnnotationUtils.getRepeatableAnnotations( TestHandler.getTestMethod(), DummyCondition.class); DummyConditionMatcher matcher = cekRequestMappingHandlerMapping.createHandleConditionMatcher( DummyConditionMatcherFactory.class, annotations); assertThat(matcher.getAnnotations()).isSameAs(annotations); DummyBean dummyBean = (DummyBean) ReflectionTestUtils.getField(matcher, "dummyBean"); assertThat(dummyBean).isSameAs(this.dummyBean); }
@Test @SuppressWarnings("unchecked") public void createHandleConditionMatcher_BeanType_NonSingleton() throws Exception { Set<ExtensionIdCondition> annotations = AnnotationUtils.getRepeatableAnnotations( TestHandler.class, ExtensionIdCondition.class); ExtensionIdConditionMatcher matcher = cekRequestMappingHandlerMapping.createHandleConditionMatcher( ExtensionIdConditionMatcherFactory.class, annotations); Collection<String> extensionIds = (Collection<String>) ReflectionTestUtils.getField(matcher, "extensionIds"); assertThat(extensionIds).containsOnlyOnce("foo"); }