Spring4 junit testing controller which calls service method outside webapp

Viewed 218

I have been writing jUnit test for a while now, but novice to spring mvc controller testing. To be specific, I have a controller method which calls service method, service method interface & impl is outside webapp, which is nothing but a jar file. When I try to mock the same using mockito I get null as an output. The same holds good if service method ( Interface & Impl ) in same webapp.

Could you please let me know how do I mock the service which is outside webapp.

Below is my code :

@Mock
private FMService fService;

@InjectMocks
private FMController fmController;

testMethod() {
     when(SQ2Service.getListProblem(linkMap,serviceAccessParams)).thenReturn(listSQ);

}

call goes to controller successfully, but returns null when encounters the SQ2Service.getListProblem(linkMap,serviceAccessParams);

0 Answers
Related