예제 #1
0
  @Test
  public void addedUserRoleFoundById() {

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

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

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

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

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

    assertEquals(startCount + 1, endCount);
  }
예제 #4
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());
  }
예제 #5
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);
  }