AgentManagerApiController { @GetMapping({"", "/", "/list"}) @PreAuthorize("hasAnyRole('A', 'S', 'U')") public List<AgentInfo> getAll(final User user, @RequestParam(value = "region", required = false) final String region) { final Collection<? extends GrantedAuthority> authorities = getCurrentAuthorities(); return agentService.getAllActive() .stream() .filter(agent -> filterAgentByCluster(region, agent.getRegion())) .filter(agent -> filterAgentByUserAuthorityAndUserId(authorities, user.getUserId(), region, agent.getRegion())) .collect(toList()); }  @GetMapping("/regions") @PreAuthorize("hasAnyRole('A', 'S', 'U')") List<String> getAvailableRegions(final User user); @GetMapping("/download_link") @PreAuthorize("hasAnyRole('A', 'S', 'U')") String getDownloadLink(final User user,  @RequestParam(value = "region", required = false) final String region); @GetMapping({"", "/", "/list"}) @PreAuthorize("hasAnyRole('A', 'S', 'U')") List<AgentInfo> getAll(final User user, @RequestParam(value = "region", required = false) final String region); @GetMapping("/state") @PreAuthorize("hasAnyRole('A', 'S', 'U')") SystemDataModel getState(@RequestParam String ip, @RequestParam String name, @RequestParam String region); @PreAuthorize("hasAnyRole('A', 'S', 'U')") @GetMapping(value = {"/states/", "/states"}) List<Map<String, Object>> getStates(); @PreAuthorize("hasAnyRole('A')") @GetMapping(value = {"/", ""}) List<AgentInfo> getAll(); @PreAuthorize("hasAnyRole('A')") @GetMapping(value = "/{ip}/{name}") AgentInfo getOneByIpAndName(@PathVariable String ip, @PathVariable String name); @PreAuthorize("hasAnyRole('A')") @PutMapping(value = "/{ip}/{name}", params = "action=approve") void approve(@PathVariable String ip, @PathVariable String name); @PreAuthorize("hasAnyRole('A')") @PutMapping(value = "/{ip}/{name}", params = "action=disapprove") void disapprove(@PathVariable String ip, @PathVariable String name); @PreAuthorize("hasAnyRole('A')") @PutMapping(value = "/{ip}/{name}", params = "action=stop") void stop(@PathVariable String ip, @PathVariable String name); @PreAuthorize("hasAnyRole('A')") @PutMapping(value = "", params = "action=stop") void stop(@RequestBody List<AgentInfo> agentInfos); @PreAuthorize("hasAnyRole('A')") @PutMapping(value = "/{ip}/{name}", params = "action=update") void update(@PathVariable String ip, @PathVariable String name); @PreAuthorize("hasAnyRole('A')") @PutMapping(value = "", params = "action=update") void update(@RequestBody List<AgentInfo> agentInfos); @GetMapping("/availableAgentCount") @PreAuthorize("permitAll") Map<String, Integer> getAvailableAgentCount(User user, @RequestParam String targetRegion); @PostMapping("/connect/{ip}/{port}") @PreAuthorize("permitAll") void addConnectionAgent(@PathVariable String ip, @PathVariable int port, @RequestParam String region);  }
@SuppressWarnings("unchecked") @Test public void testGetAgentList() { agentApiController.getAll(userContext.getCurrentUser(), "NONE"); File directory = config.getHome().getDownloadDirectory(); if (!directory.exists()) { try { FileUtils.forceMkdir(directory); } catch (IOException e) { e.printStackTrace(); } } File tmpDownFile; try { tmpDownFile = File.createTempFile("ngrinder", "zip", directory); FileUtils.writeStringToFile(tmpDownFile, "test data"); tmpDownFile.deleteOnExit(); } catch (IOException e) { e.printStackTrace(); } agentApiController.getAll(userContext.getCurrentUser(), "NONE"); }