コード例 #1
0
  private void assertQuery(MongodbQuery<User> query, User... expected) {
    // System.out.println(query.toString());
    List<User> results = query.list();

    assertNotNull(results);
    if (expected == null) {
      assertEquals("Should get empty result", 0, results.size());
      return;
    }
    assertEquals(expected.length, results.size());
    int i = 0;
    for (User u : expected) {
      assertEquals(u, results.get(i++));
    }
  }
コード例 #2
0
 private User addUser(
     String first, String last, int age, Address mainAddress, Address... addresses) {
   User user = new User(first, last, age, new Date());
   user.setGender(Gender.MALE);
   user.setMainAddress(mainAddress);
   for (Address address : addresses) {
     user.addAddress(address);
   }
   for (User u : users) {
     user.addFriend(u);
   }
   if (!users.isEmpty()) {
     user.setFriend(users.get(users.size() - 1));
   }
   ds.save(user);
   users.add(user);
   return user;
 }