assertThat(user.getEmail(), is(equalTo(USER_EMAIL)));
}
@Test
public void addOrDeleteUserDoesNotAffectAuthority() {
Authority authority = authorityRepository.get(1L);
Assert.assertNotNull("Existing authority", authority);
int usercount = authority.getUsers().size();
User user = new JpaUser();
user.setUsername("dummy");
authority.addUser(user);
authorityRepository.save(authority);
assertNull("Persisting an Authority does not persist an unknown user", repository.getByUsername("dummy"));
Assert.assertEquals("Authority has 1 more user", usercount + 1, authority.getUsers().size());
repository.save(user);
user = repository.getByUsername("dummy");
Assert.assertNotNull(user);
Assert.assertEquals("Authority has 1 more user", usercount + 1, authority.getUsers().size());
repository.delete(user);
authority = authorityRepository.get(1L);
Assert.assertNotNull("Authority has not been removed after deleting user", authority);
Assert.assertEquals("Authority has original amount of users", usercount, authority.getUsers().size());
}