Search in sources :

Example 1 with UserTestBuilder.aDefaultUser

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);
}
Also used : UserTestBuilder.aDefaultUser(org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser) Test(org.junit.Test)

Example 2 with UserTestBuilder.aDefaultUser

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);
}
Also used : UserTestBuilder.aDefaultUser(org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser) Test(org.junit.Test)

Example 3 with UserTestBuilder.aDefaultUser

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);
}
Also used : UserTestBuilder.aDefaultUser(org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser) Test(org.junit.Test)

Example 4 with UserTestBuilder.aDefaultUser

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);
}
Also used : UserTestBuilder.aDefaultUser(org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 UserTestBuilder.aDefaultUser (org.simbasecurity.core.domain.UserTestBuilder.aDefaultUser)4