@Test public void addedUserRoleFoundById() { UserRole role = new UserRole(""); role = userRoleService.save(role); assertEquals(role, userRoleService.findById(role.getId())); }
@Test public void deletedUserNotFoundById() { UserRole role = new UserRole(""); role = userRoleService.save(role); userRoleService.delete(role.getId()); assertNull(userRoleService.findById(role.getId())); }
@Test public void addingUserRoleIncreasesCount() { long startCount = userRoleService.count(); userRoleService.save(new UserRole("")); long endCount = userRoleService.count(); assertEquals(startCount + 1, endCount); }
@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); }
@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()); }
@Test public void nonExistingUserRoleNotFoundByName() { assertNull(userRoleService.findByName("nonExistingName")); }
@Test public void addedUserRoleFoundByName() { assertEquals(existingRole, userRoleService.findByName("user")); }
@Test public void nonExistingUserRoleNotFoundById() { assertNull(userRoleService.findById("nonExistingUserRoleId")); }
@Before public void setUp() { existingRole = userRoleService.findByName("user"); }