AnnotatedBeanFactoryRegistry { static synchronized BeanFactoryId register(Class<?> clazz, Set<String> pathParams, List<RequestObjectResolver> objectResolvers) { final BeanFactoryId beanFactoryId = new BeanFactoryId(clazz, pathParams); if (!factories.containsKey(beanFactoryId)) { final AnnotatedBeanFactory<Object> factory = createFactory(beanFactoryId, objectResolvers); if (factory != null) { factories.put(beanFactoryId, factory); logger.debug("Registered a bean factory: {}", beanFactoryId); } else { factories.put(beanFactoryId, unsupportedBeanFactory); } } return beanFactoryId; } private  AnnotatedBeanFactoryRegistry();   }
@Test public void shouldFailToRegister() { assertThatThrownBy(() -> register(BadRequestBeanMoreThanOnConstructor01.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("too many annotated constructors"); assertThatThrownBy(() -> register(BadRequestBeanMoreThanOnConstructor02.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("too many annotated constructors"); assertThatThrownBy(() -> register(BadRequestBeanMoreThanOnConstructor03.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("too many annotated constructors"); assertThatThrownBy(() -> register(BadRequestBeanAnnotationInConstructorParam.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Both a method and parameter are annotated"); assertThatThrownBy(() -> register(BadRequestBeanAnnotationInMethodParam.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Both a method and parameter are annotated"); assertThatThrownBy(() -> register(BadRequestBeanMoreThanOneConstructorParam.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Only one parameter is allowed to an annotated method"); assertThatThrownBy(() -> register(BadRequestBeanMoreThanOneMethodParam.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Only one parameter is allowed to an annotated method"); assertThatThrownBy( () -> register(BadRequestBeanSomeConstructorParamWithoutAnnotation.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Unsupported parameter exists"); assertThatThrownBy( () -> register(BadRequestBeanSomeMethodParamWithoutAnnotation.class, vars, resolvers)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Unsupported parameter exists"); }