### Question:
ResourcesService extends BaseService { public Map<String, Object> authorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (checkAdmin(loginUser, result)){ return result; } List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId); Visitor visitor = new ResourceTreeVisitor(authedResources); String visit = JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(visit); String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(jsonTreeStr); 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 testAuthorizedFile(){ User user = getUser(); Map<String, Object> result = resourcesService.authorizedFile(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.queryAuthorizedResourceList(1)).thenReturn(getResourceList()); result = resourcesService.authorizedFile(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)); }