Skip to content

Commit 984fe36

Browse files
borinquenkidclaude
andcommitted
Close the two real Codecov patch-coverage gaps from this PR
DeleteWhereImplementer.isCompatibleReturnType and AbstractServiceImplementer.isValidParameter each had one branch missing on lines Codecov flagged. Added a compile-error test for a @where delete method with an incompatible (non-void, non-Number) return type, and a save-with-id-named-parameter test that exercises isValidParameter's GormProperties.IDENTITY branch directly (SaveImplementer, unlike UpdateOneImplementer, doesn't strip the id parameter before validating it). Both branches now fully covered. The third flagged line, FindAllByImplementer's matchSpec == null error path, was verified empirically rather than assumed unreachable: a probe test with an edge-case DSL input (findAllBy() with no property suffix) showed doesImplement() already computes the identical memoized matchSpec before selecting this implementer, so doImplement() can never observe a null matchSpec -- the method falls through to FindAllImplementer instead whenever matchSpec would be null. Genuinely unreachable through the public DSL, not a gap. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 4f354f4 commit 984fe36

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

grails-datamapping-core/src/test/groovy/grails/gorm/services/ServiceImplementerEdgeCaseSpec.groovy

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,53 @@ class Foo {
361361
then:
362362
impl.getMethod('saveFoo', String).getAnnotation(grails.gorm.transactions.Transactional) != null
363363
}
364+
365+
void 'a @Where delete method with an incompatible return type fails to compile'() {
366+
when:
367+
new GroovyClassLoader().parseClass('''
368+
import grails.gorm.services.Service
369+
import grails.gorm.services.Where
370+
import grails.gorm.annotation.Entity
371+
372+
@Service(Foo)
373+
interface FooService {
374+
@Where({ title ==~ pattern })
375+
String deleteByTitle(String pattern)
376+
}
377+
@Entity
378+
class Foo {
379+
String title
380+
}
381+
''')
382+
383+
then:
384+
MultipleCompilationErrorsException e = thrown(MultipleCompilationErrorsException)
385+
e.message.contains('No implementations possible')
386+
}
387+
388+
void 'a save method with an id-named parameter binds it directly onto the entity'() {
389+
when:
390+
Class service = new GroovyClassLoader().parseClass('''
391+
import grails.gorm.services.Service
392+
import grails.gorm.annotation.Entity
393+
394+
@Service(Foo)
395+
interface FooService {
396+
Foo save(Serializable id, String title)
397+
}
398+
@Entity
399+
class Foo {
400+
String title
401+
}
402+
''')
403+
404+
then:
405+
service.isInterface()
406+
407+
when:
408+
Class impl = service.classLoader.loadClass("\$FooServiceImplementation")
409+
410+
then:
411+
impl.getMethod('save', Serializable, String).getAnnotation(Implemented).by() == org.grails.datastore.gorm.services.implementers.SaveImplementer
412+
}
364413
}

0 commit comments

Comments
 (0)