@Test void testCollectPropertyAnnotationChecks(){ ValidationContext context = spy(new ValidationContext()); PropertyDescriptor propertyDescriptor = mock(PropertyDescriptor.class); List<Check> list = new ArrayList<>(); context.collectPropertyAnnotationChecks(list, propertyDescriptor); verify(context, never()).collectAnnotationChecks(any(List.class), any(Class.class),any(String.class), any(Annotation[].class)); }
/** * Process all annotations of provided properties. */ protected void collectPropertyAnnotationChecks(final List<Check> annChecks, final PropertyDescriptor propertyDescriptor) { FieldDescriptor fd = propertyDescriptor.getFieldDescriptor(); if (fd != null) { Annotation[] annotations = fd.getField().getAnnotations(); collectAnnotationChecks(annChecks, propertyDescriptor.getType(), propertyDescriptor.getName(), annotations); } MethodDescriptor md = propertyDescriptor.getReadMethodDescriptor(); if (md != null) { Annotation[] annotations = md.getMethod().getAnnotations(); collectAnnotationChecks(annChecks, propertyDescriptor.getType(), propertyDescriptor.getName(), annotations); } md = propertyDescriptor.getWriteMethodDescriptor(); if (md != null) { Annotation[] annotations = md.getMethod().getAnnotations(); collectAnnotationChecks(annChecks, propertyDescriptor.getType(), propertyDescriptor.getName(), annotations); } }
/** * Process all annotations of provided field. */ protected void collectFieldAnnotationChecks(List<Check> annChecks, Field field) { Annotation[] annotations = field.getAnnotations(); if (annotations.length > 0) { collectAnnotationChecks(annChecks, field.getType(), field.getName(), annotations); } }