Skip to content

Commit df41ee3

Browse files
committed
Fix mock Region to mock RegionAttributes association.
Mock RegionAttributes should be a 'Singleton' object, however, Region.getAttributes() was returning a new (mock) RegionAttributes on every invocation.
1 parent 6145bdb commit df41ee3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-data-geode/src/test/java/org/springframework/data/gemfire/test/mock/GemFireMockObjectsSupport.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -2036,15 +2036,17 @@ public static LuceneService mockLuceneService(Cache mockCache) {
20362036

20372037
@SuppressWarnings("unchecked")
20382038
public static <K, V> Region<K, V> mockRegion(RegionService regionService, String name,
2039-
RegionAttributes<K, V> regionAttributes) {
2039+
RegionAttributes<K, V> regionAttributes) {
20402040

20412041
Map<K, V> data = new ConcurrentHashMap<>();
20422042

20432043
Region<K, V> mockRegion = mock(Region.class, name);
20442044

2045+
RegionAttributes<K, V> mockRegionAttributes = mockRegionAttributes(mockRegion, regionAttributes);
2046+
20452047
Set<Region<?, ?>> subRegions = new CopyOnWriteArraySet<>();
20462048

2047-
when(mockRegion.getAttributes()).thenAnswer(invocation -> mockRegionAttributes(mockRegion, regionAttributes));
2049+
when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
20482050
when(mockRegion.getFullPath()).thenReturn(toRegionPath(name));
20492051
when(mockRegion.getName()).thenReturn(toRegionName(name));
20502052
when(mockRegion.getRegionService()).thenReturn(regionService);

0 commit comments

Comments
 (0)