@Test public void shouldReturnProperUsageWhenThereAreValidRawUsageRecordsAboveThresholdInTwoDays() { Calendar startOfToday = CalendarHelper.zeroOutTime(Calendar.getInstance()); Calendar fiveMinutesLater = startOfToday; fiveMinutesLater.add(Calendar.MINUTE, 5); Calendar tenMinutesLater = startOfToday; tenMinutesLater.add(Calendar.MINUTE, 10); Calendar startOfTomorrow = CalendarHelper.zeroOutTime(Calendar.getInstance()); startOfTomorrow.add(Calendar.DAY_OF_YEAR, 1); Calendar tomorrowFiveMinutesLater = startOfTomorrow; tomorrowFiveMinutesLater.add(Calendar.MINUTE, 5); HostUsage usage1 = createHostUsage(1, 1, 10000000000l, 10000000000l, startOfToday); HostUsage usage2 = createHostUsage(1, 1, 50000000000l, 50000000000l, fiveMinutesLater); HostUsage usage3 = createHostUsage(1, 1, 50000000000l, 50000000000l, tenMinutesLater); HostUsage usage4 = createHostUsage(1, 1, 80000000000l, 80000000000l, startOfTomorrow); HostUsage usage5 = createHostUsage(1, 1, 30000000000l, 30000000000l, tomorrowFiveMinutesLater); rawHostUsage.add(usage1); rawHostUsage.add(usage2); rawHostUsage.add(usage3); rawHostUsage.add(usage4); rawHostUsage.add(usage5); List<org.openstack.atlas.service.domain.pojos.HostUsageRecord> hostUsageRecords = HostUsageProcessor.processRawHostUsageData(rawHostUsage); Assert.assertEquals(1, hostUsageRecords.size()); final HostUsageRecord record = hostUsageRecords.get(0); Assert.assertEquals(new Long(40000000000l), record.getHostUsages().get(0).getBandwidthIn()); Assert.assertEquals(new Long(40000000000l), record.getHostUsages().get(0).getBandwidthOut()); Assert.assertEquals(CalendarHelper.zeroOutTime(startOfToday), record.getHostUsages().get(0).getDay()); Assert.assertEquals(new Long(60000000000l), record.getHostUsages().get(1).getBandwidthIn()); Assert.assertEquals(new Long(60000000000l), record.getHostUsages().get(1).getBandwidthOut()); Assert.assertEquals(CalendarHelper.zeroOutTime(startOfTomorrow), record.getHostUsages().get(1).getDay()); }
public static List<HostUsageRecord> processRawHostUsageData(List<HostUsage> rawHostUsage) { List<HostUsageRecord> hostUsageRecords = new ArrayList<HostUsageRecord>(); if (rawHostUsage == null) return hostUsageRecords; Map<Integer, Map<Calendar, List<HostUsage>>> dailyHostUsageMap = convertRawUsageToMap(rawHostUsage); for (Integer hostId : dailyHostUsageMap.keySet()) { HostUsageRecord hostUsageRecord = new HostUsageRecord(); hostUsageRecord.setHostId(hostId); hostUsageRecord.setHostUsages(processDailyHostUsageMap(dailyHostUsageMap.get(hostId))); hostUsageRecords.add(hostUsageRecord); } return hostUsageRecords; }
HostUsageProcessor { public static List<HostUsageRecord> processRawHostUsageData(List<HostUsage> rawHostUsage) { List<HostUsageRecord> hostUsageRecords = new ArrayList<HostUsageRecord>(); if (rawHostUsage == null) return hostUsageRecords; Map<Integer, Map<Calendar, List<HostUsage>>> dailyHostUsageMap = convertRawUsageToMap(rawHostUsage); for (Integer hostId : dailyHostUsageMap.keySet()) { HostUsageRecord hostUsageRecord = new HostUsageRecord(); hostUsageRecord.setHostId(hostId); hostUsageRecord.setHostUsages(processDailyHostUsageMap(dailyHostUsageMap.get(hostId))); hostUsageRecords.add(hostUsageRecord); } return hostUsageRecords; } }
HostUsageProcessor { public static List<HostUsageRecord> processRawHostUsageData(List<HostUsage> rawHostUsage) { List<HostUsageRecord> hostUsageRecords = new ArrayList<HostUsageRecord>(); if (rawHostUsage == null) return hostUsageRecords; Map<Integer, Map<Calendar, List<HostUsage>>> dailyHostUsageMap = convertRawUsageToMap(rawHostUsage); for (Integer hostId : dailyHostUsageMap.keySet()) { HostUsageRecord hostUsageRecord = new HostUsageRecord(); hostUsageRecord.setHostId(hostId); hostUsageRecord.setHostUsages(processDailyHostUsageMap(dailyHostUsageMap.get(hostId))); hostUsageRecords.add(hostUsageRecord); } return hostUsageRecords; }  }
HostUsageProcessor { public static List<HostUsageRecord> processRawHostUsageData(List<HostUsage> rawHostUsage) { List<HostUsageRecord> hostUsageRecords = new ArrayList<HostUsageRecord>(); if (rawHostUsage == null) return hostUsageRecords; Map<Integer, Map<Calendar, List<HostUsage>>> dailyHostUsageMap = convertRawUsageToMap(rawHostUsage); for (Integer hostId : dailyHostUsageMap.keySet()) { HostUsageRecord hostUsageRecord = new HostUsageRecord(); hostUsageRecord.setHostId(hostId); hostUsageRecord.setHostUsages(processDailyHostUsageMap(dailyHostUsageMap.get(hostId))); hostUsageRecords.add(hostUsageRecord); } return hostUsageRecords; }  static List<HostUsageRecord> processRawHostUsageData(List<HostUsage> rawHostUsage); }
HostUsageProcessor { public static List<HostUsageRecord> processRawHostUsageData(List<HostUsage> rawHostUsage) { List<HostUsageRecord> hostUsageRecords = new ArrayList<HostUsageRecord>(); if (rawHostUsage == null) return hostUsageRecords; Map<Integer, Map<Calendar, List<HostUsage>>> dailyHostUsageMap = convertRawUsageToMap(rawHostUsage); for (Integer hostId : dailyHostUsageMap.keySet()) { HostUsageRecord hostUsageRecord = new HostUsageRecord(); hostUsageRecord.setHostId(hostId); hostUsageRecord.setHostUsages(processDailyHostUsageMap(dailyHostUsageMap.get(hostId))); hostUsageRecords.add(hostUsageRecord); } return hostUsageRecords; }  static List<HostUsageRecord> processRawHostUsageData(List<HostUsage> rawHostUsage); static final long ZEUS_RESET_THRESHOLD_BYTES; }