HTTPConfig extends Config { public void bean(Class<?> beanClass) { logger.info("register bean, class={}", beanClass.getCanonicalName()); if (beanClass.isEnum()) { context.beanClassValidator.beanClassNameValidator.validate(beanClass); JSONClassValidator.validateEnum(beanClass); } else { registerBean(beanClass); } boolean added = context.serviceRegistry.beanClasses.add(beanClass); if (!added) throw new Error("bean class is already registered, class=" + beanClass.getCanonicalName()); }  void route(HTTPMethod method, String path, Controller controller); void route(HTTPMethod method, String path, LambdaController controller); void bean(Class<?> beanClass); void intercept(Interceptor interceptor); void errorHandler(ErrorHandler handler); void httpPort(int port); void httpsPort(int port); LimitRateConfig limitRate(); void maxForwardedIPs(int maxIPs); AccessConfig access(); void gzip();  }
@Test void bean() { config.bean(TestBean.class); assertThat(config.context.serviceRegistry.beanClasses).contains(TestBean.class); config.bean(TestQueryParamBean.class); assertThat(config.context.serviceRegistry.beanClasses).contains(TestQueryParamBean.class); config.bean(TestEnum.class); assertThat(config.context.serviceRegistry.beanClasses).contains(TestEnum.class); assertThatThrownBy(() -> config.bean(TestBean.class)) .isInstanceOf(Error.class) .hasMessageContaining("bean class is already registered"); assertThatThrownBy(() -> config.bean(TestQueryParamBean.class)) .isInstanceOf(Error.class) .hasMessageContaining("bean class is already registered"); assertThatThrownBy(() -> config.bean(TestEnum.class)) .isInstanceOf(Error.class) .hasMessageContaining("bean class is already registered"); }