Steps to mock EJB:
1) mock Home/FacadeHome/LocalHome interface.
eg: StudentSessionHome
studentSessionHome = mock(StudentSessionHome.class);
2) identify JNDI from Delegate class and put it in map
eg: Map
map = new HashMap<String,EJBHome>();
map.put("StudentSessionJNDI",
studentSessionHome);
3) add this map object to ServiceLocator class:
eg:
ServiceLocator locator = new ServiceLocator();
locator.setMapCache(map);
4) mock the EJBObject class - studentSessionHome.create()
eg: when(studentSessionHome.create()).thenReturn(new
StudentSessionMock());
5) create mock class StudentSessionMock by implementing StudentSession
interface
eg:
class StudentSessionMock extends EJBMock implements StudentSession{....}