protected VdsNetworkInterface setUpStatisticalExpectations() { VdsNetworkStatistics stats = mock(VdsNetworkStatistics.class); VdsNetworkInterface entity = mock(VdsNetworkInterface.class); when(entity.getSpeed()).thenReturn(SPEED); when(entity.getStatistics()).thenReturn(stats); when(entity.getId()).thenReturn(NIC_ID); when(stats.getReceiveRate()).thenReturn(RECEIVE_RATE); when(stats.getTransmitRate()).thenReturn(TRANSMIT_RATE); when(stats.getReceiveDropRate()).thenReturn(RECEIVE_DROP_RATE); when(stats.getTransmitDropRate()).thenReturn(TRANSMIT_DROP_RATE); when(stats.getReceivedBytes()).thenReturn(RECEIVED_BYTES); when(stats.getTransmittedBytes()).thenReturn(TRANSMITTED_BYTES); List<VdsNetworkInterface> ifaces = new ArrayList<>(); ifaces.add(entity); setUpEntityQueryExpectations(QueryType.GetVdsInterfacesByVdsId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { PARENT_GUID }, ifaces); return entity; }
private HostInterface hostInterfaceFromNic(VdsNetworkInterface nic) { HostInterface hi = new HostInterface(); hi.setInterface(nic); hi.setName(nic.getName()); hi.setIpv4Address(nic.getIpv4Address()); hi.setIpv6Address(nic.getIpv6Address()); hi.setMAC(nic.getMacAddress()); hi.setSpeed(nic.getSpeed()); hi.setRxRate(nic.getStatistics().getReceiveRate()); hi.setRxTotal(nic.getStatistics().getReceivedBytes()); hi.setRxDrop(nic.getStatistics().getReceiveDropRate()); hi.setTxRate(nic.getStatistics().getTransmitRate()); hi.setTxTotal(nic.getStatistics().getTransmittedBytes()); hi.setTxDrop(nic.getStatistics().getTransmitDropRate()); hi.setStatus(nic.getStatistics().getStatus()); hi.getPropertyChangedEvent().addListener(this); return hi; }