Search in sources :

Example 6 with InventoryNavigator

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();
}
Also used : RuntimeFault(com.vmware.vim25.RuntimeFault) InventoryNavigator(com.vmware.vim25.mo.InventoryNavigator) Test(org.testng.annotations.Test)

Example 7 with InventoryNavigator

use of com.vmware.vim25.mo.InventoryNavigator in project SimianArmy by Netflix.

the class VSphereServiceConnectionWithMockedInventoryNavigator method shouldCallSearchManagedEntityAndReturnVMForDoItGetVirtualMachineById.

@Test
public void shouldCallSearchManagedEntityAndReturnVMForDoItGetVirtualMachineById() throws RemoteException {
    VSphereServiceConnectionWithMockedInventoryNavigator service = new VSphereServiceConnectionWithMockedInventoryNavigator();
    InventoryNavigator inventoryNavigatorMock = service.getInventoryNavigatorMock();
    VirtualMachine vmMock = mock(VirtualMachine.class);
    when(inventoryNavigatorMock.searchManagedEntity(VIRTUAL_MACHINE_TYPE_NAME, "instanceId")).thenReturn(vmMock);
    VirtualMachine actualVM = service.getVirtualMachineById("instanceId");
    verify(inventoryNavigatorMock).searchManagedEntity(VIRTUAL_MACHINE_TYPE_NAME, "instanceId");
    assertSame(vmMock, actualVM);
}
Also used : InventoryNavigator(com.vmware.vim25.mo.InventoryNavigator) VirtualMachine(com.vmware.vim25.mo.VirtualMachine) Test(org.testng.annotations.Test)

Aggregations

InventoryNavigator (com.vmware.vim25.mo.InventoryNavigator)7 Test (org.testng.annotations.Test)5 VirtualMachine (com.vmware.vim25.mo.VirtualMachine)3 ManagedEntity (com.vmware.vim25.mo.ManagedEntity)2 InvalidProperty (com.vmware.vim25.InvalidProperty)1 PerfCounterInfo (com.vmware.vim25.PerfCounterInfo)1 RuntimeFault (com.vmware.vim25.RuntimeFault)1 ServiceInstance (com.vmware.vim25.mo.ServiceInstance)1 URL (java.net.URL)1 RemoteException (java.rmi.RemoteException)1