Java 类org.apache.curator.framework.api.transaction.TransactionCreateBuilder 实例源码

项目:elastic-jobx    文件:ShardingServiceTest.java   
@Test
public void assertPersistShardingInfoTransactionExecutionCallback() throws Exception {
    CuratorTransactionFinal curatorTransactionFinal = mock(CuratorTransactionFinal.class);
    TransactionCreateBuilder transactionCreateBuilder = mock(TransactionCreateBuilder.class);
    TransactionDeleteBuilder transactionDeleteBuilder = mock(TransactionDeleteBuilder.class);
    CuratorTransactionBridge curatorTransactionBridge = mock(CuratorTransactionBridge.class);
    when(curatorTransactionFinal.create()).thenReturn(transactionCreateBuilder);
    when(transactionCreateBuilder.forPath("/testJob/servers/host0/sharding", "0,1,2".getBytes())).thenReturn(curatorTransactionBridge);
    when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal);
    when(curatorTransactionFinal.delete()).thenReturn(transactionDeleteBuilder);
    when(transactionDeleteBuilder.forPath("/testJob/leader/sharding/necessary")).thenReturn(curatorTransactionBridge);
    when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal);
    when(curatorTransactionFinal.delete()).thenReturn(transactionDeleteBuilder);
    when(transactionDeleteBuilder.forPath("/testJob/leader/sharding/processing")).thenReturn(curatorTransactionBridge);
    when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal);
    Map<String, List<Integer>> shardingItems = new HashMap<String, List<Integer>>(1);
    shardingItems.put("host0", Arrays.asList(0, 1, 2));
    ShardingService.PersistShardingInfoTransactionExecutionCallback actual = shardingService.new PersistShardingInfoTransactionExecutionCallback(shardingItems);
    actual.execute(curatorTransactionFinal);
    verify(curatorTransactionFinal).create();
    verify(transactionCreateBuilder).forPath("/testJob/servers/host0/sharding", "0,1,2".getBytes());
    verify(curatorTransactionFinal, times(2)).delete();
    verify(transactionDeleteBuilder).forPath("/testJob/leader/sharding/necessary");
    verify(transactionDeleteBuilder).forPath("/testJob/leader/sharding/processing");
    verify(curatorTransactionBridge, times(3)).and();
}
项目:ElasticJob    文件:ShardingServiceTest.java   
@Test
public void assertPersistShardingInfoTransactionExecutionCallback() throws Exception {
    CuratorTransactionFinal curatorTransactionFinal = mock(CuratorTransactionFinal.class);
    TransactionCreateBuilder transactionCreateBuilder = mock(TransactionCreateBuilder.class);
    TransactionDeleteBuilder transactionDeleteBuilder = mock(TransactionDeleteBuilder.class);
    CuratorTransactionBridge curatorTransactionBridge = mock(CuratorTransactionBridge.class);
    when(curatorTransactionFinal.create()).thenReturn(transactionCreateBuilder);
    when(transactionCreateBuilder.forPath("/testJob/servers/host0/sharding", "0,1,2".getBytes())).thenReturn(curatorTransactionBridge);
    when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal);
    when(curatorTransactionFinal.delete()).thenReturn(transactionDeleteBuilder);
    when(transactionDeleteBuilder.forPath("/testJob/leader/sharding/necessary")).thenReturn(curatorTransactionBridge);
    when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal);
    when(curatorTransactionFinal.delete()).thenReturn(transactionDeleteBuilder);
    when(transactionDeleteBuilder.forPath("/testJob/leader/sharding/processing")).thenReturn(curatorTransactionBridge);
    when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal);
    Map<String, List<Integer>> shardingItems = new HashMap<>(1);
    shardingItems.put("host0", Arrays.asList(0, 1, 2));
    ShardingService.PersistShardingInfoTransactionExecutionCallback actual = shardingService.new PersistShardingInfoTransactionExecutionCallback(shardingItems);
    actual.execute(curatorTransactionFinal);
    verify(curatorTransactionFinal).create();
    verify(transactionCreateBuilder).forPath("/testJob/servers/host0/sharding", "0,1,2".getBytes());
    verify(curatorTransactionFinal, times(2)).delete();
    verify(transactionDeleteBuilder).forPath("/testJob/leader/sharding/necessary");
    verify(transactionDeleteBuilder).forPath("/testJob/leader/sharding/processing");
    verify(curatorTransactionBridge, times(3)).and();
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public TransactionCreateBuilder create() {
    TestCreate operation = new TestCreate(this);
    operations.add(operation);
    return operation;
}
项目:vespa    文件:MockCurator.java   
@Override
public TransactionCreateBuilder create() {
    ensureNotCommitted();
    return new MockTransactionCreateBuilder();
}
项目:curator    文件:TransactionOpImpl.java   
@Override
public TransactionCreateBuilder<CuratorOp> create()
{
    ExtractingCuratorOp op = new ExtractingCuratorOp();
    return new CreateBuilderImpl(client).<CuratorOp>asTransactionCreateBuilder(op, op.getRecord());
}