@Override protected void injectMockito() { if (host == null) { return; } List<HostVO> results = new ArrayList<HostVO>(); results.add(host); Mockito.when(hostDao.listAll()).thenReturn(results); Mockito.when(hostDao.findById(Matchers.anyLong())).thenReturn(host); Mockito.when(hostDao.findHypervisorHostInCluster(Matchers.anyLong())).thenReturn(results); List<EndPoint> eps = new ArrayList<EndPoint>(); eps.add( RemoteHostEndPoint.getHypervisorHostEndPoint( host.getId(), host.getPrivateIpAddress(), host.getPublicIpAddress())); Mockito.when(selector.selectAll(Matchers.any(DataStore.class))).thenReturn(eps); Mockito.when(selector.select(Matchers.any(DataObject.class))).thenReturn(eps.get(0)); Mockito.when(selector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))) .thenReturn(eps.get(0)); }