@Test public void depositCommand() { final Client hans = new Client("hans", LocalDate.parse("1966-12-31")); final Client lisa = new Client("lisa", LocalDate.parse("1972-02-16")); final ApplicationController ctl = new ApplicationController(null); final ResponseEntity<ClientResource[]> result = ctl._clientsToResources(Arrays.asList(hans, lisa)); final ClientResource hansResource = result.getBody()[0]; final ClientResource lisaResource = result.getBody()[1]; assertEquals(2, result.getBody().length); assertEquals(null, hansResource.id); assertEquals("hans", hansResource.username); assertEquals("31.12.1966", hansResource.birthDate); assertEquals(null, lisaResource.id); assertEquals("lisa", lisaResource.username); assertEquals("16.02.1972", lisaResource.birthDate); }
ResponseEntity<ClientResource[]> _clientsToResources(final List<Client> clients) { final Stream<ClientResource> result = clients.stream().map(ClientResource::new); final ClientResource[] resultArray = result.toArray(ClientResource[]::new); return new ResponseEntity<>(resultArray, HttpStatus.OK); }
ApplicationController { ResponseEntity<ClientResource[]> _clientsToResources(final List<Client> clients) { final Stream<ClientResource> result = clients.stream().map(ClientResource::new); final ClientResource[] resultArray = result.toArray(ClientResource[]::new); return new ResponseEntity<>(resultArray, HttpStatus.OK); } }
ApplicationController { ResponseEntity<ClientResource[]> _clientsToResources(final List<Client> clients) { final Stream<ClientResource> result = clients.stream().map(ClientResource::new); final ClientResource[] resultArray = result.toArray(ClientResource[]::new); return new ResponseEntity<>(resultArray, HttpStatus.OK); } @Autowired  ApplicationController(final BankService bankService); }
ApplicationController { ResponseEntity<ClientResource[]> _clientsToResources(final List<Client> clients) { final Stream<ClientResource> result = clients.stream().map(ClientResource::new); final ClientResource[] resultArray = result.toArray(ClientResource[]::new); return new ResponseEntity<>(resultArray, HttpStatus.OK); } @Autowired  ApplicationController(final BankService bankService); @GetMapping(path = "/") ResponseEntity<String> home(/* final WebSecurityConfig webSecurityConfig, */final HttpMethod method,
			final WebRequest request); @ApiOperation(value = "Creates 2 random clients, sometimes fails after first. " + "Returns a list of all clients. This is useful for populating the database " + "and for checking, if the transaction rollback mechanism works.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/bank/pair") ResponseEntity<ClientResource[]> create2Clients(@ApiParam(hidden = true) final HttpMethod method,
			final WebRequest request); @ApiOperation(value = "Create a client from the passed client resource.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/bank/client") ResponseEntity<ClientResource> createClient(@RequestBody final ClientResource clientResource,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Delete the client with the given username.", authorizations = { @Authorization(value = "basicAuth") }) @DeleteMapping("/bank/client/{username}") ResponseEntity<String> deleteClient(@PathVariable @ApiParam("username of client") final String username,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Find clients. Omit Parameters to retrieve all clients.", authorizations = { @Authorization(value = "basicAuth") }) @GetMapping(path = "/bank/client") ResponseEntity<ClientResource[]> findClients(
			@ApiParam("Returns all clients born at fromBirth or later.") @RequestParam(name = "fromBirth", defaultValue = "") final String fromBirth,
			@ApiParam("Returns all clients with an account with a balance of minBalance or more.") @RequestParam(name = "minBalance", defaultValue = "") final String minBalance,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Creates a new account for the authenticated client with his userName. " + "The account gets the name, which is passed as request body.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/client/account") ResponseEntity<AccountAccessResource> createAccount(@RequestBody final String accountName,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Deposits the given amount of money to the account with the given accountNo. " + "This is executed as the authenticated client with his username.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/client/deposit") ResponseEntity<Void> deposit(@RequestBody final DepositCommand command,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Transfers the given amount of money from the account with the given sourceAccountNo to " + "the account with the given destinationAccountNo. Requires, that the current user is the owner " + "of the given source account.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/client/transfer") ResponseEntity<AccountResource> transfer(@RequestBody final TransferCommand command,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Adds the client with the given username as an account manager to the account with the " + "given accountNo. Requires, that the current user is the owner of the given account.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/client/manager") ResponseEntity<AccountAccessResource> addAccountManager(@RequestBody final AddAccountManagerCommand command,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Returns a report of all accounts the current user manages with columns access right (isOwner|manages), the balance, and the name of the account", authorizations = { @Authorization(value = "basicAuth") }) @GetMapping("/client/account") ResponseEntity<String> accountsReport(@ApiParam(hidden = true) final HttpMethod method,
			final WebRequest request); }
ApplicationController { ResponseEntity<ClientResource[]> _clientsToResources(final List<Client> clients) { final Stream<ClientResource> result = clients.stream().map(ClientResource::new); final ClientResource[] resultArray = result.toArray(ClientResource[]::new); return new ResponseEntity<>(resultArray, HttpStatus.OK); } @Autowired  ApplicationController(final BankService bankService); @GetMapping(path = "/") ResponseEntity<String> home(/* final WebSecurityConfig webSecurityConfig, */final HttpMethod method,
			final WebRequest request); @ApiOperation(value = "Creates 2 random clients, sometimes fails after first. " + "Returns a list of all clients. This is useful for populating the database " + "and for checking, if the transaction rollback mechanism works.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/bank/pair") ResponseEntity<ClientResource[]> create2Clients(@ApiParam(hidden = true) final HttpMethod method,
			final WebRequest request); @ApiOperation(value = "Create a client from the passed client resource.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/bank/client") ResponseEntity<ClientResource> createClient(@RequestBody final ClientResource clientResource,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Delete the client with the given username.", authorizations = { @Authorization(value = "basicAuth") }) @DeleteMapping("/bank/client/{username}") ResponseEntity<String> deleteClient(@PathVariable @ApiParam("username of client") final String username,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Find clients. Omit Parameters to retrieve all clients.", authorizations = { @Authorization(value = "basicAuth") }) @GetMapping(path = "/bank/client") ResponseEntity<ClientResource[]> findClients(
			@ApiParam("Returns all clients born at fromBirth or later.") @RequestParam(name = "fromBirth", defaultValue = "") final String fromBirth,
			@ApiParam("Returns all clients with an account with a balance of minBalance or more.") @RequestParam(name = "minBalance", defaultValue = "") final String minBalance,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Creates a new account for the authenticated client with his userName. " + "The account gets the name, which is passed as request body.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/client/account") ResponseEntity<AccountAccessResource> createAccount(@RequestBody final String accountName,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Deposits the given amount of money to the account with the given accountNo. " + "This is executed as the authenticated client with his username.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/client/deposit") ResponseEntity<Void> deposit(@RequestBody final DepositCommand command,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Transfers the given amount of money from the account with the given sourceAccountNo to " + "the account with the given destinationAccountNo. Requires, that the current user is the owner " + "of the given source account.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/client/transfer") ResponseEntity<AccountResource> transfer(@RequestBody final TransferCommand command,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Adds the client with the given username as an account manager to the account with the " + "given accountNo. Requires, that the current user is the owner of the given account.", authorizations = { @Authorization(value = "basicAuth") }) @PostMapping("/client/manager") ResponseEntity<AccountAccessResource> addAccountManager(@RequestBody final AddAccountManagerCommand command,
			@ApiParam(hidden = true) final HttpMethod method, final WebRequest request); @ApiOperation(value = "Returns a report of all accounts the current user manages with columns access right (isOwner|manages), the balance, and the name of the account", authorizations = { @Authorization(value = "basicAuth") }) @GetMapping("/client/account") ResponseEntity<String> accountsReport(@ApiParam(hidden = true) final HttpMethod method,
			final WebRequest request);  }