WebServiceInterfaceValidator { void validateRequestBeanClass(Class<?> beanClass, Method method) { boolean isValueType = isValueType(beanClass); if (isValueType) throw new Error(format("request bean type must be bean class, if it is path param, please add @PathParam, type={}, method={}", beanClass.getCanonicalName(), Methods.path(method))); } WebServiceInterfaceValidator(Class<?> serviceInterface, BeanClassValidator validator); void validate(); public RequestBeanReader requestBeanReader; public RequestBeanWriter requestBeanWriter; public ResponseBeanReader responseBeanReader; public ResponseBeanWriter responseBeanWriter; }
@Test void validateRequestBeanClass() throws NoSuchMethodException { var validator = new WebServiceInterfaceValidator(TestWebService.class, new BeanClassValidator()); var method = TestWebService.class.getDeclaredMethod("get", Integer.class); assertThatThrownBy(() -> validator.validateRequestBeanClass(Integer.class, method)) .isInstanceOf(Error.class).hasMessageContaining("if it is path param, please add @PathParam"); assertThatThrownBy(() -> validator.validateRequestBeanClass(TestEnum.class, method)) .isInstanceOf(Error.class).hasMessageContaining("if it is path param, please add @PathParam"); assertThatThrownBy(() -> validator.validateRequestBeanClass(Map.class, method)) .isInstanceOf(Error.class).hasMessageContaining("request bean type must be bean class"); }