### Question:
FideliusController { @ResponseBody @GetMapping(value="/accounts") public ResponseEntity getAccounts() { final List<Account> accounts = accountsService.getAccounts(); if(accounts != null && accounts.size() > 0) return new ResponseEntity<>(accounts, HttpStatus.OK); return new ResponseEntity<>("No Accounts found", HttpStatus.NOT_FOUND); }  @RequestMapping(value = "/heartbeat", method = RequestMethod.GET) ResponseEntity heartbeatEndpoint(); @RequestMapping(value = "/credentials", method = RequestMethod.GET) ResponseEntity getCredentials(@RequestParam("account") String account,
                                                           @RequestParam("region") String region,
                                                           @RequestParam("application") String app); @ResponseBody @GetMapping(value="/credentials/{key:.+}/") ResponseEntity getCredential(@PathVariable("key") String longKey,
                                        @RequestParam("account") String account,
                                        @RequestParam("region") String region,
                                        @RequestParam("application") String application
    ); @RequestMapping(value = "/credentials/history", method = RequestMethod.GET) ResponseEntity getCredentialHistory(@RequestParam("account") String account,
                                                                   @RequestParam("region") String region,
                                                                   @RequestParam("application") String app,
                                                                   @RequestParam("environment") String environment,
                                                                   @RequestParam(value = "component", required = false) String component,
                                                                   @RequestParam("shortKey") String key); @ResponseBody @GetMapping(value="/credentials/secret") ResponseEntity getSecret(@RequestParam("account") String account,
                                      @RequestParam("region") String region,
                                      @RequestParam("application") String application,
                                      @RequestParam("environment") String environment,
                                      @RequestParam(value = "component", required = false) String component,
                                      @RequestParam("shortKey") String shortKey); @ResponseBody @PostMapping(value="/credentials/secret") ResponseEntity createCredential(@Valid @RequestBody Credential credential); @ResponseBody @PutMapping(value="/credentials/secret") ResponseEntity updateCredential(@Valid @RequestBody Credential credential); @ResponseBody @DeleteMapping(value="/credentials/secret") ResponseEntity deleteCredential(@RequestParam("account") String account,
                                                       @RequestParam("region") String region,
                                                       @RequestParam("application") String application,
                                                       @RequestParam("environment") String environment,
                                                       @RequestParam(value = "component", required = false) String component,
                                                       @RequestParam("shortKey") String shortKey); @ResponseBody @GetMapping(value="/validActiveDirectoryRegularExpression") ResponseEntity activeDirectory(); @ResponseBody @GetMapping(value="/accounts") ResponseEntity getAccounts();  }### Answer:
@Test @WithMockUser public void shouldReturnAWSAccounts() throws Exception { Account account = new Account(); account.setAccountId("342391"); account.setAlias("NewAccount"); account.setName("accountName"); account.setSdlc("dev"); List<Account> accounts = new ArrayList<>(); accounts.add(account); when(accountsService.getAccounts()).thenReturn(accounts); mockMvc.perform(getAccountsRequest) .andExpect(status().is2xxSuccessful()) .andExpect(content().string("[{\"accountId\":\"342391\",\"name\":\"accountName\",\"sdlc\":\"dev\",\"alias\":\"NewAccount\",\"regions\":null}]")); }
@Test public void shouldReturn401ErrorIfUserNotFoundOnAWSAccounts() throws Exception { when(accountsService.getAccounts()).thenReturn(null); mockMvc.perform(getAccountsRequest) .andExpect(status().is4xxClientError()); }
@Test @WithMockUser public void shouldReturn404ErrorIfNoAWSAccounts() throws Exception { when(accountsService.getAccounts()).thenReturn(null); mockMvc.perform(getAccountsRequest) .andExpect(status().is4xxClientError()); }