@Test
 public void testFindVmOnDatacenter() throws Exception {
   when(hyperHost.getHyperHostDatacenter()).thenReturn(mor);
   when(datacenter.getMor()).thenReturn(mor);
   when(datacenter.findVm(VOLUME_PATH)).thenReturn(vmMo);
   whenNew(DatacenterMO.class).withArguments(context, mor).thenReturn(datacenter);
   VirtualMachineMO result = _resource.findVmOnDatacenter(context, hyperHost, volume);
   assertEquals(vmMo, result);
 }
  // Test successful scaling up the vm
  @Test
  public void testScaleVMF1() throws Exception {
    when(_resource.getHyperHost(context, null)).thenReturn(hyperHost);
    doReturn("i-2-3-VM").when(cmd).getVmName();
    when(hyperHost.findVmOnHyperHost("i-2-3-VM")).thenReturn(vmMo);
    doReturn(536870912L).when(vmSpec).getMinRam();
    doReturn(1).when(vmSpec).getCpus();
    doReturn(1000).when(vmSpec).getMinSpeed();
    doReturn(1000).when(vmSpec).getMaxSpeed();
    doReturn(536870912L).when(vmSpec).getMaxRam();
    doReturn(false).when(vmSpec).getLimitCpuUse();
    when(vmMo.configureVm(vmConfigSpec)).thenReturn(true);

    _resource.execute(cmd);
    verify(_resource).execute(cmd);
  }
 @Test(expected = CloudRuntimeException.class)
 public void testFindVmOnDatacenterNullHyperHostReference() throws Exception {
   when(hyperHost.getMor()).thenReturn(null);
   _resource.findVmOnDatacenter(context, hyperHost, volume);
 }