use of com.cloud.agent.api.GetVmIpAddressCommand in project cloudstack by apache.
the class NotAValidCommand method testGetVmIpAddressCommand.
@Test
public void testGetVmIpAddressCommand() throws XenAPIException, XmlRpcException {
final Connection conn = Mockito.mock(Connection.class);
final VM vm = Mockito.mock(VM.class);
final VMGuestMetrics mtr = Mockito.mock(VMGuestMetrics.class);
final VMGuestMetrics.Record rec = Mockito.mock(VMGuestMetrics.Record.class);
final Map<String, String> vmIpsMap = new HashMap<>();
vmIpsMap.put("Test", "127.0.0.1");
rec.networks = vmIpsMap;
final GetVmIpAddressCommand getVmIpAddrCmd = new GetVmIpAddressCommand("Test", "127.0.0.1/24", false);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getConnection()).thenReturn(conn);
when(citrixResourceBase.getVM(conn, getVmIpAddrCmd.getVmName())).thenReturn(vm);
when(vm.getGuestMetrics(conn)).thenReturn(mtr);
when(mtr.getRecord(conn)).thenReturn(rec);
final Answer answer = wrapper.execute(getVmIpAddrCmd, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertTrue(answer.getResult());
}
Aggregations