snuyanzin commented on code in PR #30180:
URL: https://github.com/apache/flink/pull/30180#discussion_r4723114172
##########
flink-runtime/src/test/java/org/apache/flink/runtime/iterative/event/EventWithAggregatorsTest.java:
##########
@@ -64,59 +63,31 @@ public void testSerializationOfEventWithAggregateValues() {
aggMap.put(stringValueName, stringAgg);
aggMap.put(longValueName, longAgg);
- Set<String> allNames = new HashSet<String>();
- allNames.add(stringValueName);
- allNames.add(longValueName);
-
- Set<Value> allVals = new HashSet<Value>();
- allVals.add(stringValue);
- allVals.add(longValue);
-
// run the serialization
AllWorkersDoneEvent e = new AllWorkersDoneEvent(aggMap);
IterationEventWithAggregators deserialized =
pipeThroughSerialization(e);
- // verify the result
- String[] names = deserialized.getAggregatorNames();
- Value[] aggregates = deserialized.getAggregates(cl);
+ assertThat(deserialized.getAggregatorNames())
+ .containsExactlyInAnyOrder(stringValueName, longValueName);
+ assertThat(deserialized.getAggregates(cl))
+ .containsExactlyInAnyOrder(stringValue, longValue);
+ }
- Assert.assertEquals(allNames.size(), names.length);
- Assert.assertEquals(allVals.size(), aggregates.length);
+ private IterationEventWithAggregators pipeThroughSerialization(
+ IterationEventWithAggregators event) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ event.write(new DataOutputViewStreamWrapper(baos));
- // check that all the correct names and values are returned
- for (String s : names) {
- allNames.remove(s);
- }
- for (Value v : aggregates) {
- allVals.remove(v);
- }
+ byte[] data = baos.toByteArray();
+ baos.close();
- Assert.assertTrue(allNames.isEmpty());
- Assert.assertTrue(allVals.isEmpty());
- }
+ DataInputViewStreamWrapper in =
+ new DataInputViewStreamWrapper(new ByteArrayInputStream(data));
+ IterationEventWithAggregators newEvent =
event.getClass().newInstance();
Review Comment:
since you are touching it: can we replace it?
it is deprecated since jdk9
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]