kirklund commented on code in PR #7493:
URL: https://github.com/apache/geode/pull/7493#discussion_r857815443


##########
geode-core/src/test/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSenderTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.cache.execute;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
+
+public class PartitionedRegionFunctionResultSenderTest {
+  DistributionManager dm = mock(DistributionManager.class);
+  PartitionedRegion region = mock(PartitionedRegion.class);
+  ATestResultCollector rc = new ATestResultCollector();
+  ServerToClientFunctionResultSender serverToClientFunctionResultSender =
+      mock(ServerToClientFunctionResultSender.class);
+  FunctionStats functionStats = mock(FunctionStats.class);
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.lastResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }

Review Comment:
   You should always add assertions for expected exceptions:
   ```
   Throwable thrown = catchThrowable(() -> {
     sender.lastResult(new FunctionException());
   }
   
   assertThat(thrown)
     .isInstanceOf(FunctionException.class)
     .(any other assertions that are valuable?)
   ```



##########
geode-core/src/test/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSenderTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.cache.execute;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
+
+public class PartitionedRegionFunctionResultSenderTest {
+  DistributionManager dm = mock(DistributionManager.class);
+  PartitionedRegion region = mock(PartitionedRegion.class);
+  ATestResultCollector rc = new ATestResultCollector();
+  ServerToClientFunctionResultSender serverToClientFunctionResultSender =
+      mock(ServerToClientFunctionResultSender.class);
+  FunctionStats functionStats = mock(FunctionStats.class);
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.lastResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_OnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, true, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }

Review Comment:
   Another expected exception that needs assertion(s).



##########
geode-core/src/test/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSenderTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.cache.execute;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
+
+public class PartitionedRegionFunctionResultSenderTest {
+  DistributionManager dm = mock(DistributionManager.class);
+  PartitionedRegion region = mock(PartitionedRegion.class);
+  ATestResultCollector rc = new ATestResultCollector();
+  ServerToClientFunctionResultSender serverToClientFunctionResultSender =
+      mock(ServerToClientFunctionResultSender.class);
+  FunctionStats functionStats = mock(FunctionStats.class);
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.lastResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_OnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, true, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, false, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    sender.sendException(new FunctionException());
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInSendResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .sendResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.sendResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }

Review Comment:
   Another expected exception that needs assertion(s).



##########
geode-core/src/test/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSenderTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.cache.execute;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
+
+public class PartitionedRegionFunctionResultSenderTest {
+  DistributionManager dm = mock(DistributionManager.class);
+  PartitionedRegion region = mock(PartitionedRegion.class);
+  ATestResultCollector rc = new ATestResultCollector();
+  ServerToClientFunctionResultSender serverToClientFunctionResultSender =
+      mock(ServerToClientFunctionResultSender.class);
+  FunctionStats functionStats = mock(FunctionStats.class);
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.lastResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_OnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, true, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, false, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    sender.sendException(new FunctionException());
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }

Review Comment:
   Another expected exception that needs assertion(s).



##########
geode-core/src/test/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSenderTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.cache.execute;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
+
+public class PartitionedRegionFunctionResultSenderTest {
+  DistributionManager dm = mock(DistributionManager.class);
+  PartitionedRegion region = mock(PartitionedRegion.class);
+  ATestResultCollector rc = new ATestResultCollector();
+  ServerToClientFunctionResultSender serverToClientFunctionResultSender =
+      mock(ServerToClientFunctionResultSender.class);
+  FunctionStats functionStats = mock(FunctionStats.class);
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.lastResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_OnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, true, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, false, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    sender.sendException(new FunctionException());
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInSendResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .sendResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.sendResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInSendResultFailsEndResultsIsCalled_NotOnlyLocal_OnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .sendResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, true, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    try {
+      sender.sendResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInSendResultFailsEndResultsIsCalled_NotOnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .sendResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, false, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    try {
+      sender.sendResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }

Review Comment:
   Another expected exception that needs assertion(s).



##########
geode-core/src/test/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSenderTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.cache.execute;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
+
+public class PartitionedRegionFunctionResultSenderTest {
+  DistributionManager dm = mock(DistributionManager.class);
+  PartitionedRegion region = mock(PartitionedRegion.class);
+  ATestResultCollector rc = new ATestResultCollector();
+  ServerToClientFunctionResultSender serverToClientFunctionResultSender =
+      mock(ServerToClientFunctionResultSender.class);
+  FunctionStats functionStats = mock(FunctionStats.class);
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)

Review Comment:
   I recommend either using a cause like `new FunctionException(new 
CauseException("for test")` and then include the cause and cause message in the 
assertions or at least use a custom message like `new FunctionException("for 
test")`.



##########
geode-core/src/test/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSenderTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.cache.execute;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
+
+public class PartitionedRegionFunctionResultSenderTest {
+  DistributionManager dm = mock(DistributionManager.class);
+  PartitionedRegion region = mock(PartitionedRegion.class);
+  ATestResultCollector rc = new ATestResultCollector();
+  ServerToClientFunctionResultSender serverToClientFunctionResultSender =
+      mock(ServerToClientFunctionResultSender.class);
+  FunctionStats functionStats = mock(FunctionStats.class);
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.lastResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_OnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, true, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInLastResultFailsEndResultsIsCalled_NotOnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, false, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    sender.sendException(new FunctionException());
+    try {
+      sender.lastResult(new FunctionException(), true, rc, null);
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInSendResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .sendResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, 
true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.sendResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }
+
+    assertThat(rc.isEndResultsCalled()).isEqualTo(true);
+  }
+
+  @Test
+  public void 
whenResponseToClientInSendResultFailsEndResultsIsCalled_NotOnlyLocal_OnlyRemote()
 {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .sendResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, false, true, 
true,
+            new TestFunction(), new int[2], (x, y) -> functionStats);
+
+    try {
+      sender.sendResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }

Review Comment:
   Another expected exception that needs assertion(s).



-- 
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.

To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to