use of org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser in project simba-os by cegeka.
the class UserDatabaseRepositoryTest method searchUsersOrderedByName_SearchIsCaseInsensitiveOnAllNameFields.
@Test
public void searchUsersOrderedByName_SearchIsCaseInsensitiveOnAllNameFields() throws Exception {
User user = UserTestBuilder.aDefaultUser().withUserName("banaan").withFirstName("Jan").withName("Klaas").build();
persistAndRefresh(user);
assertThat(userDatabaseRepository.searchUsersOrderedByName("j")).containsExactly(user);
assertThat(userDatabaseRepository.searchUsersOrderedByName("S")).containsExactly(user);
assertThat(userDatabaseRepository.searchUsersOrderedByName("B")).containsExactly(user);
}
use of org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser in project simba-os by cegeka.
the class UserDatabaseRepositoryTest method findAllOrderedByName_UsersAreOrderedByUserNameAscending.
@Test
public void findAllOrderedByName_UsersAreOrderedByUserNameAscending() throws Exception {
User userB = UserTestBuilder.aDefaultUser().withUserName("b").build();
User userC = UserTestBuilder.aDefaultUser().withUserName("c").build();
User userA = UserTestBuilder.aDefaultUser().withUserName("a").build();
persistAndRefresh(userB, userC, userA);
Collection<User> result = userDatabaseRepository.findAllOrderedByName();
assertThat(result).containsExactly(user2, userA, userB, userC, user);
}
use of org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser in project simba-os by cegeka.
the class UserDatabaseRepositoryTest method searchUsersOrderedByName_AllNameFieldsAreSearched.
@Test
public void searchUsersOrderedByName_AllNameFieldsAreSearched() throws Exception {
User userB = UserTestBuilder.aDefaultUser().withUserName("banaan").withFirstName("Jan").withName("Klaas").build();
User userC = UserTestBuilder.aDefaultUser().withUserName("citroen").withFirstName("Piet").withName("Hein").build();
User userA = UserTestBuilder.aDefaultUser().withUserName("appel").withFirstName("Kevin").withName("Nobin").build();
persistAndRefresh(userB, userC, userA);
assertThat(userDatabaseRepository.searchUsersOrderedByName("a")).containsExactly(userA, userB);
assertThat(userDatabaseRepository.searchUsersOrderedByName("z")).isEmpty();
assertThat(userDatabaseRepository.searchUsersOrderedByName("")).containsExactly(user2, userA, userB, userC, user);
assertThat(userDatabaseRepository.searchUsersOrderedByName("aa")).containsExactly(userB);
assertThat(userDatabaseRepository.searchUsersOrderedByName("v")).containsExactly(userA);
assertThat(userDatabaseRepository.searchUsersOrderedByName("s")).containsExactly(userB);
}
use of org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser in project simba-os by cegeka.
the class UserDatabaseRepositoryTest method findForRole.
@Test
public void findForRole() {
Role role = new RoleEntity("aRole");
User otherUser = UserTestBuilder.aDefaultUser().withUserName("otherUser").build();
persistAndRefresh(role, otherUser);
role.addUser(this.user);
Collection<User> result = userDatabaseRepository.findForRole(role);
assertThat(result).containsOnly(user);
}
Aggregations