use of com.coreos.jetcd.options.DeleteOption in project jetcd by coreos.
the class KVTest method testGetAndDeleteWithPrefix.
@Test
public void testGetAndDeleteWithPrefix() throws Exception {
String prefix = randomString();
ByteString key = ByteString.copyFromUtf8(prefix);
int numPrefixes = 10;
putKeysWithPrefix(prefix, numPrefixes);
// verify get withPrefix.
ListenableFuture<RangeResponse> getFuture = kvClient.get(key, GetOption.newBuilder().withPrefix(key).build());
RangeResponse getResp = getFuture.get();
test.assertEquals(getResp.getCount(), numPrefixes);
// verify del withPrefix.
DeleteOption deleteOpt = DeleteOption.newBuilder().withPrefix(key).build();
ListenableFuture<DeleteRangeResponse> delFuture = kvClient.delete(key, deleteOpt);
DeleteRangeResponse delResp = delFuture.get();
test.assertEquals(delResp.getDeleted(), numPrefixes);
}
Aggregations