Esempio n. 1
0
 @Test
 @Transactional(value = "hibernateTransactionManager", readOnly = true)
 public void shouldLoadAuthoritiesWhichUserHave() {
   User user = hibernateTemplate.load(User.class, 1);
   Authority authority = hibernateTemplate.load(Authority.class, 1);
   assertFalse(user.getAuthorities().isEmpty());
   assertTrue(user.getAuthorities().contains(authority));
 }
Esempio n. 2
0
 @Test
 public void shouldFindOnlyOneUserByUsername() {
   jdbcTemplate.query(
       "SELECT id, username, password, enabled FROM users WHERE username = ?",
       new Object[] {"super"},
       new RowCallbackHandler() {
         public void processRow(ResultSet resultSet) throws SQLException {
           user = new User(resultSet.getString(2), resultSet.getString(3), resultSet.getString(4));
           user.setId(resultSet.getInt(1));
         }
       });
   assertThat(user.getId(), is(1));
   assertThat(user.getUsername(), is("super"));
 }