### Question:
AccountController { @RequestMapping(path = "/accounts", method = RequestMethod.GET) public ResponseEntity<List<Account>> getAccounts() { return ResponseEntity.ok(service.getAccounts()); }  @RequestMapping(path = "/account/{id}", method = RequestMethod.GET) ResponseEntity<Account> getAccountById(@PathVariable Long id); @RequestMapping(path = "/accounts", method = RequestMethod.GET) ResponseEntity<List<Account>> getAccounts(); @RequestMapping(path = "/account", method = RequestMethod.POST) ResponseEntity<Account> addAccount(@RequestBody Account account); @RequestMapping(path = "/account/{id}", method = RequestMethod.PUT) ResponseEntity<Account> updateAccount(@PathVariable Long id, @RequestBody Account account); @RequestMapping(path = "/account/{id}", method = RequestMethod.DELETE) ResponseEntity<String> deleteAccount(@PathVariable Long id);  }### Answer:
@Test public void whenGetAccountsInvokedItShouldReturnAccountList() { List<Account> accounts = new ArrayList<>(); Account mockAccount = mock(Account.class); accounts.add(mockAccount); when(mockAccount.getId()).thenReturn(new Long(1)); when(mockAccount.getName()).thenReturn("Sagar Jadhav"); when(service.getAccounts()).thenReturn(accounts); ResponseEntity<List<Account>> responseEntity = controller.getAccounts(); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(accounts.size(), responseEntity.getBody().size()); assertEquals(accounts.get(0), responseEntity.getBody().get(0)); }