static VmNetworkInterface setUpStatisticalEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics) { when(entity.getStatistics()).thenReturn(statistics); when(statistics.getReceiveRate()).thenReturn(1D); when(statistics.getReceiveDropRate()).thenReturn(2D); when(statistics.getTransmitRate()).thenReturn(3D); when(statistics.getTransmitDropRate()).thenReturn(4D); when(statistics.getReceivedBytes()).thenReturn(5L); when(statistics.getTransmittedBytes()).thenReturn(6L); return entity; }
static VmNetworkInterface setUpStatisticalEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics) { expect(entity.getStatistics()).andReturn(statistics).anyTimes(); expect(statistics.getReceiveRate()).andReturn(1D).anyTimes(); expect(statistics.getReceiveDropRate()).andReturn(2D).anyTimes(); expect(statistics.getTransmitRate()).andReturn(3D).anyTimes(); expect(statistics.getTransmitDropRate()).andReturn(4D).anyTimes(); expect(statistics.getReceivedBytes()).andReturn(5L).anyTimes(); expect(statistics.getTransmittedBytes()).andReturn(6L).anyTimes(); return entity; }
private void saveVmsToDb() { getDbFacade().getVmDynamicDao().updateAllInBatch(vmDynamicToSave.values()); getDbFacade().getVmStatisticsDao().updateAllInBatch(vmStatisticsToSave); final List<VmNetworkStatistics> allVmInterfaceStatistics = new LinkedList<VmNetworkStatistics>(); for (List<VmNetworkInterface> list : vmInterfaceStatisticsToSave) { for (VmNetworkInterface iface : list) { allVmInterfaceStatistics.add(iface.getStatistics()); } } getDbFacade().getVmNetworkStatisticsDao().updateAllInBatch(allVmInterfaceStatistics); getDbFacade() .getDiskImageDynamicDao() .updateAllDiskImageDynamicWithDiskIdByVmId(vmDiskImageDynamicToSave); getDbFacade().getLunDao().updateAllInBatch(vmLunDisksToSave); getVdsEventListener().addExternallyManagedVms(externalVmsToAdd); saveVmDevicesToDb(); saveVmGuestAgentNetworkDevices(); saveVmJobsToDb(); }