tag:blogger.com,1999:blog-3237724005744642470.post5912326200142355908..comments2020-07-30T12:43:10.297+01:00Comments on Captain Debug's Blog: Writng a JSR 303 Custom ConstraintRoger Hugheshttp://www.blogger.com/profile/07042290171112551665[email protected]Blogger3125tag:blogger.com,1999:blog-3237724005744642470.post-30758224158207241172013-04-09T08:02:09.513+01:002013-04-09T08:02:09.513+01:00I often use Mockito and combine it with Spring&#39...I often use Mockito and combine it with Spring&#39;s ReflectionTestUtils.setField(...) method to inject mock objects in to Spring beans without the need to use the context files.Roger Hugheshttps://www.blogger.com/profile/07042290171112551665[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-50863022751434799312013-04-02T08:34:07.153+01:002013-04-02T08:34:07.153+01:00Hi, nice article. I have my own custom annotation...Hi,<br />nice article.<br /><br />I have my own custom annotation validation implementation. <br />But my implementation depends on service that it will be injected at moment of runtime.<br /><br />If I follow your approach, problem occurs at the following line:<br /><br />Set&gt; constraintValidations = validator.validate(myObject);<br /><br />IMHO, problem lies in fact that my validator expects to have that service. <br /><br />I would like to test it without involving context files. I do not want to test it like integration test but just as unit test.<br /><br />I have experience with Mockito, so some kind of that approach would suffice and should work? Do you have any idea how this can be achieved?<br /><br /><br />Thank YouAleksandar Stoisavljevichttps://www.blogger.com/profile/08937424063680013385[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-5137030383271043382013-03-04T21:28:09.309+00:002013-03-04T21:28:09.309+00:00Roger, nice post. RossRoger, nice post.<br /><br />RossAnonymoushttps://www.blogger.com/profile/12252575590186343761[email protected]