RegionMapCommitPut extends AbstractRegionMapPut { @Override protected boolean isOnlyExisting() { return this.onlyExisting; } RegionMapCommitPut(FocusedRegionMap focusedRegionMap, InternalRegion owner,
      @Released EntryEventImpl callbackEvent, Operation putOp, boolean didDestroy,
      TransactionId txId, TXRmtEvent txEvent, List<EntryEventImpl> pendingCallbacks,
      TXEntryState txEntryState);   }
@Test public void localCreateIsNotOnlyExisting() { when(transactionId.getMemberId()).thenReturn(myId); createInstance(Operation.CREATE, false, null, localTxEntryState); assertThat(instance.isOnlyExisting()).isFalse(); }
@Test public void remoteCreateWithNotAllEventsIsOnlyExisting() { when(transactionId.getMemberId()).thenReturn(remoteId); when(internalRegion.isAllEvents()).thenReturn(false); createInstance(Operation.CREATE, false, txRmtEvent, null); assertThat(instance.isOnlyExisting()).isTrue(); }
@Test public void remoteCreateWithLocalTxEntryStateIsNotOnlyExisting() { when(transactionId.getMemberId()).thenReturn(remoteId); createInstance(Operation.CREATE, false, txRmtEvent, localTxEntryState); assertThat(instance.isOnlyExisting()).isFalse(); }
@Test public void remoteCreateWithAllEventsIsNotOnlyExisting() { when(transactionId.getMemberId()).thenReturn(remoteId); when(internalRegion.isAllEvents()).thenReturn(true); createInstance(Operation.CREATE, false, txRmtEvent, null); assertThat(instance.isOnlyExisting()).isFalse(); }
@Test public void remoteUpdateWithAllEventsIsNotOnlyExisting() { when(transactionId.getMemberId()).thenReturn(remoteId); when(internalRegion.isAllEvents()).thenReturn(true); createInstance(Operation.UPDATE, false, txRmtEvent, null); assertThat(instance.isOnlyExisting()).isFalse(); }
@Test public void remoteUpdateWithAllEventsAndInitializedIsOnlyExisting() { when(transactionId.getMemberId()).thenReturn(remoteId); when(internalRegion.isAllEvents()).thenReturn(true); when(internalRegion.isInitialized()).thenReturn(true); createInstance(Operation.UPDATE, false, txRmtEvent, null); assertThat(instance.isOnlyExisting()).isTrue(); }
@Test public void failedUpdateWithDidDestroyDoesCallTxApplyPutHandleDidDestroy() { when(transactionId.getMemberId()).thenReturn(remoteId); when(internalRegion.getConcurrencyChecksEnabled()).thenReturn(true); createInstance(Operation.UPDATE, true, txRmtEvent, null); RegionEntry result = instance.put(); assertThat(result).isNull(); assertThat(instance.isOnlyExisting()).isTrue(); verify(internalRegion, times(1)).txApplyPutHandleDidDestroy(eq(key)); }
@Test public void successfulUpdateWithDidDestroyDoesNotCallTxApplyPutHandleDidDestroy() { when(transactionId.getMemberId()).thenReturn(remoteId); when(internalRegion.getConcurrencyChecksEnabled()).thenReturn(true); RegionEntry existingEntry = mock(RegionEntry.class); when(focusedRegionMap.getEntry(eq(event))).thenReturn(existingEntry); createInstance(Operation.UPDATE, true, txRmtEvent, null); RegionEntry result = instance.put(); assertThat(result).isNotNull(); assertThat(instance.isOnlyExisting()).isTrue(); verify(internalRegion, never()).txApplyPutHandleDidDestroy(any()); }