RolesAndPermissionsService implements ApplicationListener<ContextRefreshedEvent> { public List<PermissionModel> getSchoolPermissions() { return permissionDao.findByType(PermissionModel.PermissionType.SCHOOL); }  void setRoleDao(RoleDAO roleDao); void setPermissionDao(PermissionDAO permissionDao); void setUsersService(UsersService usersService); void setRoleAssignmentDao(RoleAssignmentDAO roleAssignmentDao); @Override void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent); RoleModel createRole(RoleModel role); RoleAssignment createRoleAssignment(RoleAssignment roleAssignment); List<PermissionModel> getSchoolPermissions(); List<PermissionModel> getVaultPermissions(); RoleModel getRole(long id); RoleModel getIsAdmin(); RoleModel getDataOwner(); List<RoleModel> getEditableRoles(); List<RoleModel> getViewableRoles(); List<RoleModel> getSchoolRoles(); List<RoleModel> getVaultRoles(); RoleAssignment getRoleAssignment(long id); List<RoleAssignment> getRoleAssignmentsForSchool(String schoolId); List<RoleAssignment> getRoleAssignmentsForVault(String vaultId); User getVaultOwner(String vaultId); List<RoleAssignment> getRoleAssignmentsForUser(String userId); List<RoleAssignment> getRoleAssignmentsForRole(Long roleId); boolean hasAdminDashboardPermissions(String userId); Set<Permission> getUserPermissions(String userId); boolean hasPermission(String userId, Permission permission); boolean isAdminUser(String userId); RoleModel updateRole(RoleModel role); RoleAssignment updateRoleAssignment(RoleAssignment roleAssignment); void deleteRole(Long roleId); void deleteRoleAssignment(Long roleAssignmentId);  }
@Test public void getSchoolPermissionsShouldReturnAllPermissionsApplicableToSchoolRoles() { PermissionModel school1 = aPermission(Permission.CAN_VIEW_VAULTS_SIZE, PermissionModel.PermissionType.SCHOOL); PermissionModel school2 = aPermission(Permission.CAN_VIEW_IN_PROGRESS, PermissionModel.PermissionType.SCHOOL); PermissionModel school3 = aPermission(Permission.CAN_VIEW_QUEUES, PermissionModel.PermissionType.SCHOOL); List<PermissionModel> allPermissions = Arrays.asList( school1, school2, school3, aPermission(Permission.VIEW_VAULT_ROLES, PermissionModel.PermissionType.VAULT), aPermission(Permission.CAN_MANAGE_ROLES, PermissionModel.PermissionType.ADMIN), aPermission(Permission.CAN_MANAGE_BILLING_DETAILS, PermissionModel.PermissionType.ADMIN), aPermission(Permission.CAN_VIEW_EVENTS, PermissionModel.PermissionType.ADMIN)); given(mockPermissionDao.findAll()).willReturn(allPermissions); Collection<PermissionModel> actual = underTest.getSchoolPermissions(); List<PermissionModel> expected = Arrays.asList(school1, school2, school3); assertEquals(expected, actual); }