HostService { public List<HostVO> listAllHostsInCluster(Cluster cluster) { return hostDao.listAllUpAndEnabledNonHAHosts(Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId(), null); }  boolean isHostUpAndEnabled(long hostId); boolean isHostInMaintenanceError(long hostId); boolean isHostInPreparedForMaintenance(long hostId); @Transactional(readOnly = false) void markHostAsShutdownByAdministrationAgent(long id); void loadHostDetails(HostVO host); List<HypervisorType> getAllHypervisorsTypeInCloud(); HostVO findHostById(Long hostId); List<HostVO> listAllHostsInCluster(Cluster cluster); List<VMInstanceVO> listAllVmsFromHost(long hostId); @Transactional(readOnly = false) void updateHostPrivaceMacAddress(HostVO hostVo, String privateMacAddress); boolean isHostDown(long id); boolean isThereAnyHostOnCloudDeactivatedByOurManager();  }
@Test public void listAllHostsInClusterTest() { String str = null; List<HostVO> hosts = new ArrayList<>(); HostVO host1 = Mockito.mock(HostVO.class); hosts.add(host1); HostVO host2 = Mockito.mock(HostVO.class); hosts.add(host2); Cluster cluster = Mockito.mock(Cluster.class); Mockito.when(cluster.getId()).thenReturn(0l); Mockito.when(cluster.getPodId()).thenReturn(0l); Mockito.when(cluster.getDataCenterId()).thenReturn(0l); Mockito.doReturn(hosts).when(hostDao).listAllUpAndEnabledNonHAHosts(Mockito.eq(Type.Routing), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong(), Mockito.eq(str)); spy.listAllHostsInCluster(cluster); Mockito.verify(cluster).getId(); Mockito.verify(cluster).getPodId(); Mockito.verify(cluster).getDataCenterId(); Mockito.verify(hostDao).listAllUpAndEnabledNonHAHosts(Mockito.eq(Type.Routing), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong(), Mockito.eq(str)); }