Source:
public void testClusterManagerWriteStatusDelegateUse() throws StoreException, IOException, InterruptedException { assumeTrue(isLogSegmented); properties.setProperty(StoreConfig.storeReadOnlyEnableSizeThresholdPercentageName, "65"); properties.setProperty(StoreConfig.storeReadWriteEnableSizeThresholdPercentageDeltaName, "5"); StoreConfig config = new StoreConfig(new VerifiableProperties(properties)); ReplicaId replicaId = getMockReplicaId(tempDirStr); ClusterManagerWriteStatusDelegate clusterManagerWriteStatusDelegate = mock(ClusterManagerWriteStatusDelegate.class); when(clusterManagerWriteStatusDelegate.unseal(anyObject())).thenReturn(true); when(clusterManagerWriteStatusDelegate.seal(anyObject())).thenReturn(true); store.shutdown(); store = createBlobStore(replicaId, config, clusterManagerWriteStatusDelegate); store.start(); verifyZeroInteractions(clusterManagerWriteStatusDelegate); List<MockId> addedIds = put(5, 900, Utils.Infinite_Time); verify(clusterManagerWriteStatusDelegate, times(1)).seal(replicaId); replicaId.setSealedState(true); for (MockId addedId : addedIds) { delete(addedId); } store.shutdown(); store = createBlobStore(replicaId, config, clusterManagerWriteStatusDelegate); store.start(); verifyNoMoreInteractions(clusterManagerWriteStatusDelegate); time.sleep(TimeUnit.DAYS.toMillis(8)); store.compact(store.getCompactionDetails(new CompactAllPolicy(config, time))); verify(clusterManagerWriteStatusDelegate, times(1)).unseal(replicaId); replicaId.setSealedState(true); shutdownStoreAndDeleteFiles(); store = createBlobStore(replicaId, config, clusterManagerWriteStatusDelegate); store.start(); verify(clusterManagerWriteStatusDelegate, times(2)).unseal(replicaId); store.shutdown(); }

Target:
public void testClusterManagerWriteStatusDelegateUse() throws StoreException, IOException, InterruptedException { StoreConfig defaultConfig = changeThreshold(65, 5); StoreTestUtils.MockReplicaId replicaId = getMockReplicaId(tempDirStr); WriteStatusDelegate writeStatusDelegate = mock(WriteStatusDelegate.class); when(writeStatusDelegate.unseal(anyObject())).thenReturn(true); when(writeStatusDelegate.seal(anyObject())).thenReturn(true); restartStore(defaultConfig, replicaId, writeStatusDelegate); verifyZeroInteractions(writeStatusDelegate); put(1, 50, Utils.Infinite_Time); verifyNoMoreInteractions(writeStatusDelegate); List<MockId> addedIds = put(4, 900, Utils.Infinite_Time); verify(writeStatusDelegate, times(1)).seal(replicaId); replicaId.setSealedState(true); restartStore(changeThreshold(99, 1), replicaId, writeStatusDelegate); verify(writeStatusDelegate, times(1)).unseal(replicaId); replicaId.setSealedState(false); restartStore(defaultConfig, replicaId, writeStatusDelegate); verify(writeStatusDelegate, times(2)).seal(replicaId); replicaId.setSealedState(true); if (isLogSegmented) { for (MockId addedId : addedIds) { delete(addedId); } restartStore(defaultConfig, replicaId, writeStatusDelegate); verifyNoMoreInteractions(writeStatusDelegate); time.sleep(TimeUnit.DAYS.toMillis(8)); store.compact(store.getCompactionDetails(new CompactAllPolicy(defaultConfig, time))); verify(writeStatusDelegate, times(2)).unseal(replicaId); replicaId.setSealedState(true); restartStore(defaultConfig, replicaId, writeStatusDelegate); verify(writeStatusDelegate, times(3)).unseal(replicaId); } store.shutdown(); }