XenHypervisor implements HypervisorHost { protected Connection getConnection(HostVO host) { Map<String, String> params = host.getDetails(); String username = getUsername(params); Queue<String> password = getPassword(params); return connPool.getConnect(host.getPrivateIpAddress(), username, password); }  @Override void shutdownHost(HostVO hostVo); @Override boolean supportsHypervisor(HypervisorType hypervisorType);  }
@SuppressWarnings("unchecked") @Test public void getConnectionTest() throws Exception { HostVO hostVo = setHostVoWithDetails(); XenServerConnectionPool connPool = Mockito.mock(XenServerConnectionPool.class); Mockito.doReturn(conn).when(connPool).getConnect(Mockito.anyString(), Mockito.anyString(), Mockito.any(Queue.class)); xenHypervisor.connPool = connPool; xenHypervisor.getConnection(hostVo); InOrder inOrder = Mockito.inOrder(xenHypervisor); inOrder.verify(xenHypervisor).getUsername(Mockito.anyMap()); inOrder.verify(xenHypervisor).getPassword(Mockito.anyMap()); Mockito.verify(connPool).getConnect(Mockito.anyString(), Mockito.anyString(), Mockito.any(Queue.class)); }