示例#1
0
  @Test
  public void canSaveWithACustomTypeId() throws Exception {

    ExternalFriend john = new ExternalFriend(999, "Robert");

    collection.save(john);

    ExternalFriend result = collection.findOne().as(ExternalFriend.class);
    assertThat(result.getId()).isEqualTo(999);
  }
示例#2
0
  @Test
  public void canUpdateWithACustomTypeId() throws Exception {

    ExternalFriend friend = new ExternalFriend(999, "Robert");
    collection.save(friend);

    friend.setName("Robert");
    collection.save(friend);

    ExternalFriend result = collection.findOne().as(ExternalFriend.class);
    assertThat(result.getId()).isEqualTo(999);
  }