testCases: Map<String, Class<out Annotation>>) { controllerClass.declaredMethods .filter { MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(QueryMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(MutationMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(SchemaMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(BatchMapping::class.java) } .forEach { method -> val methodName = "${controllerClass.canonicalName}#${method.name}" val isPublic = Modifier.isPublic(method.modifiers) val isStatic = Modifier.isStatic(method.modifiers) assert(isPublic) { "$methodName must be public method." } assert(!isStatic) { "$methodName must not be static method." } val annotationClass = testCases[method.name] Assert.assertNotNull(annotationClass) { "$methodName must be added to the testCases. testCases:$testCases" } val annotation = AnnotationUtils.findAnnotation(method, annotationClass) Assert.assertNotNull(annotation) { "$methodName must be annotated with ${annotationClass?.simpleName}" } } } コード
testCases: Map<String, Class<out Annotation>>) { controllerClass.declaredMethods .filter { MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(QueryMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(MutationMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(SchemaMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(BatchMapping::class.java) } .forEach { method -> val methodName = "${controllerClass.canonicalName}#${method.name}" val isPublic = Modifier.isPublic(method.modifiers) val isStatic = Modifier.isStatic(method.modifiers) assert(isPublic) { "$methodName must be public method." } assert(!isStatic) { "$methodName must not be static method." } val annotationClass = testCases[method.name] Assert.assertNotNull(annotationClass) { "$methodName must be added to the testCases. testCases:$testCases" } val annotation = AnnotationUtils.findAnnotation(method, annotationClass) Assert.assertNotNull(annotation) { "$methodName must be annotated with ${annotationClass?.simpleName}" } } } コード
Class<T>, testCases: Map<String, Class<out Annotation>>) { controllerClass.declaredMethods .filter { MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(QueryMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(MutationMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(SchemaMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(BatchMapping::class.java) } .forEach { method -> val methodName = "${controllerClass.canonicalName}#${method.name}" val isPublic = Modifier.isPublic(method.modifiers) val isStatic = Modifier.isStatic(method.modifiers) assert(isPublic) { "$methodName must be public method." } assert(!isStatic) { "$methodName must not be static method." } val annotationClass = testCases[method.name] Assert.assertNotNull(annotationClass) { "$methodName must be added to the testCases. testCases:$testCases" } val annotation = AnnotationUtils.findAnnotation(method, annotationClass) Assert.assertNotNull(annotation) { "$methodName must be annotated with ${annotationClass?.simpleName}" } } }
<T> assertMethodsWithAnnotation(controllerClass: Class<T>, testCases: Map<String, Class<out Annotation>>) { controllerClass.declaredMethods .filter { MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(QueryMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(MutationMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(SchemaMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(BatchMapping::class.java) } .forEach { method -> val methodName = "${controllerClass.canonicalName}#${method.name}" val isPublic = Modifier.isPublic(method.modifiers) val isStatic = Modifier.isStatic(method.modifiers) assert(isPublic) { "$methodName must be public method." } assert(!isStatic) { "$methodName must not be static method." } val annotationClass = testCases[method.name] Assert.assertNotNull(annotationClass) { "$methodName must be added to the testCases. testCases:$testCases" } val annotation = AnnotationUtils.findAnnotation(method, annotationClass) Assert.assertNotNull(annotation) { "$methodName must be annotated with ${annotationClass?.simpleName}" } } } コード
assertMethodsWithAnnotation(controllerClass: Class<T>, testCases: Map<String, Class<out Annotation>>) { controllerClass.declaredMethods .filter { MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(QueryMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(MutationMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(SchemaMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(BatchMapping::class.java) } .forEach { method -> val methodName = "${controllerClass.canonicalName}#${method.name}" val isPublic = Modifier.isPublic(method.modifiers) val isStatic = Modifier.isStatic(method.modifiers) assert(isPublic) { "$methodName must be public method." } assert(!isStatic) { "$methodName must not be static method." } val annotationClass = testCases[method.name] Assert.assertNotNull(annotationClass) { "$methodName must be added to the testCases. testCases:$testCases" } val annotation = AnnotationUtils.findAnnotation(method, annotationClass) Assert.assertNotNull(annotation) { "$methodName must be annotated with ${annotationClass?.simpleName}" } } } コード
testCases: Map<String, Class<out Annotation>>) { controllerClass.declaredMethods .filter { MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(QueryMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(MutationMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(SchemaMapping::class.java) || MergedAnnotations.from(it, SearchStrategy.TYPE_HIERARCHY).isPresent(BatchMapping::class.java) } .forEach { method -> val methodName = "${controllerClass.canonicalName}#${method.name}" val isPublic = Modifier.isPublic(method.modifiers) val isStatic = Modifier.isStatic(method.modifiers) assert(isPublic) { "$methodName must be public method." } assert(!isStatic) { "$methodName must not be static method." } val annotationClass = testCases[method.name] Assert.assertNotNull(annotationClass) { "$methodName must be added to the testCases. testCases:$testCases" } val annotation = AnnotationUtils.findAnnotation(method, annotationClass) Assert.assertNotNull(annotation) { "$methodName must be annotated with ${annotationClass?.simpleName}" } } } コード