use of io.etcd.jetcd.options.DeleteOption in project jetcd by coreos.
the class KVTest method testGetAndDeleteWithPrefix.
@Test
public void testGetAndDeleteWithPrefix() throws Exception {
String prefix = randomString();
ByteSequence key = bytesOf(prefix);
int numPrefixes = 10;
putKeysWithPrefix(prefix, numPrefixes);
// verify get withPrefix.
CompletableFuture<GetResponse> getFuture = kvClient.get(key, GetOption.newBuilder().isPrefix(true).build());
GetResponse getResp = getFuture.get();
assertThat(getResp.getCount()).isEqualTo(numPrefixes);
// verify del withPrefix.
DeleteOption deleteOpt = DeleteOption.newBuilder().isPrefix(true).build();
CompletableFuture<DeleteResponse> delFuture = kvClient.delete(key, deleteOpt);
DeleteResponse delResp = delFuture.get();
assertThat(delResp.getDeleted()).isEqualTo(numPrefixes);
}
Aggregations