Myasuka commented on a change in pull request #12078:
URL: https://github.com/apache/flink/pull/12078#discussion_r425817891
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/state/ttl/TtlMapStateAllEntriesTestContext.java
##########
@@ -64,6 +64,6 @@ public void update(Map<Integer, String> map) throws Exception
{
@Override
public Object getOriginal() throws Exception {
- return ttlState.original.entries() == null ?
Collections.emptySet() : ttlState.original.entries();
+ return ttlState.original.entries().iterator().hasNext() ?
ttlState.original.entries() : emptyValue;
Review comment:
I think this implementation should already violate the purpose of unit
test.
This method should return the **actual** value and then verify whether the
result equals to the **expected** value. However, you just return the
`emptyValue` which is the actual **expected** value, and the verification will
always return true.
I think one of the walk-around solution is to add a method `boolean
isOriginalEmptyValue(Object originalValue)` in `TtlStateTestContextBase`, which
will return whether the original value equals to the `emptyValue`. By doing so,
you could override this method in `TtlMapStateAllEntriesTestContext` and return
whether the original value is actually an empty iterable.
Thus, we could replace `assertEquals("Expired original state should be
unavailable", ctx().emptyValue, ctx().getOriginal());` to
`assertTrue(ctx().isOriginalEmptyValue(ctx().getOriginal()));`
Any other better test solution is also welcome.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]