dstarcev
08/02/2016, 10:46 AM@Service
open class DefaultPasswordGenerator : PasswordGenerator {
override fun generatePassword(): String = KeyGenerators.string().generateKey()
}
In the test module I want to override it (this class is written on Groovy) @Configuration
class TestBeanConfiguration {
@Bean
@Primary
def mockPasswordGenerator() {
return Mockito.mock(PasswordGenerator)
}
}
If I use @Autowired
in a test, it injects the mock, but for application controllers it continues using default bean