Search in sources :

Example 1 with DropIndexOptions

use of com.mongodb.client.model.DropIndexOptions in project mongo-java-driver by mongodb.

the class MongoCollectionImplTest method testDropIndexes.

@Test
public void testDropIndexes() {
    DropIndexOptions options = new DropIndexOptions().maxTime(1, TimeUnit.MILLISECONDS);
    assertAll("dropIndexes", () -> assertAll("check validation", () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndexes((DropIndexOptions) null)), () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndexes(clientSession, null)), () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndexes(null, options))), () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndexes(null, new DropIndexOptions());
        assertPublisherIsTheSameAs(expected, collection.dropIndexes(), "Default");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndexes(null, options);
        assertPublisherIsTheSameAs(expected, collection.dropIndexes(options), "With options");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndexes(clientSession, new DropIndexOptions());
        assertPublisherIsTheSameAs(expected, collection.dropIndexes(clientSession), "With client session");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndexes(clientSession, options);
        assertPublisherIsTheSameAs(expected, collection.dropIndexes(clientSession, options), "With client session & options");
    });
}
Also used : DropIndexOptions(com.mongodb.client.model.DropIndexOptions) Test(org.junit.jupiter.api.Test)

Example 2 with DropIndexOptions

use of com.mongodb.client.model.DropIndexOptions in project mongo-java-driver by mongodb.

the class MongoCollectionImplTest method testDropIndex.

@Test
public void testDropIndex() {
    String indexName = "index_name";
    Bson index = Indexes.ascending("ascending_index");
    DropIndexOptions options = new DropIndexOptions().maxTime(1, TimeUnit.MILLISECONDS);
    assertAll("dropIndex", () -> assertAll("check validation", () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndex((String) null)), () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndex((Bson) null)), () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndex(indexName, null)), () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndex(clientSession, (String) null)), () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndex(clientSession, (Bson) null)), () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndex(clientSession, (String) null)), () -> assertThrows(IllegalArgumentException.class, () -> collection.dropIndex(clientSession, indexName, null))), () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndex(null, indexName, new DropIndexOptions());
        assertPublisherIsTheSameAs(expected, collection.dropIndex(indexName), "Default string");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndex(null, index, new DropIndexOptions());
        assertPublisherIsTheSameAs(expected, collection.dropIndex(index), "Default bson");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndex(null, indexName, options);
        assertPublisherIsTheSameAs(expected, collection.dropIndex(indexName, options), "With string & options");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndex(null, index, options);
        assertPublisherIsTheSameAs(expected, collection.dropIndex(index, options), "With bson & options");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndex(clientSession, indexName, new DropIndexOptions());
        assertPublisherIsTheSameAs(expected, collection.dropIndex(clientSession, indexName), "With client session & string");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndex(clientSession, index, new DropIndexOptions());
        assertPublisherIsTheSameAs(expected, collection.dropIndex(clientSession, index), "With client session & bson");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndex(clientSession, indexName, options);
        assertPublisherIsTheSameAs(expected, collection.dropIndex(clientSession, indexName, options), "With client session, string & options");
    }, () -> {
        Publisher<Void> expected = mongoOperationPublisher.dropIndex(clientSession, index, options);
        assertPublisherIsTheSameAs(expected, collection.dropIndex(clientSession, index, options), "With client session, bson & options");
    });
}
Also used : DropIndexOptions(com.mongodb.client.model.DropIndexOptions) Bson(org.bson.conversions.Bson) Test(org.junit.jupiter.api.Test)

Example 3 with DropIndexOptions

use of com.mongodb.client.model.DropIndexOptions in project mongo-java-driver by mongodb.

the class MongoCollectionImpl method dropIndexes.

@Override
public void dropIndexes(final ClientSession clientSession) {
    notNull("clientSession", clientSession);
    executeDropIndex(clientSession, "*", new DropIndexOptions());
}
Also used : DropIndexOptions(com.mongodb.client.model.DropIndexOptions)

Aggregations

DropIndexOptions (com.mongodb.client.model.DropIndexOptions)3 Test (org.junit.jupiter.api.Test)2 Bson (org.bson.conversions.Bson)1