I have a Component
@Component
class SomeComponent {
@Autowired
GrailsApplication grailsApplication
String buildString(String someInfo) {
return "${grailsApplication.config.my.string}${someInfo}"
}
}
And a unit test
@TestMixin(ControllerUnitTestMixin)
class SomeComponent Tests {
@Test
void test() {
SomeComponent component = new SomeComponent()
component.grailsApplication = new Expando()
component.grailsApplication.config = [config: [my: [string: 'FOO']]]
assert component.buildString('BAR') == 'FOOBAR'
}
}
When I execute my test I got this error:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '{}' with class 'groovy.util.Expando' to class 'org.codehaus.groovy.grails.commons.GrailsApplication'
So what's the best way to do this?