@Test
public void listVmsFromHostTest() {

    HostResources hostResources = Mockito.mock(HostResources.class);
    Mockito.when(hostResources.getHostId()).thenReturn(1l);
    ServiceOfferingVO serviceOfferingVO = new ServiceOfferingVO("name", 1, 512, 1000, 1000, 1000, true, "displayText", ProvisioningType.THIN, true, true, "tags", true,
            com.cloud.vm.VirtualMachine.Type.User, true);
    List<VMInstanceVO> vmsInstanceVO = createRunningVmIistanceVo(2);
    Mockito.when(vmInstanceDao.listByHostId(1l)).thenReturn(vmsInstanceVO);
    Mockito.when(serviceOfferingDao.findById(1l)).thenReturn(serviceOfferingVO);
    List<VmResources> vmResourcesList = hostResourcesService.listVmsFromHost(hostResources);
    Assert.assertEquals(2, vmResourcesList.size());
    Assert.assertEquals(1000l, vmResourcesList.get(0).getCpuSpeed());
    Assert.assertEquals(512l, vmResourcesList.get(1).getMemoryInMegaBytes());
    Assert.assertEquals(1, vmResourcesList.get(0).getNumberOfCpus());
}