jujoramos commented on a change in pull request #5070:
URL: https://github.com/apache/geode/pull/5070#discussion_r422027346



##########
File path: 
geode-core/src/test/java/org/apache/geode/internal/cache/DistributedRegionTest.java
##########
@@ -180,4 +189,75 @@ public void 
regionSyncNotInvokedInPerformSynchronizeForLostMemberTaskIfRegionNot
 
     verify(distributedRegion, never()).synchronizeForLostMember(member, 
lostMemberVersionID);
   }
+
+  @Test
+  public void 
validateAsynchronousEventDispatcherShouldDoNothingWhenDispatcherIdCanNotBeFound()
 {
+    InternalCache internalCache = mock(InternalCache.class);
+    when(internalCache.getAllGatewaySenders())
+        .thenReturn(Collections.singleton(mock(GatewaySender.class)));
+    DistributedRegion distributedRegion = mock(DistributedRegion.class);

Review comment:
       It might be possible but it will require some effort as the 
`DistributedRegion` class doesn't have a default constructor and the 
initialisation logic is not trivial (I tried to do it but need to mock a lot of 
other objects to avoid getting all kind of exceptions)... I can do it if it 
becomes a blocker to merge this `PR`, otherwise I prefer to use the same 
approach the rest of this test class is using.

##########
File path: 
geode-core/src/test/java/org/apache/geode/internal/cache/DistributedRegionTest.java
##########
@@ -180,4 +189,75 @@ public void 
regionSyncNotInvokedInPerformSynchronizeForLostMemberTaskIfRegionNot
 
     verify(distributedRegion, never()).synchronizeForLostMember(member, 
lostMemberVersionID);
   }
+
+  @Test
+  public void 
validateAsynchronousEventDispatcherShouldDoNothingWhenDispatcherIdCanNotBeFound()
 {
+    InternalCache internalCache = mock(InternalCache.class);
+    when(internalCache.getAllGatewaySenders())
+        .thenReturn(Collections.singleton(mock(GatewaySender.class)));
+    DistributedRegion distributedRegion = mock(DistributedRegion.class);
+    when(distributedRegion.getCache()).thenReturn(internalCache);
+    
doCallRealMethod().when(distributedRegion).validateAsynchronousEventDispatcher(anyString());
+
+    
distributedRegion.validateAsynchronousEventDispatcher("nonExistingDispatcher");
+  }
+
+  @Test
+  public void 
validateAsynchronousEventDispatcherShouldDoNothingWhenFoundDispatcherIsSerial() 
{
+    String senderId = "mySender";
+    GatewaySender serialSender = mock(GatewaySender.class);
+    when(serialSender.isParallel()).thenReturn(false);
+    when(serialSender.getId()).thenReturn(senderId);
+    InternalCache internalCache = mock(InternalCache.class);
+    
when(internalCache.getAllGatewaySenders()).thenReturn(Collections.singleton(serialSender));
+    DistributedRegion distributedRegion = mock(DistributedRegion.class);

Review comment:
       See my comments above.

##########
File path: 
geode-core/src/test/java/org/apache/geode/internal/cache/DistributedRegionTest.java
##########
@@ -180,4 +189,75 @@ public void 
regionSyncNotInvokedInPerformSynchronizeForLostMemberTaskIfRegionNot
 
     verify(distributedRegion, never()).synchronizeForLostMember(member, 
lostMemberVersionID);
   }
+
+  @Test
+  public void 
validateAsynchronousEventDispatcherShouldDoNothingWhenDispatcherIdCanNotBeFound()
 {
+    InternalCache internalCache = mock(InternalCache.class);
+    when(internalCache.getAllGatewaySenders())
+        .thenReturn(Collections.singleton(mock(GatewaySender.class)));
+    DistributedRegion distributedRegion = mock(DistributedRegion.class);
+    when(distributedRegion.getCache()).thenReturn(internalCache);
+    
doCallRealMethod().when(distributedRegion).validateAsynchronousEventDispatcher(anyString());
+
+    
distributedRegion.validateAsynchronousEventDispatcher("nonExistingDispatcher");
+  }
+
+  @Test
+  public void 
validateAsynchronousEventDispatcherShouldDoNothingWhenFoundDispatcherIsSerial() 
{
+    String senderId = "mySender";
+    GatewaySender serialSender = mock(GatewaySender.class);
+    when(serialSender.isParallel()).thenReturn(false);
+    when(serialSender.getId()).thenReturn(senderId);
+    InternalCache internalCache = mock(InternalCache.class);
+    
when(internalCache.getAllGatewaySenders()).thenReturn(Collections.singleton(serialSender));
+    DistributedRegion distributedRegion = mock(DistributedRegion.class);
+    when(distributedRegion.getCache()).thenReturn(internalCache);
+    
doCallRealMethod().when(distributedRegion).validateAsynchronousEventDispatcher(anyString());
+
+    distributedRegion.validateAsynchronousEventDispatcher(senderId);
+  }
+
+  @Test
+  public void 
validateAsynchronousEventDispatcherShouldThrowExceptionWhenDispatcherIdMatchesAnExistingParallelAsyncEventQueue()
 {
+    String senderId = "senderId";
+    String regionPath = "thisRegion";
+    String internalSenderId = getSenderIdFromAsyncEventQueueId(senderId);
+    GatewaySender parallelAsyncEventQueue = mock(GatewaySender.class);
+    when(parallelAsyncEventQueue.isParallel()).thenReturn(true);
+    when(parallelAsyncEventQueue.getId()).thenReturn(internalSenderId);
+    InternalCache internalCache = mock(InternalCache.class);
+    when(internalCache.getAllGatewaySenders())
+        .thenReturn(Collections.singleton(parallelAsyncEventQueue));
+    DistributedRegion distributedRegion = mock(DistributedRegion.class);

Review comment:
       See my comments above.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to