Fix Region.getEntry() for a given key by returning null if the Optional is empty.

This commit is contained in:
John Blum
2017-12-15 22:41:47 -08:00
parent d817def8a5
commit eae2022bfa

View File

@@ -1413,7 +1413,8 @@ public abstract class MockGemFireObjectsSupport extends MockObjectsSupport {
data.get(invocation.<K>getArgument(0)));
when(mockRegion.getEntry(ArgumentMatchers.<K>any())).thenAnswer(invocation ->
data.entrySet().stream().filter(entry -> entry.getKey().equals(invocation.getArgument(0))).findFirst());
data.entrySet().stream().filter(entry -> entry.getKey().equals(invocation.getArgument(0))).findFirst()
.orElse(null));
when(mockRegion.put(any(), any())).thenAnswer(invocation ->
data.put(invocation.getArgument(0), invocation.getArgument(1)));