Fix equals/hashCode
@@ -21,7 +21,8 @@ public class MetricsMock implements Metric {
@Override
public void set(String key, Number val, Context ctx) {
- Map<String, Number> metricsMap = metrics.getOrDefault(ctx, new HashMap<>());
+ metrics.putIfAbsent(ctx, new HashMap<>());
+ Map<String, Number> metricsMap = metrics.get(ctx);
metricsMap.put(key, val);
}
@@ -76,13 +77,16 @@ public class MetricsMock implements Metric {
}
@Override
- public boolean equals(Object obj) {
- return Objects.deepEquals(obj, dimensions);
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ MapContext that = (MapContext) o;
+ return dimensions.equals(that.dimensions);
}
@Override
public int hashCode() {
- return Objects.toString(dimensions).hashCode();
+ return Objects.hash(dimensions);
}
public Map<String, String> getDimensions() {
