Use doAnser(..) instead of thenAnser(..) Mockito mock stubbing for getSubregions(..) and subregions(..) operations on mock Region.

This commit is contained in:
John Blum
2020-09-16 12:13:05 -07:00
parent f896abd33b
commit 2e94141994

View File

@@ -2325,15 +2325,16 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
mockRegionDataAccessOperations(mockRegion, mockRegionAttributes);
when(mockRegion.getSubregion(anyString())).thenAnswer(invocation -> {
doAnswer(invocation -> {
String subRegionPath = toRegionPath(invocation.getArgument(0));
String subRegionFullPath = String.format("%1$s%2$s", mockRegion.getFullPath(), subRegionPath);
return regions.get(subRegionFullPath);
});
when(mockRegion.subregions(anyBoolean())).thenAnswer(invocation -> {
}).when(mockRegion).getSubregion(anyString());
doAnswer(invocation -> {
boolean recursive = invocation.getArgument(0);
@@ -2342,7 +2343,8 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
.flatMap(subRegion -> subRegion.subregions(true).stream())
.collect(Collectors.toSet())
: subRegions;
});
}).when(mockRegion).subregions(anyBoolean());
return rememberMockedRegion(mockRegion);
}