### Question:
ResourcesService extends BaseService { public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (checkAdmin(loginUser, result)) { return result; } List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<Resource> list ; if (resourceList != null && resourceList.size() > 0) { Set<Resource> resourceSet = new HashSet<>(resourceList); List<Resource> authedResourceList = resourcesMapper.queryAuthorizedResourceList(userId); getAuthorizedResourceList(resourceSet, authedResourceList); list = new ArrayList<>(resourceSet); }else { list = new ArrayList<>(0); } Visitor visitor = new ResourceTreeVisitor(list); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result,Status.SUCCESS); return result; }  @Transactional(rollbackFor = RuntimeException.class) Result createDirectory(User loginUser,
                                 String name,
                                 String description,
                                 ResourceType type,
                                 int pid,
                                 String currentDir); @Transactional(rollbackFor = RuntimeException.class) Result createResource(User loginUser,
                                 String name,
                                 String desc,
                                 ResourceType type,
                                 MultipartFile file,
                                 int pid,
                                 String currentDir); @Transactional(rollbackFor = RuntimeException.class) Result updateResource(User loginUser,
                                 int resourceId,
                                 String name,
                                 String desc,
                                 ResourceType type); Map<String, Object> queryResourceListPaging(User loginUser, int direcotryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize); Map<String, Object> queryResourceList(User loginUser, ResourceType type); Map<String, Object> queryResourceJarList(User loginUser, ResourceType type); @Transactional(rollbackFor = Exception.class) Result delete(User loginUser, int resourceId); Result verifyResourceName(String fullName, ResourceType type,User loginUser); Result queryResource(String fullName,Integer id,ResourceType type); Result readResource(int resourceId, int skipLineNum, int limit); @Transactional(rollbackFor = RuntimeException.class) Result onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content,int pid,String currentDirectory); @Transactional(rollbackFor = RuntimeException.class) Result updateResourceContent(int resourceId, String content); org.springframework.core.io.Resource downloadResource(int resourceId); Map<String, Object> authorizeResourceTree(User loginUser, Integer userId); Map<String, Object> unauthorizedFile(User loginUser, Integer userId); Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId); Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId); Map<String, Object> authorizedFile(User loginUser, Integer userId);  }### Answer:
@Test public void testUnauthorizedFile(){ User user = getUser(); Map<String, Object> result = resourcesService.unauthorizedFile(user,1); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM,result.get(Constants.STATUS)); user.setUserType(UserType.ADMIN_USER); Mockito.when(resourcesMapper.queryResourceExceptUserId(1)).thenReturn(getResourceList()); result = resourcesService.unauthorizedFile(user,1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS)); List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); }