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));
}
Aggregations