Skip to content

Commit

Permalink
Fix missing 'tags' in hashcode
Browse files Browse the repository at this point in the history
Both in new AggregatedStatsQueryRequest and existing StatsQueryRequest classes
  • Loading branch information
jotak committed Sep 1, 2016
1 parent 6b2efbd commit 53d85ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Expand Up @@ -22,11 +22,12 @@
import com.google.common.base.MoreObjects;

/**
* @author jtakvorian
* Request object used to provide stats on multiple metrics that are aggregated
* @author Joel Takvorian
*/
public class AggregatedStatsQueryRequest {

private List<String> ids;
private List<String> metrics;

private String start;

Expand All @@ -42,12 +43,12 @@ public class AggregatedStatsQueryRequest {

private boolean stacked;

public List<String> getIds() {
return ids;
public List<String> getMetrics() {
return metrics;
}

public void setIds(List<String> ids) {
this.ids = ids;
public void setMetrics(List<String> metrics) {
this.metrics = metrics;
}

public String getStart() {
Expand Down Expand Up @@ -111,7 +112,7 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AggregatedStatsQueryRequest that = (AggregatedStatsQueryRequest) o;
return Objects.equals(ids, that.ids) &&
return Objects.equals(metrics, that.metrics) &&
Objects.equals(tags, that.tags) &&
Objects.equals(start, that.start) &&
Objects.equals(end, that.end) &&
Expand All @@ -123,12 +124,12 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(ids, start, end, buckets, bucketDuration, percentiles, stacked);
return Objects.hash(metrics, tags, start, end, buckets, bucketDuration, percentiles, stacked);
}

@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("ids", ids)
.add("metrics", metrics)
.add("tags", tags)
.add("start", start)
.add("end", end)
Expand Down
Expand Up @@ -126,7 +126,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(metrics, start, end, buckets, bucketDuration, percentiles, types);
return Objects.hash(metrics, tags, start, end, buckets, bucketDuration, percentiles, types);
}

@Override public String toString() {
Expand Down
Expand Up @@ -185,7 +185,7 @@ protected void findStatsForAggregatedMetrics(AsyncResponse asyncResponse, Aggreg
Map<String, String> tags = Optional.ofNullable(query.getTags())
.map(strTags -> new TagsConverter().fromString(strTags).getTags())
.orElseGet(Collections::emptyMap);
List<String> metricIds = Optional.ofNullable(query.getIds())
List<String> metricIds = Optional.ofNullable(query.getMetrics())
.orElseGet(Collections::emptyList);

if (metricIds.isEmpty() && tags.isEmpty()) {
Expand Down
Expand Up @@ -83,7 +83,7 @@ class GaugeMetricStatisticsITest extends RESTTest {

// Both buckets and bucketDuration parameters provided
badPost(path: "gauges/stats/query", headers: [(tenantHeaderName): tenantId], body: [
ids: ['$metric'],
metrics: ['$metric'],
buckets: 1,
bucketDuration: "1d"
]) { exception ->
Expand Down Expand Up @@ -566,7 +566,7 @@ class GaugeMetricStatisticsITest extends RESTTest {
start: start.millis,
end: start.plusMinutes(5).millis,
buckets: 5,
ids: ['G1', 'G2'],
metrics: ['G1', 'G2'],
stacked: true
],
headers: [(tenantHeaderName): tenantId]
Expand Down Expand Up @@ -666,7 +666,7 @@ class GaugeMetricStatisticsITest extends RESTTest {
start: start.millis,
end: start.plusMinutes(4).millis,
buckets: 1,
ids: ['G1', 'G2'],
metrics: ['G1', 'G2'],
stacked: true
],
headers: [(tenantHeaderName): tenantId]
Expand Down Expand Up @@ -774,7 +774,7 @@ class GaugeMetricStatisticsITest extends RESTTest {
start: start.millis,
end: start.plusMinutes(4).millis,
buckets: 1,
ids: ['G1', 'G2']
metrics: ['G1', 'G2']
],
headers: [(tenantHeaderName): tenantId]
)
Expand Down

0 comments on commit 53d85ee

Please sign in to comment.