Beispiel #1
0
  @Test
  public void addedUserRoleFoundById() {

    UserRole role = new UserRole("");
    role = userRoleService.save(role);

    assertEquals(role, userRoleService.findById(role.getId()));
  }
Beispiel #2
0
  @Test
  public void deletedUserNotFoundById() {

    UserRole role = new UserRole("");
    role = userRoleService.save(role);
    userRoleService.delete(role.getId());

    assertNull(userRoleService.findById(role.getId()));
  }
Beispiel #3
0
  @Test
  public void addingUserRoleIncreasesCount() {

    long startCount = userRoleService.count();
    userRoleService.save(new UserRole(""));
    long endCount = userRoleService.count();

    assertEquals(startCount + 1, endCount);
  }
Beispiel #4
0
  @Test
  public void deletingUserRoleDecreasesCount() {

    UserRole role = userRoleService.save(new UserRole(""));
    long startCount = userRoleService.count();

    userRoleService.delete(role.getId());
    long endCount = userRoleService.count();

    assertEquals(startCount - 1, endCount);
  }
Beispiel #5
0
  @Test
  public void findAllAddedUserRoles() {

    mongoTemplate.dropCollection(UserRole.class);

    ArrayList<UserRole> roles = new ArrayList<UserRole>();

    UserRole a = userRoleService.save(new UserRole(""));
    UserRole b = userRoleService.save(new UserRole(""));
    UserRole c = userRoleService.save(new UserRole(""));
    UserRole d = userRoleService.save(new UserRole(""));

    roles.add(a);
    roles.add(b);
    roles.add(c);
    roles.add(d);

    assertEquals(roles, userRoleService.findAll());
  }
Beispiel #6
0
 @Test
 public void nonExistingUserRoleNotFoundByName() {
   assertNull(userRoleService.findByName("nonExistingName"));
 }
Beispiel #7
0
 @Test
 public void addedUserRoleFoundByName() {
   assertEquals(existingRole, userRoleService.findByName("user"));
 }
Beispiel #8
0
 @Test
 public void nonExistingUserRoleNotFoundById() {
   assertNull(userRoleService.findById("nonExistingUserRoleId"));
 }
Beispiel #9
0
 @Before
 public void setUp() {
   existingRole = userRoleService.findByName("user");
 }