Search in sources :

Example 1 with TestEntity

use of dev.morphia.test.models.TestEntity in project morphia by mongodb.

the class TestDatastore method testBulkInsert.

@Test
public void testBulkInsert() {
    MongoCollection collection = getDs().getCollection(TestEntity.class);
    this.getDs().insert(asList(new TestEntity(), new TestEntity(), new TestEntity(), new TestEntity(), new TestEntity()), new InsertManyOptions().writeConcern(WriteConcern.ACKNOWLEDGED));
    assertEquals(collection.countDocuments(), 5);
    collection.drop();
    this.getDs().insert(asList(new TestEntity(), new TestEntity(), new TestEntity(), new TestEntity(), new TestEntity()), new InsertManyOptions().writeConcern(WriteConcern.ACKNOWLEDGED));
    assertEquals(collection.countDocuments(), 5);
}
Also used : TestEntity(dev.morphia.test.models.TestEntity) MongoCollection(com.mongodb.client.MongoCollection) InsertManyOptions(dev.morphia.InsertManyOptions) Test(org.testng.annotations.Test)

Example 2 with TestEntity

use of dev.morphia.test.models.TestEntity in project morphia by mongodb.

the class TestDatastore method testInsert.

@Test
public void testInsert() {
    MongoCollection collection = getDs().getCollection(TestEntity.class);
    this.getDs().insert(new TestEntity());
    assertEquals(collection.countDocuments(), 1);
    this.getDs().insert(new TestEntity(), new InsertOneOptions().writeConcern(WriteConcern.ACKNOWLEDGED));
    assertEquals(collection.countDocuments(), 2);
}
Also used : TestEntity(dev.morphia.test.models.TestEntity) MongoCollection(com.mongodb.client.MongoCollection) InsertOneOptions(dev.morphia.InsertOneOptions) Test(org.testng.annotations.Test)

Aggregations

MongoCollection (com.mongodb.client.MongoCollection)2 TestEntity (dev.morphia.test.models.TestEntity)2 Test (org.testng.annotations.Test)2 InsertManyOptions (dev.morphia.InsertManyOptions)1 InsertOneOptions (dev.morphia.InsertOneOptions)1