leandro.bighetti
07/29/2016, 10:23 AMdh44t
07/29/2016, 10:26 AMthyberg
07/29/2016, 1:18 PMdstarcev
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 beandstarcev
08/02/2016, 11:28 AMrocketraman
08/02/2016, 1:52 PMTestBeanConfiguration
class, and the mockPasswordGenerator
function, as open
.Dave Leeds
08/04/2016, 4:35 PM@RequestMapping(value = "/something/somewhere", method = GET)
@ResponseBody
public String doStuff() {
return "";
}
Translating this to Kotlin, I get this:
@RequestMapping(value = "/something/somewhere", method = GET)
@ResponseBody
fun doStuff(): String {
return ""
}
That gives me this compile error: Type mismatch: inferred type is RequestMethod but Array<RequestMethod> was expected
.
Of course, I can fix that by wrapping the RequestMethod with arrayOf()
, like this:
@RequestMapping(value = "/something/somewhere", method = arrayOf(GET))
@ResponseBody
fun doStuff(): String {
return ""
}
That works, but I’d like to understand — why do you have to specify the method
as an array in Kotlin but not in Java?jkschneider
08/04/2016, 4:35 PMDave Leeds
08/04/2016, 4:36 PMjkschneider
08/04/2016, 4:36 PMjkschneider
08/04/2016, 4:37 PMvalue =
is unnecessary in this scenariomikegehard
08/04/2016, 5:35 PMDave Leeds
08/04/2016, 5:49 PMjasper
08/05/2016, 8:41 AMrocketraman
08/09/2016, 11:36 PM@Configuration
within the test class, but in 1.4 it ignores it unless it is outside the test class. Anyone encountered this?rocketraman
08/09/2016, 11:44 PM@SpringApplicationConfiguration
but not with the equivalent @SpringBootTest
annotation in 1.4rocketraman
08/09/2016, 11:49 PM@MockBean
rocketraman
08/10/2016, 12:32 AM@SpringBootTest
you have to add the nested class explicitly to the annotation classes
arrayaaverin
08/10/2016, 6:19 AMdh44t
08/10/2016, 9:51 AMdh44t
08/10/2016, 9:52 AMdh44t
08/10/2016, 9:52 AMhotchemi
08/18/2016, 6:26 AMisto
08/18/2016, 12:27 PMisto
08/18/2016, 12:42 PMUnable to proxy method [private final ...
isto
08/18/2016, 12:43 PMjkschneider
08/18/2016, 2:26 PMisto
08/18/2016, 3:33 PMdh44t
08/18/2016, 3:34 PMisto
08/18/2016, 3:34 PM