Search in sources :

Example 16 with UpdateResults

use of org.mongodb.morphia.query.UpdateResults in project morphia by mongodb.

the class TestUpdateOps method testRemoveWithNoData.

@Test
@Ignore("mapping in WriteResult needs to be resolved")
public void testRemoveWithNoData() {
    DumbColl dumbColl = new DumbColl("ID");
    dumbColl.fromArray = singletonList(new DumbArrayElement("something"));
    DumbColl dumbColl2 = new DumbColl("ID2");
    dumbColl2.fromArray = singletonList(new DumbArrayElement("something"));
    getDs().save(asList(dumbColl, dumbColl2));
    UpdateResults deleteResults = getDs().update(getDs().find(DumbColl.class).field("opaqueId").equalIgnoreCase("ID"), getAds().createUpdateOperations(DumbColl.class, new BasicDBObject("$pull", new BasicDBObject("fromArray", new BasicDBObject("whereId", "not there")))));
    getDs().update(getDs().find(DumbColl.class).field("opaqueId").equalIgnoreCase("ID"), getAds().createUpdateOperations(DumbColl.class).removeAll("fromArray", new DumbArrayElement("something")));
}
Also used : BasicDBObject(com.mongodb.BasicDBObject) UpdateResults(org.mongodb.morphia.query.UpdateResults) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

UpdateResults (org.mongodb.morphia.query.UpdateResults)16 Test (org.junit.Test)10 BasicDBObject (com.mongodb.BasicDBObject)5 DBObject (com.mongodb.DBObject)4 DBCollection (com.mongodb.DBCollection)3 LinkedHashMap (java.util.LinkedHashMap)3 MappedClass (org.mongodb.morphia.mapping.MappedClass)3 MappedField (org.mongodb.morphia.mapping.MappedField)3 WriteResult (com.mongodb.WriteResult)2 Date (java.util.Date)2 Datastore (org.mongodb.morphia.Datastore)2 MongoClient (com.mongodb.MongoClient)1 DBCollectionUpdateOptions (com.mongodb.client.model.DBCollectionUpdateOptions)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ObjectId (org.bson.types.ObjectId)1 Ignore (org.junit.Ignore)1 Morphia (org.mongodb.morphia.Morphia)1