AgentManagerApiController { @GetMapping("/availableAgentCount") @PreAuthorize("permitAll") public Map<String, Integer> getAvailableAgentCount(User user, @RequestParam String targetRegion) { return buildMap("availableAgentCount", agentService.getReadyAgentCount(user.getUserId(), targetRegion)); }  @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);  }
@Test public void testGetAvailableAgentCount() { String targetRegion = "test"; Map<String, Integer> response = agentApiController.getAvailableAgentCount(getTestUser(), targetRegion); assertThat(0, is(response.get("availableAgentCount"))); }