@Test
public void testListingUsageRecords() throws Exception {
try {
setExpectedServerAnswer("recordtestanswer.xml");
UsageRecordList usageRecords = client.getAccount().getUsageRecords();
TreeSet<UsageRecord> answers = new TreeSet<UsageRecord>(new Comparator<UsageRecord>() {
@Override
public int compare(UsageRecord o1, UsageRecord o2) {
UsageCategory o1_category = o1.getCategory();
UsageCategory o2_category = o2.getCategory();
if (o1_category == null) {
return 1;
} else if (o2_category == null) {
return -1;
} else {
return o1_category.compareTo(o2_category);
}
}
});
Iterator<UsageRecord> usageRecordsIter = usageRecords.iterator();
while (usageRecordsIter.hasNext()) { // iter is of type Iterator<String>
answers.add(usageRecordsIter.next());
}