use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method twoCommandsOneFails.
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void twoCommandsOneFails() {
JsonObject content = JsonObject.create().put("foo1", "bar_orig_1").put("foo2", "bar_orig_2");
String docId = prepare(content);
assertThrows(PathExistsException.class, () -> coll.mutateIn(docId, Arrays.asList(MutateInSpec.insert("foo0", "bar0"), MutateInSpec.insert("foo1", "bar1"), MutateInSpec.remove("foo3"))));
JsonObject updated = getContent(docId);
assertEquals("bar_orig_1", updated.getString("foo1"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method insertExpandMacroSEQ_NOXattr.
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED, ClusterType.CAVES })
void insertExpandMacroSEQ_NOXattr() {
JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create(), Arrays.asList(MutateInSpec.insert("x.foo", MutateInMacro.SEQ_NO).xattr()));
assertNotEquals(MutateInMacro.SEQ_NO.value(), updatedContent.getString("foo"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class AnalyticsCollectionIntegrationTest method performsDataverseCollectionQuery.
@Test
void performsDataverseCollectionQuery() {
cluster.analyticsQuery("ALTER COLLECTION `" + bucket.name() + "`.`" + scopeName + "`.`" + collectionName + "` ENABLE ANALYTICS");
// REQUEST_PLUS makes query hang
// AnalyticsOptions opts = AnalyticsOptions.analyticsOptions().scanConsistency(AnalyticsScanConsistency.REQUEST_PLUS);
// Ensure doc ingested by analytics
waitUntilCondition(() -> singletonMap(delimitedDataverseName, singletonMap(collectionName, 0L)).equals(analytics.getPendingMutations()));
Scope scope = cluster.bucket(config().bucketname()).scope(scopeName);
AnalyticsResult result = scope.analyticsQuery("SELECT * FROM `" + bucket.name() + "`.`" + scopeName + "`.`" + collectionName + "` WHERE `" + collectionName + "`.foo=\"bar\"");
List<JsonObject> rows = result.rowsAs(JsonObject.class);
assertFalse(rows.isEmpty());
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class AnalyticsCollectionIntegrationTest method performsDataverseQuery.
@Test
void performsDataverseQuery() {
// default
analytics.createDataset(dataset, bucket.name());
analytics.createDataverse(dataverse);
analytics.createDataset(dataset, bucket.name(), createDatasetAnalyticsOptions().dataverseName(dataverse));
// REQUEST_PLUS makes query hang
// AnalyticsOptions opts = AnalyticsOptions.analyticsOptions().scanConsistency(AnalyticsScanConsistency.REQUEST_PLUS).timeout(Duration.ofSeconds(300));
AnalyticsResult result = cluster.analyticsQuery("SELECT * FROM " + dataverse + "." + dataset + " where " + dataset + ".test= \"hello\"");
List<JsonObject> rows = result.rowsAs(JsonObject.class);
assertFalse(!rows.isEmpty());
AnalyticsMetaData meta = result.metaData();
assertFalse(meta.clientContextId().isEmpty());
assertTrue(meta.signature().isPresent());
assertFalse(meta.requestId().isEmpty());
assertEquals(AnalyticsStatus.SUCCESS, meta.status());
assertFalse(meta.metrics().elapsedTime().isZero());
assertFalse(meta.metrics().executionTime().isZero());
assertEquals(rows.size(), meta.metrics().resultCount());
// assertEquals(rows.size(), meta.metrics().processedObjects()); // fails
// assertTrue(meta.metrics().resultSize() > 0); // fails
assertTrue(meta.warnings().isEmpty());
// assertEquals(1, meta.metrics().errorCount()); //fails
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class AnalyticsIntegrationTest method performsDataverseQuery.
@Test
void performsDataverseQuery() {
AnalyticsResult result = cluster.analyticsQuery("SELECT DataverseName FROM Metadata.`Dataverse`");
List<JsonObject> rows = result.rowsAs(JsonObject.class);
assertFalse(rows.isEmpty());
for (JsonObject row : rows) {
assertNotNull(row.get("DataverseName"));
}
AnalyticsMetaData meta = result.metaData();
assertFalse(meta.clientContextId().isEmpty());
assertTrue(meta.signature().isPresent());
assertFalse(meta.requestId().isEmpty());
assertEquals(AnalyticsStatus.SUCCESS, meta.status());
assertFalse(meta.metrics().elapsedTime().isZero());
assertFalse(meta.metrics().executionTime().isZero());
assertEquals(rows.size(), meta.metrics().resultCount());
assertEquals(rows.size(), meta.metrics().processedObjects());
assertTrue(meta.metrics().resultSize() > 0);
assertTrue(meta.warnings().isEmpty());
assertEquals(0, meta.metrics().errorCount());
}
Aggregations