Пример #1
0
  @Test
  public void findAll() {
    final UserMapper sut = new UserMapper(dataSource(), new IntegerIdentityMap<User>());

    for (final User user : sut.findAll(10, 0)) {
      final int userId = user.getId();

      switch (userId) {
        case 1:
          assertThat(user.getLoginName(), is("Foo"));
          assertThat(user.getHashedUserData(), is("b9f46238b289f23ba807973840655032"));
          break;
        case 2:
          assertThat(user.getLoginName(), is("Bar"));
          assertThat(user.getHashedUserData(), is("043bd227eaa879d438e7c1dfea568bc9"));
          break;
        case 3:
          assertThat(user.getLoginName(), is("Baz"));
          assertThat(user.getHashedUserData(), is("aa82cc74b4a932c06d4ea5a9ac38cf5e"));
          break;
        default:
          fail("Unexpected user id: " + userId);
      }
    }
  }
Пример #2
0
 @Test
 public void findAll_emptyTable()
     throws SQLException, ClassNotFoundException, IOException, URISyntaxException {
   destroyTestDatabase();
   startTestDatabase(false);
   final UserMapper sut = new UserMapper(dataSource(), new IntegerIdentityMap<User>());
   final Collection<User> users = sut.findAll(10, 0);
   assertThat(users, is(empty()));
 }