HostService { public List<VMInstanceVO> listAllVmsFromHost(long hostId) { return vmInstanceDao.listByHostId(hostId); }  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 listAllVmsFromHostTest() { List<VMInstanceVO> vms = new ArrayList<>(); VMInstanceVO vm = Mockito.mock(VMInstanceVO.class); vms.add(vm); Mockito.doReturn(vms).when(vmInstanceDao).listByHostId(Mockito.anyLong()); List<VMInstanceVO> result = spy.listAllVmsFromHost(0l); Mockito.verify(vmInstanceDao).listByHostId(Mockito.anyLong()); Assert.assertEquals(vms, result); Assert.assertEquals(vms.get(0), vms.get(0)); Assert.assertEquals(vms.size(), vms.size()); }