示例#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 deletingUserRoleDecreasesCount() {

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

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

    assertEquals(startCount - 1, endCount);
  }
示例#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());
  }
示例#6
0
 @Test
 public void nonExistingUserRoleNotFoundByName() {
   assertNull(userRoleService.findByName("nonExistingName"));
 }
示例#7
0
 @Test
 public void addedUserRoleFoundByName() {
   assertEquals(existingRole, userRoleService.findByName("user"));
 }
示例#8
0
 @Test
 public void nonExistingUserRoleNotFoundById() {
   assertNull(userRoleService.findById("nonExistingUserRoleId"));
 }
示例#9
0
 @Before
 public void setUp() {
   existingRole = userRoleService.findByName("user");
 }