Skip to content

Commit

Permalink
grails-core issue grails/grails-core#11318 apply Generated annotation…
Browse files Browse the repository at this point in the history
… to RenderConverterTrait method, to improve test coverage reports (#15)
  • Loading branch information
aulea authored Feb 26, 2024
1 parent 9df2d62 commit a49dc6e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.grails.compiler.web.converters

import grails.artefact.Enhances
import groovy.transform.Generated
import org.grails.web.converters.Converter
import org.grails.web.servlet.mvc.GrailsWebRequest
import org.springframework.web.context.request.RequestContextHolder
Expand All @@ -15,6 +16,7 @@ trait RenderConverterTrait {
*
* @param converter The converter to render
*/
@Generated
void render(Converter<?> converter) {
GrailsWebRequest webRequest = (GrailsWebRequest)RequestContextHolder.currentRequestAttributes()
HttpServletResponse response = webRequest.currentResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.grails.compiler.web.converters

import grails.web.Action
import groovy.transform.Generated
import spock.lang.Specification

import java.lang.reflect.Method

class ControllerTraitGeneratedSpec extends Specification {

void "test that all RenderConverter trait methods are marked as Generated"() {
expect: "all RenderConverter methods are marked as Generated on implementation class"
RenderConverterTrait.getMethods().each { Method traitMethod ->
assert TestConverter.class.getMethod(traitMethod.name, traitMethod.parameterTypes).isAnnotationPresent(Generated)
}
}
}

class TestConverter implements RenderConverterTrait {

}

0 comments on commit a49dc6e

Please sign in to comment.