use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method reviveDocumentOnAlreadyAliveDocument.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void reviveDocumentOnAlreadyAliveDocument() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
coll.insert(docId, body);
try {
coll.mutateIn(docId, Collections.singletonList(upsert("foo", "bar").xattr()), MutateInOptions.mutateInOptions().accessDeleted(true).storeSemantics(StoreSemantics.REVIVE));
fail();
} catch (DocumentAlreadyAliveException ignored) {
assertEquals(CAN_ONLY_REVIVE_DELETED_DOCUMENTS.name(), ignored.context().exportAsMap().get("subdocStatus"));
}
}
use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method getAndTouch.
/**
* This test is ignored against the mock because right now it does not bump the CAS like
* the server does when getAndTouch is called.
*
* <p>Remove the ignore as soon as https://github.com/couchbase/CouchbaseMock/issues/49 is
* fixed.</p>
*/
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void getAndTouch() {
String id = UUID.randomUUID().toString();
JsonObject expected = JsonObject.create().put("foo", true);
MutationResult insert = collection.insert(id, expected, insertOptions().expiry(Duration.ofSeconds(10)));
assertTrue(insert.cas() != 0);
GetResult getAndTouch = collection.getAndTouch(id, Duration.ofSeconds(1));
assertTrue(getAndTouch.cas() != 0);
assertNotEquals(insert.cas(), getAndTouch.cas());
assertEquals(expected, getAndTouch.contentAsObject());
waitUntilCondition(() -> {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// ignored.
}
try {
collection.get(id);
return false;
} catch (DocumentNotFoundException knf) {
return true;
}
});
}
use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method fullDocWithExpirationAndCustomTranscoder.
@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void fullDocWithExpirationAndCustomTranscoder() {
String id = UUID.randomUUID().toString();
JsonObject content = JsonObject.create().put("foo", "bar").put("created", true).put("age", 12);
MutationResult mutationResult = collection.upsert(id, content.toBytes(), upsertOptions().expiry(Duration.ofSeconds(5)).transcoder(RawBinaryTranscoder.INSTANCE));
assertTrue(mutationResult.cas() != 0);
GetResult getResult = collection.get(id, getOptions().withExpiry(true).transcoder(RawBinaryTranscoder.INSTANCE));
assertTrue(getResult.expiryTime().isPresent());
assertTrue(getResult.expiryTime().get().toEpochMilli() > 0);
assertEquals(content, JsonObject.fromJson(getResult.contentAs(byte[].class)));
}
use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method fullDocWithExpiration.
/**
* Right now the mock does not support xattr/macro expansion so this test is
* ignored on the mock. Once the mock supports it, please remove the ignore
* annotation.
*
* <p>See https://github.com/couchbase/CouchbaseMock/issues/46</p>
*/
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void fullDocWithExpiration() {
String id = UUID.randomUUID().toString();
JsonObject content = JsonObject.create().put("foo", "bar").put("created", true).put("age", 12);
MutationResult mutationResult = collection.upsert(id, content, upsertOptions().expiry(Duration.ofSeconds(5)));
assertTrue(mutationResult.cas() != 0);
GetResult getResult = collection.get(id, getOptions().withExpiry(true));
assertTrue(getResult.expiryTime().isPresent());
assertTrue(getResult.expiryTime().get().toEpochMilli() > 0);
assertEquals(content, getResult.contentAsObject());
}
use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method decrement.
/**
* Right now the mock allows the value to be decremented below zero, which is against the server
* spec/protocol. Once https://github.com/couchbase/CouchbaseMock/issues/51 is fixed, this
* ignore annotation can be removed.
*/
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void decrement() {
String id = UUID.randomUUID().toString();
assertThrows(DocumentNotFoundException.class, () -> collection.binary().decrement(id));
CounterResult result = collection.binary().decrement(id, decrementOptions().initial(2L));
assertTrue(result.cas() != 0);
assertEquals(2L, result.content());
result = collection.binary().decrement(id);
assertTrue(result.cas() != 0);
assertEquals(1L, result.content());
result = collection.binary().decrement(id);
assertTrue(result.cas() != 0);
assertEquals(0L, result.content());
result = collection.binary().decrement(id);
assertTrue(result.cas() != 0);
assertEquals(0L, result.content());
}
Aggregations