@Test public void testGetAllCpuStatisticsByVdsId() { List<CpuStatistics> result = vdsCpuStatisticsDao.getAllCpuStatisticsByVdsId(existingVds.getId()); assertNotNull(result); assertEquals(2, result.size()); }
@Test public void testMassUpdateCpuStatistics() { List<CpuStatistics> result = vdsCpuStatisticsDao.getAllCpuStatisticsByVdsId(existingVds.getId()); assertNotNull(result); assertEquals(2, result.size()); assertEquals(20, result.get(0).getCpuUsagePercent()); assertEquals(20, result.get(1).getCpuUsagePercent()); result.get(0).setCpuUsagePercent(30); result.get(1).setCpuUsagePercent(30); vdsCpuStatisticsDao.massUpdateCpuStatistics(result, existingVds.getId()); result = vdsCpuStatisticsDao.getAllCpuStatisticsByVdsId(existingVds.getId()); assertNotNull(result); assertEquals(2, result.size()); assertEquals(30, result.get(0).getCpuUsagePercent()); assertEquals(30, result.get(1).getCpuUsagePercent()); }
@Test public void testMassSaveCpuStatistics() { List<CpuStatistics> result = vdsCpuStatisticsDao.getAllCpuStatisticsByVdsId(ANOTHER_EXISTING_VDS_ID); assertNotNull(result); assertEquals(0, result.size()); List<CpuStatistics> newCpuStats = new ArrayList<>(); newVdsCpuStatistics.setCpuId(0); newCpuStats.add(newVdsCpuStatistics); newVdsCpuStatistics.setCpuId(1); newCpuStats.add(newVdsCpuStatistics); newVdsCpuStatistics.setCpuId(2); newCpuStats.add(newVdsCpuStatistics); vdsCpuStatisticsDao.massSaveCpuStatistics(newCpuStats, ANOTHER_EXISTING_VDS_ID); result = vdsCpuStatisticsDao.getAllCpuStatisticsByVdsId(ANOTHER_EXISTING_VDS_ID); assertNotNull(result); assertEquals(3, result.size()); }