use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.
the class VSphereServiceConnection method getVirtualMachineById.
/**
* Gets the named VirtualMachine.
*/
public VirtualMachine getVirtualMachineById(String instanceId) throws RemoteException {
InventoryNavigator inventoryNavigator = getInventoryNavigator();
VirtualMachine virtualMachine = (VirtualMachine) inventoryNavigator.searchManagedEntity(VIRTUAL_MACHINE_TYPE_NAME, instanceId);
return virtualMachine;
}
use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.
the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldCallSearchManagedEntitiesOnDescribeWhenAtLeastOneVMIsReturned.
@Test
public void shouldCallSearchManagedEntitiesOnDescribeWhenAtLeastOneVMIsReturned() throws RemoteException {
VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
ManagedEntity[] meMocks = new ManagedEntity[] { mock(VirtualMachine.class) };
when(inventoryNavigatorMock.searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME)).thenReturn(meMocks);
VirtualMachine[] actualVMs = service.describeVirtualMachines();
verify(inventoryNavigatorMock).searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME);
assertSame(meMocks[0], actualVMs[0]);
}
use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.
the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldEncapsulateInvalidPropertyException.
@Test(expectedExceptions = AmazonServiceException.class)
public void shouldEncapsulateInvalidPropertyException() throws RemoteException {
VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
when(inventoryNavigatorMock.searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME)).thenThrow(new InvalidProperty());
service.describeVirtualMachines();
}
use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.
the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldEncapsulateRemoteExceptionException.
@Test(expectedExceptions = AmazonServiceException.class)
public void shouldEncapsulateRemoteExceptionException() throws RemoteException {
VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
when(inventoryNavigatorMock.searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME)).thenThrow(new RemoteException());
service.describeVirtualMachines();
}
use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.
the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldEncapsulateRuntimeFaultException.
@Test(expectedExceptions = AmazonServiceException.class)
public void shouldEncapsulateRuntimeFaultException() throws RemoteException {
VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
when(inventoryNavigatorMock.searchManagedEntities(VIRTUAL_MACHINE_TYPE_NAME)).thenThrow(new RuntimeFault());
service.describeVirtualMachines();
}
Aggregations