As in JCLOUDS-991 it appears size is missing as a UsageResponse parameter, particularily for Volume usages. This commit adds it into the UsageRecord class.

This commit is contained in:
John McDonnell 2015-08-17 21:29:40 +01:00 committed by Ignasi Barrera
parent cf0e659ccf
commit c73b82b58b
2 changed files with 25 additions and 6 deletions

View File

@ -111,6 +111,7 @@ public class UsageRecord {
protected boolean isSourceNAT; protected boolean isSourceNAT;
protected double rawUsageHours; protected double rawUsageHours;
protected String usage; protected String usage;
protected Long size;
protected String type; protected String type;
protected UsageType usageType; protected UsageType usageType;
@ -258,6 +259,14 @@ public class UsageRecord {
return self(); return self();
} }
/**
* @see UsageRecord#getSize()
*/
public T size(Long size) {
this.size = size;
return self();
}
/** /**
* @see UsageRecord#getType() * @see UsageRecord#getType()
*/ */
@ -277,7 +286,7 @@ public class UsageRecord {
public UsageRecord build() { public UsageRecord build() {
return new UsageRecord(id, description, accountId, accountName, domainId, startDate, endDate, assignDate, releaseDate, return new UsageRecord(id, description, accountId, accountName, domainId, startDate, endDate, assignDate, releaseDate,
zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours, zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours,
usage, type, usageType); usage, size, type, usageType);
} }
public T fromUsageRecord(UsageRecord in) { public T fromUsageRecord(UsageRecord in) {
@ -300,6 +309,7 @@ public class UsageRecord {
.isSourceNAT(in.isSourceNAT()) .isSourceNAT(in.isSourceNAT())
.rawUsageHours(in.getRawUsageHours()) .rawUsageHours(in.getRawUsageHours())
.usage(in.getUsage()) .usage(in.getUsage())
.size(in.getSize())
.type(in.getType()) .type(in.getType())
.usageType(in.getUsageType()); .usageType(in.getUsageType());
} }
@ -330,19 +340,21 @@ public class UsageRecord {
private final boolean isSourceNAT; private final boolean isSourceNAT;
private final double rawUsageHours; private final double rawUsageHours;
private final String usage; private final String usage;
private final Long size;
private final String type; private final String type;
private final UsageType usageType; private final UsageType usageType;
@ConstructorProperties({ @ConstructorProperties({
"usageid", "description", "accountid", "account", "domainid", "startdate", "enddate", "assigndate", "releasedate", "usageid", "description", "accountid", "account", "domainid", "startdate", "enddate", "assigndate", "releasedate",
"zoneid", "virtualmachineid", "name", "offeringid", "templateid", "ipaddress", "issourcenat", "rawusage", "usage", "zoneid", "virtualmachineid", "name", "offeringid", "templateid", "ipaddress", "issourcenat", "rawusage", "usage",
"type", "usagetype" "size", "type", "usagetype"
}) })
protected UsageRecord(String id, @Nullable String description, @Nullable String accountId, @Nullable String accountName, protected UsageRecord(String id, @Nullable String description, @Nullable String accountId, @Nullable String accountName,
@Nullable String domainId, @Nullable Date startDate, @Nullable Date endDate, @Nullable Date assignDate, @Nullable String domainId, @Nullable Date startDate, @Nullable Date endDate, @Nullable Date assignDate,
@Nullable String releaseDate, @Nullable String zoneId, @Nullable String virtualMachineId, @Nullable String virtualMachineName, @Nullable String releaseDate, @Nullable String zoneId, @Nullable String virtualMachineId, @Nullable String virtualMachineName,
@Nullable String serviceOfferingId, @Nullable String templateId, @Nullable String ipAddress, @Nullable String serviceOfferingId, @Nullable String templateId, @Nullable String ipAddress,
boolean isSourceNAT, double rawUsageHours, @Nullable String usage, @Nullable String type, @Nullable UsageType usageType) { boolean isSourceNAT, double rawUsageHours, @Nullable String usage, @Nullable Long size,
@Nullable String type, @Nullable UsageType usageType) {
this.id = id; this.id = id;
this.description = description; this.description = description;
this.accountId = accountId; this.accountId = accountId;
@ -361,6 +373,7 @@ public class UsageRecord {
this.isSourceNAT = isSourceNAT; this.isSourceNAT = isSourceNAT;
this.rawUsageHours = rawUsageHours; this.rawUsageHours = rawUsageHours;
this.usage = usage; this.usage = usage;
this.size = size;
this.type = type; this.type = type;
this.usageType = usageType; this.usageType = usageType;
} }
@ -452,6 +465,10 @@ public class UsageRecord {
return this.usage; return this.usage;
} }
public Long getSize() {
return this.size;
}
@Nullable @Nullable
public String getType() { public String getType() {
return this.type; return this.type;
@ -466,7 +483,7 @@ public class UsageRecord {
public int hashCode() { public int hashCode() {
return Objects.hashCode(id, description, accountId, accountName, domainId, startDate, endDate, assignDate, releaseDate, return Objects.hashCode(id, description, accountId, accountName, domainId, startDate, endDate, assignDate, releaseDate,
zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours, zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours,
usage, type, usageType); size, usage, type, usageType);
} }
@Override @Override
@ -492,6 +509,7 @@ public class UsageRecord {
&& Objects.equal(this.isSourceNAT, that.isSourceNAT) && Objects.equal(this.isSourceNAT, that.isSourceNAT)
&& Objects.equal(this.rawUsageHours, that.rawUsageHours) && Objects.equal(this.rawUsageHours, that.rawUsageHours)
&& Objects.equal(this.usage, that.usage) && Objects.equal(this.usage, that.usage)
&& Objects.equal(this.size, that.size)
&& Objects.equal(this.type, that.type) && Objects.equal(this.type, that.type)
&& Objects.equal(this.usageType, that.usageType); && Objects.equal(this.usageType, that.usageType);
} }
@ -503,7 +521,7 @@ public class UsageRecord {
.add("releaseDate", releaseDate).add("zoneId", zoneId).add("virtualMachineId", virtualMachineId) .add("releaseDate", releaseDate).add("zoneId", zoneId).add("virtualMachineId", virtualMachineId)
.add("virtualMachineName", virtualMachineName).add("serviceOfferingId", serviceOfferingId).add("templateId", templateId) .add("virtualMachineName", virtualMachineName).add("serviceOfferingId", serviceOfferingId).add("templateId", templateId)
.add("ipAddress", ipAddress).add("isSourceNAT", isSourceNAT).add("rawUsageHours", rawUsageHours).add("usage", usage) .add("ipAddress", ipAddress).add("isSourceNAT", isSourceNAT).add("rawUsageHours", rawUsageHours).add("usage", usage)
.add("type", type).add("usageType", usageType); .add("size", size).add("type", type).add("usageType", usageType);
} }
@Override @Override

View File

@ -60,7 +60,8 @@ public class ListUsageRecordsResponseTest extends BaseSetParserTest<UsageRecord>
.accountName("admin").accountId("2").domainId("1").zoneId("1") .accountName("admin").accountId("2").domainId("1").zoneId("1")
.description("Template Id:203 Size:3117171712") .description("Template Id:203 Size:3117171712")
.usage("24 Hrs").usageType(UsageRecord.UsageType.TEMPLATE).rawUsageHours(24) .usage("24 Hrs").usageType(UsageRecord.UsageType.TEMPLATE).rawUsageHours(24)
.templateId("0").id("203").startDate(start).endDate(end).build()); .size(3117171712l).templateId("0").id("203")
.startDate(start).endDate(end).build());
} }