issue with autowiring and easymock in intellijx

Hi there,

i have an integrationtest where i autowire in mocks using a springcontext and easymock. The tests and everything works fine but i have a problem with intellij error highlighting.

my bean is configured like this:
<bean id="eventService" factory-method="createMock">
        <constructor-arg index="0"
                         value="com.karpet.nuba.service.EventService"/>
    </bean>

my autowiring in the class:
@Autowired
    @Qualifier("eventService")
    EventService eventService;

(the qualifier was there just to see if it would help, it didnt)

The eventservice java declaration above is highlighted red since idea believes that there's no bean defined as eventservice, since it doesn't understand that the factory method will create a mock of the class eventservice.

It's kind of annoying since i do it in a few places. At the very least, is it possible to turn the detection off for affected classes (found the global switch, but thats not optimal of course) ?

Cheers,

7 comments
Comment actions Permalink

Hello,

I'd suggest you to submit corresponding request to IJ tracker - there is enough information at config file to check that everything if fine.

Regards, Denis

0
Comment actions Permalink

Yes, there is, and the whole "factory-method" thing is kind of spring standard so i think its unfortunate that it doesn't work.

What about the possibilities of excluding classes from that inspection, can you do that somehow?

0
Comment actions Permalink

IDEA does fully support "factory-method", as well as all other standard spring attributes/elements.
However, it does not have any special knowledge of EasyMock.

0
Comment actions Permalink

Hi Taras,

The point is that IJ can check that the factory method has signature '<T> T createMock(Class<T>)' and 'com.karpet.nuba.service.EventService' is provided as an argument. Hence, we can be sure that IS-A com.karpet.nuba.service.EventService is returned.

Denis

0
Comment actions Permalink

What about the possibilities of excluding classes from that inspection, can you do that somehow?


AFAIK it's not possible to do that.

Denis
0
Comment actions Permalink

As a workaround, you can choose "Suppress for field" quick fix.

0
Comment actions Permalink

It doesn't have to have any knowledge of easymock, intellij just needs to follow the factory-method signature pattern.

EDIT: Ah, in too late. What he said :)

0

Please sign in to leave a comment.