Use doAnswer(..) instead of thenAnswer(..) Mockito mock stubbing for mock Region.remove(key).

This commit is contained in:
John Blum
2020-09-16 14:59:31 -07:00
parent 8c32143918
commit efed3af760
2 changed files with 6 additions and 4 deletions

View File

@@ -2763,8 +2763,8 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
}).when(mockRegion).putAll(any(Map.class));
// Region.remove(key)
when(mockRegion.remove(any())).thenAnswer(invocation -> {
// Map.remove(key) / Region.remove(key)
doAnswer(invocation -> {
K key = invocation.getArgument(0);
@@ -2795,7 +2795,8 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
.forEach(cacheListener -> cacheListener.afterDestroy(mockEntryEvent));
return invalidatedKeys.remove(key) ? null : value;
});
}).when(mockRegion).remove(any());
// Region.removeAll(:Collection<K>)
doAnswer(invocation -> {

View File

@@ -65,7 +65,7 @@ import org.springframework.data.gemfire.tests.mock.GemFireMockObjectsSupport;
import org.springframework.data.gemfire.tests.support.MapBuilder;
/**
* Unit Tests for Mock {@link Region}.
* Unit Tests for Mock {@link Region} Data Access Operations and Events.
*
* @author John Blum
* @see org.junit.Test
@@ -75,6 +75,7 @@ import org.springframework.data.gemfire.tests.support.MapBuilder;
* @see org.apache.geode.cache.CacheLoader
* @see org.apache.geode.cache.CacheWriter
* @see org.apache.geode.cache.EntryEvent
* @see org.apache.geode.cache.LoaderHelper
* @see org.apache.geode.cache.Region
* @see org.apache.geode.cache.RegionAttributes
* @see org.apache.geode.cache.RegionService