Re: WOInject and WOUnit co-operation
Re: WOInject and WOUnit co-operation
- Subject: Re: WOInject and WOUnit co-operation
- From: Paul Hoadley <email@hidden>
- Date: Thu, 7 Dec 2017 14:36:08 +1030
Hi Henrique,
On 6 Dec 2017, at 20:45, Paul Hoadley <email@hidden> wrote:
>> Create a protected method to initialize the EO dependency:
>>
>> class MyEO {
>> private AnyObject object;
>>
>> @Inject
>> protected void initMyObject(AnyObject object) {
>> this.object = object;
>> }
>> }
>>
>> @Before
>> public void setup() {
>> eo = new MyEO();
>>
>> eo.initMyObject(anObject);
>>
>> editingContext.insertObject(eo); // or insertSavedObject if you want to
>> create a dummy EO.
>> }
>
> In this first solution, there’s no @Inject annotation on 'AnyObject object'
> now. Forgive my Guice ignorance here—does the @Inject on
> initMyObject(AnyObject object) cause that method to be _called_ by Guice?
Sure does!
> If so, when?
Presumably at construction time.
>> It's not cool if you have to do it all the time, but it looks more polished
>> than making your EO ask for a test version of the injected object. What do
>> you think?
>
> Great solutions—thanks. I’ll test them out tomorrow.
I’ve used the annotated init…() method example. Works great.
--
Paul Hoadley
https://logicsquad.net/
https://www.linkedin.com/company/logic-squad/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden