Skip to content

Commit 91450ba

Browse files
authored
add hashcode/equals to WaitTest helper classes to avoid log error (#34006)
1 parent 3a146a3 commit 91450ba

File tree

1 file changed

+32
-0
lines changed
  • sdks/java/core/src/test/java/org/apache/beam/sdk/transforms

1 file changed

+32
-0
lines changed

sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/WaitTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.Serializable;
2323
import java.util.Collections;
2424
import java.util.List;
25+
import java.util.Objects;
2526
import java.util.Set;
2627
import java.util.concurrent.atomic.AtomicReference;
2728
import java.util.stream.Collectors;
@@ -95,6 +96,22 @@ public String toString() {
9596
.add("watermarkUpdate", watermarkUpdate)
9697
.toString();
9798
}
99+
100+
@Override
101+
public int hashCode() {
102+
return Objects.hash(processingTime, element, watermarkUpdate);
103+
}
104+
105+
@Override
106+
public boolean equals(Object other) {
107+
if (!(other instanceof Event)) {
108+
return false;
109+
}
110+
Event<?> otherEvent = (Event<?>) other;
111+
return Objects.equals(processingTime, otherEvent.processingTime)
112+
&& Objects.equals(watermarkUpdate, otherEvent.watermarkUpdate)
113+
&& Objects.equals(element, otherEvent.element);
114+
}
98115
}
99116

100117
/**
@@ -238,6 +255,21 @@ public WindowExpirationValue(@Nullable Instant watermarkAdvance, long value) {
238255
this.watermarkAdvance = watermarkAdvance;
239256
this.value = value;
240257
}
258+
259+
@Override
260+
public boolean equals(Object other) {
261+
if (!(other instanceof WindowExpirationValue)) {
262+
return false;
263+
}
264+
WindowExpirationValue otherValue = (WindowExpirationValue) other;
265+
return Objects.equals(watermarkAdvance, otherValue.watermarkAdvance)
266+
&& value == otherValue.value;
267+
}
268+
269+
@Override
270+
public int hashCode() {
271+
return Objects.hash(watermarkAdvance, value);
272+
}
241273
}
242274

243275
@Test

0 commit comments

Comments
 (0)