@Override
  protected void injectMockito() {
    List<HostVO> hosts = new ArrayList<HostVO>();
    hosts.add(this.host);
    Mockito.when(
            resourceMgr.listAllUpAndEnabledHosts(
                (Type) Matchers.any(), Matchers.anyLong(), Matchers.anyLong(), Matchers.anyLong()))
        .thenReturn(hosts);

    RemoteHostEndPoint ep =
        RemoteHostEndPoint.getHypervisorHostEndPoint(
            this.host.getId(), this.host.getPrivateIpAddress(), this.host.getPublicIpAddress());
    Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class)))
        .thenReturn(ep);
    Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(ep);
    Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
  }
Example #2
0
 @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));
 }