HostResourcesService { public HostResources createHostResources(HostVO hostVO) { HostResources host = createAndConfigureHostResources(hostVO); List<VmResources> vms = listVmsFromHost(host); host.setVmsResources(vms); calculateHostResourcesAllocated(host); loadHostOverprovisioningFactors(host); return host; }  HostResources createAndConfigureHostResources(HostVO hostVo); HostResources createHostResources(HostVO hostVO);  }
@Test public void createHostResourcesTest() { HostVO hostVo = new HostVO(""); HostResources host = new HostResources(); HostResourcesService spy = Mockito.spy(new HostResourcesService()); Mockito.doReturn(host).when(spy).createAndConfigureHostResources(hostVo); List<VmResources> vms = hostResourcesUtils.createSmallVms(1); Mockito.doReturn(vms).when(spy).listVmsFromHost(host); Mockito.doNothing().when(spy).calculateHostResourcesAllocated(host); Mockito.doNothing().when(spy).loadHostOverprovisioningFactors(host); HostResources hostResourcesReturned = spy.createHostResources(hostVo); Assert.assertEquals(vms, hostResourcesReturned.getVmsResources()); InOrder inOrder = Mockito.inOrder(spy); inOrder.verify(spy).createAndConfigureHostResources(hostVo); inOrder.verify(spy).listVmsFromHost(host); inOrder.verify(spy).calculateHostResourcesAllocated(host); inOrder.verify(spy).loadHostOverprovisioningFactors(host); }