Search in sources :

Example 6 with CollectionSpec

use of com.couchbase.client.java.manager.collection.CollectionSpec in project couchbase-jvm-clients by couchbase.

the class AnalyticsCollectionIntegrationTest method setup.

@BeforeAll
static void setup() {
    cluster = Cluster.connect(seedNodes(), clusterOptions());
    bucket = cluster.bucket(config().bucketname());
    analytics = cluster.analyticsIndexes();
    collectionManager = bucket.collections();
    bucket.waitUntilReady(Duration.ofSeconds(5));
    waitForService(bucket, ServiceType.ANALYTICS);
    collectionManager.createScope(scopeName);
    CollectionSpec collSpec = CollectionSpec.create(collectionName, scopeName);
    collectionManager.createCollection(collSpec);
    waitUntilCondition(() -> collectionExists(collectionManager, collSpec));
    waitForQueryIndexerToHaveKeyspace(cluster, config().bucketname());
    // this inserts two documents in bucket.scope.collection and creates a primary index.
    // then inserts one document in bucket._default._default and creates a primary index.
    cluster.query("insert into `" + config().bucketname() + "`.`" + scopeName + "`.`" + collectionName + "` (key, value ) values ( '123',  { \"test\" : \"hello\" })");
    insertDoc(bucket.scope(scopeName).collection(collectionName), FOO_CONTENT);
    cluster.query("create primary index on `" + config().bucketname() + "`.`" + scopeName + "`.`" + collectionName + "`");
    insertDoc(bucket.defaultCollection(), DEFAULT_CONTENT);
    try {
        cluster.query("create primary index on `" + config().bucketname() + "`.`" + "_default" + "`." + "_default");
    } catch (IndexExistsException e) {
    // Primary index is already created, ignore
    }
    delimitedDataverseName = "`" + config().bucketname() + "`.`" + scopeName + "`";
}
Also used : IndexExistsException(com.couchbase.client.core.error.IndexExistsException) CollectionSpec(com.couchbase.client.java.manager.collection.CollectionSpec) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

CollectionSpec (com.couchbase.client.java.manager.collection.CollectionSpec)6 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)3 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)3 BeforeAll (org.junit.jupiter.api.BeforeAll)3 Test (org.junit.jupiter.api.Test)3 IndexExistsException (com.couchbase.client.core.error.IndexExistsException)2 com.couchbase.client.core.error (com.couchbase.client.core.error)1 CollectionNotFoundException (com.couchbase.client.core.error.CollectionNotFoundException)1 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)1 DocumentNotFoundException (com.couchbase.client.core.error.DocumentNotFoundException)1 ParsingFailureException (com.couchbase.client.core.error.ParsingFailureException)1 QueryException (com.couchbase.client.core.error.QueryException)1 QuotaLimitedException (com.couchbase.client.core.error.QuotaLimitedException)1 ScopeNotFoundException (com.couchbase.client.core.error.ScopeNotFoundException)1 UnambiguousTimeoutException (com.couchbase.client.core.error.UnambiguousTimeoutException)1 Bucket (com.couchbase.client.java.Bucket)1 Cluster (com.couchbase.client.java.Cluster)1 Collection (com.couchbase.client.java.Collection)1 JsonObject (com.couchbase.client.java.json.JsonObject)1 GetResult (com.couchbase.client.java.kv.GetResult)1