@Test
public void testUpdate() throws Exception {
client.delete(new Delete("test", "update", new BasicBSONObject("_id", "updateId")));
// Test null update
client.update(new Update("test", "update",
new BasicBSONObject("_id", "updateId"),
new BasicBSONObject("name", "abcdefg")
));
Response response = client.query(new Query("test", "update", 0, 1, new BasicBSONObject("_id", "updateId"), null));
Assert.assertEquals(response.getNumberReturned(), 0);
client.insert(new Insert("test", "update", new BasicBSONObject("_id", "updateId").append("name", "testname")));
response = client.query(new Query("test", "update", 0, 1, new BasicBSONObject("_id", "updateId"), null));
Assert.assertEquals(1, response.getNumberReturned());
client.update(new Update("test", "update", new BasicBSONObject("_id", "updateId"), new BasicBSONObject("_id", "updateId").append("name", "testname updated")));
response = client.query(new Query("test", "update", 0, 1, new BasicBSONObject("_id", "updateId"), null));
Assert.assertEquals(1, response.getNumberReturned());
BSONObject result = response.getDocuments().get(0);
Assert.assertEquals("updateId", result.get("_id"));