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

项目: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 CuratorTransactionBridge forPath(String path, byte[] data) throws Exception {
    this.path = path;
    this.data = data;
    return returnMe;
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public CuratorTransactionBridge forPath(String path) throws Exception {
    this.path = path;
    this.data = null;
    return returnMe;
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public Pathable<CuratorTransactionBridge> withVersion(int version) {
    throw new UnsupportedOperationException();
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public ACLPathAndBytesable<CuratorTransactionBridge> withMode(CreateMode mode) {
    throw new UnsupportedOperationException();
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public PathAndBytesable<CuratorTransactionBridge> withACL(List<ACL> aclList) {
    throw new UnsupportedOperationException();
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public ACLPathAndBytesable<CuratorTransactionBridge> compressed() {
    throw new UnsupportedOperationException();
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public PathAndBytesable<CuratorTransactionBridge> withVersion(int version) {
    throw new UnsupportedOperationException();
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public PathAndBytesable<CuratorTransactionBridge> compressed() {
    throw new UnsupportedOperationException();
}
项目:dcos-commons    文件:CuratorPersisterTest.java   
@Override
public Pathable<CuratorTransactionBridge> withVersion(int version) {
    throw new UnsupportedOperationException();
}
项目:vespa    文件:MockCurator.java   
@Override
public PathAndBytesable<CuratorTransactionBridge> withACL(List<ACL> list) {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
项目:vespa    文件:MockCurator.java   
@Override
public ACLPathAndBytesable<CuratorTransactionBridge> compressed() {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
项目:vespa    文件:MockCurator.java   
@Override
public ACLPathAndBytesable<CuratorTransactionBridge> withMode(CreateMode createMode) {
    this.createMode = createMode;
    return this;
}
项目:vespa    文件:MockCurator.java   
@Override
public CuratorTransactionBridge forPath(String s, byte[] bytes) throws Exception {
    createNode(s, bytes, false, createMode, newRoot, delayedListener);
    return new MockCuratorTransactionBridge();
}
项目:vespa    文件:MockCurator.java   
@Override
public CuratorTransactionBridge forPath(String s) throws Exception {
    createNode(s, new byte[0], false, createMode, newRoot, delayedListener);
    return new MockCuratorTransactionBridge();
}
项目:vespa    文件:MockCurator.java   
@Override
public Pathable<CuratorTransactionBridge> withVersion(int i) {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
项目:vespa    文件:MockCurator.java   
@Override
public CuratorTransactionBridge forPath(String path) throws Exception {
    deleteNode(path, false, newRoot, delayedListener);
    return new MockCuratorTransactionBridge();
}
项目:vespa    文件:MockCurator.java   
@Override
public PathAndBytesable<CuratorTransactionBridge> compressed() {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
项目:vespa    文件:MockCurator.java   
@Override
public PathAndBytesable<CuratorTransactionBridge> withVersion(int i) {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
项目:vespa    文件:MockCurator.java   
@Override
public CuratorTransactionBridge forPath(String s, byte[] bytes) throws Exception {
    MockCurator.this.setData(s, bytes, newRoot, delayedListener);
    return new MockCuratorTransactionBridge();
}
项目:vespa    文件:MockCurator.java   
@Override
public CuratorTransactionBridge forPath(String s) throws Exception {
    MockCurator.this.setData(s, new byte[0], newRoot, delayedListener);
    return new MockCuratorTransactionBridge();
}