BucketOperatorImpl implements BucketOperator { @Override public void createRedundantBucket(InternalDistributedMember targetMember, int bucketId, Map<String, Long> colocatedRegionBytes, Completion completion) { boolean result = false; try { result = rebalanceOp.createRedundantBucketForRegion(targetMember, bucketId); } finally { if (result) { completion.onSuccess(); } else { completion.onFailure(); } } } BucketOperatorImpl(PartitionedRegionRebalanceOp rebalanceOp); @Override boolean moveBucket(InternalDistributedMember source, InternalDistributedMember target,
      int bucketId, Map<String, Long> colocatedRegionBytes); @Override boolean movePrimary(InternalDistributedMember source, InternalDistributedMember target,
      int bucketId); @Override void createRedundantBucket(InternalDistributedMember targetMember, int bucketId,
      Map<String, Long> colocatedRegionBytes, Completion completion); @Override void waitForOperations(); @Override boolean removeBucket(InternalDistributedMember targetMember, int bucketId,
      Map<String, Long> colocatedRegionBytes);  }
@Test public void createBucketShouldDelegateToParRegRebalanceOpCreateRedundantBucketForRegion() throws UnknownHostException { doReturn(true).when(rebalanceOp).createRedundantBucketForRegion(targetMember, bucketId); operator.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completion); verify(rebalanceOp, times(1)).createRedundantBucketForRegion(targetMember, bucketId); }
@Test public void createBucketShouldInvokeOnSuccessIfCreateBucketSucceeds() { doReturn(true).when(rebalanceOp).createRedundantBucketForRegion(targetMember, bucketId); operator.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completion); verify(rebalanceOp, times(1)).createRedundantBucketForRegion(targetMember, bucketId); verify(completion, times(1)).onSuccess(); }
@Test public void createBucketShouldInvokeOnFailureIfCreateBucketFails() { doReturn(false).when(rebalanceOp).createRedundantBucketForRegion(targetMember, bucketId); operator.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completion); verify(rebalanceOp, times(1)).createRedundantBucketForRegion(targetMember, bucketId); verify(completion, times(1)).onFailure(); }