Generally speaking, Service classes should be mocked when called from other classes for Unit Tests, otherwise, you'd want to write an Integration test.
Personally, if that is all your service is doing I'd just make that a method on the domain itself:
class Vendor {
def sponsorService
SponsorLevel getSponsorLevel(){
BigDecimal sponsoringAmount = BigDecimal.ZERO
sponsoringAmount = sponsoringAmount.add(this.cashDonation ?: BigDecimal.ZERO)
sponsoringAmount = sponsoringAmount.add(this.itemValue ?: BigDecimal.ZERO)
return SponsorLevel.getSponsoringLevel(sponsoringAmount)
}
}
Your service isn't transactional, your getLevel()
isn't doing anything with the database, and the method is specific to your Vendor Domain. So to me, it makes more sense to make this a Domain method on Vendor. It simplifies your code and your test.