You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2021/01/14 00:34:33 UTC

[GitHub] [geode] luissson opened a new pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

luissson opened a new pull request #5901:
URL: https://github.com/apache/geode/pull/5901


   Thank you for submitting a contribution to Apache Geode.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   - [ ] Does `gradlew build` run cleanly?
   
   - [ ] Have you written or updated unit tests to verify your changes?
   
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   
   ### Note:
   Please ensure that once the PR is submitted, check Concourse for build issues and
   submit an update to your PR as soon as possible. If you need help, please send an
   email to dev@geode.apache.org.
   


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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567032550



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/PartitionedTXRegionStubTest.java
##########
@@ -127,6 +129,36 @@ public void destroyExistingEntryThrowsTransactionDataNodeHasDepartedExceptionIfI
     verify(stub, never()).trackBucketForTx(keyInfo);
   }
 
+  @Test
+  public void getEntryForIteratorReturnsEntryGotFromLocal() throws Exception {
+    PartitionedTXRegionStub stub = spy(new PartitionedTXRegionStub(txStateStub, partitionedRegion));
+    EntrySnapshot entry = mock(EntrySnapshot.class);
+
+    when(event.getRegion()).thenReturn(partitionedRegion);
+    when(partitionedRegion.getBucketPrimary(1))
+        .thenReturn((InternalDistributedMember) remoteTransactionHost);
+    when(partitionedRegion.getEntryRemotely((InternalDistributedMember) remoteTransactionHost, 1,
+        key, false, true)).thenReturn(entry);
+
+    assertThat(stub.getEntryForIterator(keyInfo, true)).isEqualTo(entry);
+    verify(stub).trackBucketForTx(keyInfo);
+  }
+
+  @Test
+  public void getEntryForIteratorReturnsEntryGotFromRemote() throws Exception {

Review comment:
       Similarly getEntryForIteratorReturnsEntryGotFromAnyDataHosts is more appropriate here. 
   Also the method does not throw Exception, please remove it to avoid warnings.
   




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567036594



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/DistributedTXRegionStubTest.java
##########
@@ -0,0 +1,371 @@
+/*
+ * 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.tx;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowable;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.geode.cache.EntryNotFoundException;
+import org.apache.geode.cache.RegionDestroyedException;
+import org.apache.geode.cache.TransactionDataNodeHasDepartedException;
+import org.apache.geode.cache.TransactionDataNotColocatedException;
+import org.apache.geode.cache.TransactionException;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.internal.cache.DistributedPutAllOperation;
+import org.apache.geode.internal.cache.DistributedRegion;
+import org.apache.geode.internal.cache.DistributedRemoveAllOperation;
+import org.apache.geode.internal.cache.EntryEventImpl;
+import org.apache.geode.internal.cache.EventID;
+import org.apache.geode.internal.cache.KeyInfo;
+import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.internal.cache.RemoteOperationException;
+import org.apache.geode.internal.cache.TXStateStub;
+import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
+import org.apache.geode.internal.cache.tier.sockets.VersionedObjectList;
+
+public class DistributedTXRegionStubTest {
+
+  private TXStateStub txStateStub;
+  private DistributedRegion distributedRegion;
+  private Object expectedObject;
+  private EntryEventImpl event;
+  private DistributedMember remoteTransactionHost;
+  private KeyInfo keyInfo;
+  private Set<InternalDistributedMember> failures;

Review comment:
       failures is never used.




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567035135



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/PartitionedTXRegionStubTest.java
##########
@@ -139,6 +171,15 @@ public void getEntryReturnsEntryGotFromRemote() throws Exception {
     verify(stub).trackBucketForTx(keyInfo);
   }
 
+  @Test
+  public void isBucketNotFoundExceptionReturnTrue() throws Exception {
+    PartitionedTXRegionStub stub = spy(new PartitionedTXRegionStub(txStateStub, partitionedRegion));
+    BucketNotFoundException ex = mock(BucketNotFoundException.class);
+    Throwable cause = mock(Throwable.class);

Review comment:
       cause is not being used, do you want to add another test case that BucketNotFoundException was wrapped as a cause?




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567030717



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/PartitionedTXRegionStubTest.java
##########
@@ -127,6 +129,36 @@ public void destroyExistingEntryThrowsTransactionDataNodeHasDepartedExceptionIfI
     verify(stub, never()).trackBucketForTx(keyInfo);
   }
 
+  @Test
+  public void getEntryForIteratorReturnsEntryGotFromLocal() throws Exception {

Review comment:
       getEntryForIteratorReturnsEntryGotFromLocal is misleading here. Possibly getEntryForIteratorReturnsEntryGotFromTransactionHost is more appropriate.




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r566447639



##########
File path: geode-core/src/main/java/org/apache/geode/internal/cache/tx/DistributedTXRegionStub.java
##########
@@ -120,12 +137,11 @@ public boolean containsKey(KeyInfo keyInfo) {
     }
   }
 
-
   @Override
   public boolean containsValueForKey(KeyInfo keyInfo) {
     try {
-      RemoteContainsKeyValueResponse response = RemoteContainsKeyValueMessage
-          .send((InternalDistributedMember) state.getTarget(), region, keyInfo.getKey(), true);
+      RemoteContainsKeyValueResponse response = sendRemoteContainsKeyValueMessage(
+          (InternalDistributedMember) state.getTarget(), keyInfo.getKey());

Review comment:
       The method lost valueCheck (true) value with the current method implementation.
   RemoteContainsKeyValueResponse send(InternalDistributedMember recipient,
         LocalRegion r, Object key, boolean valueCheck) 




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



[GitHub] [geode] pivotal-eshu merged pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu merged pull request #5901:
URL: https://github.com/apache/geode/pull/5901


   


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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567036594



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/DistributedTXRegionStubTest.java
##########
@@ -0,0 +1,371 @@
+/*
+ * 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.tx;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowable;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.geode.cache.EntryNotFoundException;
+import org.apache.geode.cache.RegionDestroyedException;
+import org.apache.geode.cache.TransactionDataNodeHasDepartedException;
+import org.apache.geode.cache.TransactionDataNotColocatedException;
+import org.apache.geode.cache.TransactionException;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.internal.cache.DistributedPutAllOperation;
+import org.apache.geode.internal.cache.DistributedRegion;
+import org.apache.geode.internal.cache.DistributedRemoveAllOperation;
+import org.apache.geode.internal.cache.EntryEventImpl;
+import org.apache.geode.internal.cache.EventID;
+import org.apache.geode.internal.cache.KeyInfo;
+import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.internal.cache.RemoteOperationException;
+import org.apache.geode.internal.cache.TXStateStub;
+import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
+import org.apache.geode.internal.cache.tier.sockets.VersionedObjectList;
+
+public class DistributedTXRegionStubTest {
+
+  private TXStateStub txStateStub;
+  private DistributedRegion distributedRegion;
+  private Object expectedObject;
+  private EntryEventImpl event;
+  private DistributedMember remoteTransactionHost;
+  private KeyInfo keyInfo;
+  private Set<InternalDistributedMember> failures;

Review comment:
       failure is never used.




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567023414



##########
File path: geode-core/src/main/java/org/apache/geode/internal/cache/tx/DistributedTXRegionStub.java
##########
@@ -176,7 +202,7 @@ public boolean putEntry(EntryEventImpl event, boolean ifNew, boolean ifOld,
     final InternalRegion r = event.getRegion();

Review comment:
       Original initialized false is redundant. You may want to clean it as well.




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567018485



##########
File path: geode-core/src/main/java/org/apache/geode/internal/cache/tx/DistributedTXRegionStub.java
##########
@@ -86,12 +93,17 @@ public Entry getEntry(KeyInfo keyInfo, boolean allowTombstone) {
     }
   }
 
+  RemoteFetchEntryMessage.FetchEntryResponse sendRemoteFetchEntryMessage(
+      InternalDistributedMember recipient, LocalRegion region, Object key)

Review comment:
       recipient is never being used in the method.




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567025251



##########
File path: geode-core/src/main/java/org/apache/geode/internal/cache/tx/DistributedTXRegionStub.java
##########
@@ -146,9 +167,8 @@ public Object findObject(KeyInfo keyInfo, boolean isCreate, boolean generateCall
     final Object key = keyInfo.getKey();

Review comment:
       Original initialized null value is redundant; you may want to remove it as well.




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567037590



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/DistributedTXRegionStubTest.java
##########
@@ -0,0 +1,371 @@
+/*
+ * 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.tx;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowable;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.geode.cache.EntryNotFoundException;
+import org.apache.geode.cache.RegionDestroyedException;
+import org.apache.geode.cache.TransactionDataNodeHasDepartedException;
+import org.apache.geode.cache.TransactionDataNotColocatedException;
+import org.apache.geode.cache.TransactionException;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.internal.cache.DistributedPutAllOperation;
+import org.apache.geode.internal.cache.DistributedRegion;
+import org.apache.geode.internal.cache.DistributedRemoveAllOperation;
+import org.apache.geode.internal.cache.EntryEventImpl;
+import org.apache.geode.internal.cache.EventID;
+import org.apache.geode.internal.cache.KeyInfo;
+import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.internal.cache.RemoteOperationException;
+import org.apache.geode.internal.cache.TXStateStub;
+import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
+import org.apache.geode.internal.cache.tier.sockets.VersionedObjectList;
+
+public class DistributedTXRegionStubTest {
+
+  private TXStateStub txStateStub;
+  private DistributedRegion distributedRegion;
+  private Object expectedObject;
+  private EntryEventImpl event;
+  private DistributedMember remoteTransactionHost;
+  private KeyInfo keyInfo;
+  private Set<InternalDistributedMember> failures;
+
+
+  @Before
+  public void setup() {
+    txStateStub = mock(TXStateStub.class);
+    distributedRegion = mock(DistributedRegion.class, RETURNS_DEEP_STUBS);
+    event = mock(EntryEventImpl.class);
+    expectedObject = new Object();
+    remoteTransactionHost = mock(InternalDistributedMember.class);
+    keyInfo = mock(KeyInfo.class);
+
+    when(txStateStub.getTarget()).thenReturn(remoteTransactionHost);
+    when(event.getEventId()).thenReturn(mock(EventID.class));
+    when(event.getRegion()).thenReturn(distributedRegion);
+    when(keyInfo.getKey()).thenReturn(expectedObject);
+  }
+
+  @Test
+  public void destroyExistingEntryTranslatesRegionDestroyedException() throws Exception {

Review comment:
       Exception is not thrown.




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567040718



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/DistributedTXRegionStubTest.java
##########
@@ -0,0 +1,371 @@
+/*
+ * 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.tx;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowable;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.geode.cache.EntryNotFoundException;
+import org.apache.geode.cache.RegionDestroyedException;
+import org.apache.geode.cache.TransactionDataNodeHasDepartedException;
+import org.apache.geode.cache.TransactionDataNotColocatedException;
+import org.apache.geode.cache.TransactionException;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.internal.cache.DistributedPutAllOperation;
+import org.apache.geode.internal.cache.DistributedRegion;
+import org.apache.geode.internal.cache.DistributedRemoveAllOperation;
+import org.apache.geode.internal.cache.EntryEventImpl;
+import org.apache.geode.internal.cache.EventID;
+import org.apache.geode.internal.cache.KeyInfo;
+import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.internal.cache.RemoteOperationException;
+import org.apache.geode.internal.cache.TXStateStub;
+import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
+import org.apache.geode.internal.cache.tier.sockets.VersionedObjectList;
+
+public class DistributedTXRegionStubTest {
+
+  private TXStateStub txStateStub;
+  private DistributedRegion distributedRegion;
+  private Object expectedObject;
+  private EntryEventImpl event;
+  private DistributedMember remoteTransactionHost;
+  private KeyInfo keyInfo;
+  private Set<InternalDistributedMember> failures;
+
+
+  @Before
+  public void setup() {
+    txStateStub = mock(TXStateStub.class);
+    distributedRegion = mock(DistributedRegion.class, RETURNS_DEEP_STUBS);
+    event = mock(EntryEventImpl.class);
+    expectedObject = new Object();
+    remoteTransactionHost = mock(InternalDistributedMember.class);
+    keyInfo = mock(KeyInfo.class);
+
+    when(txStateStub.getTarget()).thenReturn(remoteTransactionHost);
+    when(event.getEventId()).thenReturn(mock(EventID.class));
+    when(event.getRegion()).thenReturn(distributedRegion);
+    when(keyInfo.getKey()).thenReturn(expectedObject);
+  }
+
+  @Test
+  public void destroyExistingEntryTranslatesRegionDestroyedException() throws Exception {
+    DistributedTXRegionStub stub = spy(new DistributedTXRegionStub(txStateStub, distributedRegion));
+
+    when(event.getRegion()).thenThrow(RegionDestroyedException.class);
+
+    Throwable caughtException =
+        catchThrowable(() -> stub.destroyExistingEntry(event, true, expectedObject));
+
+    assertThat(caughtException).isInstanceOf(TransactionDataNotColocatedException.class);
+  }
+
+  @Test
+  public void destroyExistingEntryTranslatesRemoteOperationException() throws Exception {
+    DistributedTXRegionStub stub = spy(new DistributedTXRegionStub(txStateStub, distributedRegion));
+    when(event.getRegion()).thenReturn(distributedRegion);
+
+    doThrow(RemoteOperationException.class).when(stub).sendRemoteDestroyMessage(event,
+        expectedObject);
+
+    Throwable caughtException =
+        catchThrowable(() -> stub.destroyExistingEntry(event, true, expectedObject));
+
+    assertThat(caughtException).isInstanceOf(TransactionDataNodeHasDepartedException.class);
+  }
+
+  @Test
+  public void getEntryEntryNotFoundExceptionReturnNull() throws Exception {

Review comment:
       Exception is never thrown.
   
   Also, will getEntryReturnsNullIfGotEntryNotFoundException be a better method name?




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567034664



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/PartitionedTXRegionStubTest.java
##########
@@ -139,6 +171,15 @@ public void getEntryReturnsEntryGotFromRemote() throws Exception {
     verify(stub).trackBucketForTx(keyInfo);
   }
 
+  @Test
+  public void isBucketNotFoundExceptionReturnTrue() throws Exception {

Review comment:
       Exception is not thrown from the method.




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



[GitHub] [geode] pivotal-eshu commented on a change in pull request #5901: GEODE-8797: Increase code coverage on TXRegionStub classes

Posted by GitBox <gi...@apache.org>.
pivotal-eshu commented on a change in pull request #5901:
URL: https://github.com/apache/geode/pull/5901#discussion_r567035135



##########
File path: geode-core/src/test/java/org/apache/geode/internal/cache/tx/PartitionedTXRegionStubTest.java
##########
@@ -139,6 +171,15 @@ public void getEntryReturnsEntryGotFromRemote() throws Exception {
     verify(stub).trackBucketForTx(keyInfo);
   }
 
+  @Test
+  public void isBucketNotFoundExceptionReturnTrue() throws Exception {
+    PartitionedTXRegionStub stub = spy(new PartitionedTXRegionStub(txStateStub, partitionedRegion));
+    BucketNotFoundException ex = mock(BucketNotFoundException.class);
+    Throwable cause = mock(Throwable.class);

Review comment:
       cause is not being used, do you want to add another test case that BucketNotFoundException was wrapped as a cause?
   Also a negative case -- isBucketNotFoundExceptionReturnFalse case?




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