@Test
  public void upsert() throws Exception {
    repository.upsert(item()).getUnchecked();
    check(findItem()).is(item());

    repository.upsert(item().withList("foo", "bar")).getUnchecked();
    check(findItem().list()).hasAll("foo", "bar");

    // add item with different ID. This should be insert (not update)
    repository.upsert(item().withId("another_id").withList("aaa")).getUnchecked();
    check(repository.findAll().fetchAll().getUnchecked()).hasSize(2);
  }
Basic CRUD operations on the top of repository
mongo/test/org/immutables/mongo/fixture/BasicMongoOperationsTest.java