Search in sources :

Example 1 with ScopeSpec

use of com.couchbase.client.java.manager.collection.ScopeSpec in project spring-data-couchbase by spring-projects.

the class JavaIntegrationTests method setupScopeCollection.

public static void setupScopeCollection(Cluster cluster, String scopeName, String collectionName, CollectionManager collectionManager) {
    // Create the scope.collection (borrowed from CollectionManagerIntegrationTest )
    ScopeSpec scopeSpec = ScopeSpec.create(scopeName);
    CollectionSpec collSpec = CollectionSpec.create(collectionName, scopeName);
    if (!scopeName.equals(CollectionIdentifier.DEFAULT_SCOPE)) {
        try {
            collectionManager.createScope(scopeName);
            waitUntilCondition(() -> scopeExists(collectionManager, scopeName));
            ScopeSpec found = collectionManager.getScope(scopeName);
            assertEquals(scopeSpec, found);
        } catch (CouchbaseException e) {
            if (!e.toString().contains("already exists")) {
                e.printStackTrace();
                throw e;
            }
        }
    }
    try {
        collectionManager.createCollection(collSpec);
    } catch (CouchbaseException e) {
        if (!e.toString().contains("already exists")) {
            e.printStackTrace();
            throw e;
        }
    }
    waitUntilCondition(() -> collectionExists(collectionManager, collSpec));
    waitUntilCondition(() -> collectionReady(cluster.bucket(config().bucketname()).scope(scopeName).collection(collectionName)));
    assertNotEquals(scopeSpec, collectionManager.getScope(scopeName));
    assertTrue(collectionManager.getScope(scopeName).collections().contains(collSpec));
    waitForQueryIndexerToHaveBucket(cluster, collectionName);
    try {
        block(createPrimaryIndex(cluster, config().bucketname(), scopeName, collectionName));
    } catch (Exception e) {
        e.printStackTrace();
    }
    waitUntilCondition(() -> collectionReadyQuery(cluster.bucket(config().bucketname()).scope(scopeName), collectionName));
}
Also used : ScopeSpec(com.couchbase.client.java.manager.collection.ScopeSpec) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) CollectionSpec(com.couchbase.client.java.manager.collection.CollectionSpec) UnambiguousTimeoutException(com.couchbase.client.core.error.UnambiguousTimeoutException) IndexExistsException(com.couchbase.client.core.error.IndexExistsException) ParsingFailureException(com.couchbase.client.core.error.ParsingFailureException) DocumentNotFoundException(com.couchbase.client.core.error.DocumentNotFoundException) CollectionNotFoundException(com.couchbase.client.core.error.CollectionNotFoundException) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) QueryException(com.couchbase.client.core.error.QueryException) ScopeNotFoundException(com.couchbase.client.core.error.ScopeNotFoundException) IOException(java.io.IOException)

Aggregations

CollectionNotFoundException (com.couchbase.client.core.error.CollectionNotFoundException)1 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)1 DocumentNotFoundException (com.couchbase.client.core.error.DocumentNotFoundException)1 IndexExistsException (com.couchbase.client.core.error.IndexExistsException)1 ParsingFailureException (com.couchbase.client.core.error.ParsingFailureException)1 QueryException (com.couchbase.client.core.error.QueryException)1 ScopeNotFoundException (com.couchbase.client.core.error.ScopeNotFoundException)1 UnambiguousTimeoutException (com.couchbase.client.core.error.UnambiguousTimeoutException)1 CollectionSpec (com.couchbase.client.java.manager.collection.CollectionSpec)1 ScopeSpec (com.couchbase.client.java.manager.collection.ScopeSpec)1 IOException (java.io.IOException)1