use of com.couchbase.client.java.AsyncBucket in project samza by apache.
the class TestCouchbaseTableWriteFunction method testPutAsyncJsonObjectValue.
@Test
public void testPutAsyncJsonObjectValue() throws Exception {
String key = "key";
JsonObject value = JsonObject.fromJson("{\"id\": 1}");
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableWriteFunction<JsonObject> writeFunction = createAndInit(bucket, asyncBucket);
when(asyncBucket.upsert(any(Document.class), anyLong(), any(TimeUnit.class))).thenReturn(Observable.just(null));
assertNull(writeFunction.putAsync(key, value).get());
}
use of com.couchbase.client.java.AsyncBucket in project samza by apache.
the class TestCouchbaseTableWriteFunction method testDeleteAsyncStringValue.
@Test
public void testDeleteAsyncStringValue() throws Exception {
String key = "key";
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableWriteFunction<String> writeFunction = createAndInit(String.class, new StringSerde(), bucket, asyncBucket);
when(asyncBucket.remove(eq(key), anyLong(), any(TimeUnit.class))).thenReturn(Observable.just(null));
assertNull(writeFunction.deleteAsync(key).get());
}
use of com.couchbase.client.java.AsyncBucket in project samza by apache.
the class TestCouchbaseTableReadFunction method testGetAsyncStringValue.
@Test
public void testGetAsyncStringValue() throws Exception {
String key = "key";
String value = "value";
StringSerde stringSerde = new StringSerde();
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableReadFunction readFunction = createAndInit(String.class, stringSerde, bucket, asyncBucket);
when(asyncBucket.get(eq(key), anyObject(), anyLong(), any(TimeUnit.class))).thenReturn(Observable.just(BinaryDocument.create(key, Unpooled.wrappedBuffer(stringSerde.toBytes(value)))));
assertEquals(value, readFunction.getAsync(key).get());
}
use of com.couchbase.client.java.AsyncBucket in project samza by apache.
the class TestCouchbaseTableReadFunction method testGetAsyncJsonObjectValue.
@Test
public void testGetAsyncJsonObjectValue() throws Exception {
String key = "key";
JsonObject value = JsonObject.fromJson("{\"id\": 1}");
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableReadFunction readFunction = createAndInit(bucket, asyncBucket);
when(asyncBucket.get(eq(key), anyObject(), anyLong(), any(TimeUnit.class))).thenReturn(Observable.just(JsonDocument.create(key, value)));
assertEquals(value, readFunction.getAsync(key).get());
}
use of com.couchbase.client.java.AsyncBucket in project samza by apache.
the class TestCouchbaseTableReadFunction method testGetAsyncNullValue.
@Test
public void testGetAsyncNullValue() throws Exception {
String key = "NonExistingKey";
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableReadFunction readFunction = createAndInit(String.class, new StringSerde(), bucket, asyncBucket);
when(asyncBucket.get(eq(key), anyObject(), anyLong(), any(TimeUnit.class))).thenReturn(Observable.empty());
assertNull(readFunction.getAsync(key).get());
}
Aggregations