UserUtils { public static boolean hasPermissionforAction(final UserManager userManager, final User user, final Permission.Type type) { for (final String roleName : user.getRoles()) { final Role role = userManager.getRole(roleName); final Permission perm = role.getPermission(); if (perm.isPermissionSet(Permission.Type.ADMIN) || perm.isPermissionSet(type)) { return true; } } return false; } private  UserUtils(); static boolean hasPermissionforAction(final UserManager userManager, final User user,
      final Permission.Type type); static void setupWatch(final Map<String, ParseConfigFile> configFileMap,
      final FileWatcher watcher);  }
@Test public void testRegularUserCantUploadProject() { final UserManager userManager = TestUtils.createTestXmlUserManager(); final User user = TestUtils.getTestUser(); assertThat(UserUtils.hasPermissionforAction(userManager, user, UPLOADPROJECTS)).isFalse(); }
@Test public void testUserWithPermissionsCanUploadProject() throws UserManagerException { final UserManager userManager = TestUtils.createTestXmlUserManager(); final User testUpload = userManager.getUser("testUpload", "testUpload"); assertThat(UserUtils.hasPermissionforAction(userManager, testUpload, UPLOADPROJECTS)).isTrue(); }
@Test public void testAdminUserCanUploadProject() throws UserManagerException { final UserManager userManager = TestUtils.createTestXmlUserManager(); final User testAdmin = userManager.getUser("testAdmin", "testAdmin"); assertThat(UserUtils.hasPermissionforAction(userManager, testAdmin, UPLOADPROJECTS)).isTrue(); }