Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Banking Application using Java8, Spring Boot, Spring Security and H2 DB
# Banking Application using Java 11, Spring Boot, Spring Security and H2 DB

RESTful API to simulate simple banking operations.

Expand Down Expand Up @@ -38,9 +38,9 @@ https://projectlombok.org/setup/eclipse

### Prerequisites

* Java 8
* Java 11 JDK (ensure JAVA_HOME environment variable is set to Java 11 installation)
* Spring Tool Suite 4 or similar IDE
* [Maven](https://maven.apache.org/) - Dependency Management
* [Maven](https://maven.apache.org/) 3.6+ - Dependency Management

### Maven Dependencies

Expand All @@ -52,8 +52,7 @@ spring-boot-starter-web
spring-boot-devtools
h2 - Inmemory database
lombok - to reduce boilerplate code
springfox-swagger2
springfox-swagger-ui
springdoc-openapi-ui - OpenAPI 3.0 documentation
spring-boot-starter-test
spring-security-test

Expand All @@ -64,10 +63,12 @@ spring-security-test
Please find the Rest API documentation in the below url

```
http://localhost:8989/bank-api/swagger-ui.html
http://localhost:8989/bank-api/swagger-ui/index.html

```

Note: SpringDoc OpenAPI uses a different URL pattern than the legacy Springfox implementation.

## H2 In-Memory Database

Make sure to use jdbc:h2:mem:testdb as your jdbc url. If you intend to you use custom database name, please
Expand Down
16 changes: 6 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<version>2.7.18</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.coding.exercise</groupId>
Expand All @@ -15,7 +15,7 @@
<description>Bank App Spring Boot Project</description>

<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -52,15 +52,11 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.15</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.10.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,18 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;

@Configuration
@EnableSwagger2
public class ApplicationConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.paths(PathSelectors.any())
.build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("BANKING APPLICATION REST API")
.description("API for Banking Application.")
.version("1.0.0").build();
public OpenAPI customOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("BANKING APPLICATION REST API")
.description("API for Banking Application.")
.version("1.0.0"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@
import com.coding.exercise.bankapp.domain.TransferDetails;
import com.coding.exercise.bankapp.service.BankingServiceImpl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

@RestController
@RequestMapping("accounts")
@Api(tags = { "Accounts and Transactions REST endpoints" })
@Tag(name = "Accounts and Transactions REST endpoints")
public class AccountController {

@Autowired
private BankingServiceImpl bankingService;

@GetMapping(path = "/{accountNumber}")
@ApiOperation(value = "Get account details", notes = "Find account details by account number")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@Operation(summary = "Get account details", description = "Find account details by account number")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public ResponseEntity<Object> getByAccountNumber(@PathVariable Long accountNumber) {

return bankingService.findByAccountNumber(accountNumber);
}

@PostMapping(path = "/add/{customerNumber}")
@ApiOperation(value = "Add a new account", notes = "Create an new account for existing customer.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@Operation(summary = "Add a new account", description = "Create an new account for existing customer.")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public ResponseEntity<Object> addNewAccount(@RequestBody AccountInformation accountInformation,
@PathVariable Long customerNumber) {
Expand All @@ -54,10 +54,10 @@ public ResponseEntity<Object> addNewAccount(@RequestBody AccountInformation acco
}

@PutMapping(path = "/transfer/{customerNumber}")
@ApiOperation(value = "Transfer funds between accounts", notes = "Transfer funds between accounts.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@Operation(summary = "Transfer funds between accounts", description = "Transfer funds between accounts.")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public ResponseEntity<Object> transferDetails(@RequestBody TransferDetails transferDetails,
@PathVariable Long customerNumber) {
Expand All @@ -66,10 +66,10 @@ public ResponseEntity<Object> transferDetails(@RequestBody TransferDetails trans
}

@GetMapping(path = "/transactions/{accountNumber}")
@ApiOperation(value = "Get all transactions", notes = "Get all Transactions by account number")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@Operation(summary = "Get all transactions", description = "Get all Transactions by account number")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public List<TransactionDetails> getTransactionByAccountNumber(@PathVariable Long accountNumber) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,58 @@
import com.coding.exercise.bankapp.domain.CustomerDetails;
import com.coding.exercise.bankapp.service.BankingServiceImpl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

@RestController
@RequestMapping("customers")
@Api(tags = { "Customer REST endpoints" })
@Tag(name = "Customer REST endpoints")
public class CustomerController {

@Autowired
private BankingServiceImpl bankingService;

@GetMapping(path = "/all")
@ApiOperation(value = "Find all customers", notes = "Gets details of all the customers")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@Operation(summary = "Find all customers", description = "Gets details of all the customers")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public List<CustomerDetails> getAllCustomers() {

return bankingService.findAll();
}

@PostMapping(path = "/add")
@ApiOperation(value = "Add a Customer", notes = "Add customer and create an account")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@Operation(summary = "Add a Customer", description = "Add customer and create an account")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public ResponseEntity<Object> addCustomer(@RequestBody CustomerDetails customer) {

return bankingService.addCustomer(customer);
}

@GetMapping(path = "/{customerNumber}")
@ApiOperation(value = "Get customer details", notes = "Get Customer details by customer number.")
@Operation(summary = "Get customer details", description = "Get Customer details by customer number.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = CustomerDetails.class, responseContainer = "Object"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public CustomerDetails getCustomer(@PathVariable Long customerNumber) {

return bankingService.findByCustomerNumber(customerNumber);
}

@PutMapping(path = "/{customerNumber}")
@ApiOperation(value = "Update customer", notes = "Update customer and any other account information associated with him.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@Operation(summary = "Update customer", description = "Update customer and any other account information associated with him.")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public ResponseEntity<Object> updateCustomer(@RequestBody CustomerDetails customerDetails,
@PathVariable Long customerNumber) {
Expand All @@ -76,10 +76,10 @@ public ResponseEntity<Object> updateCustomer(@RequestBody CustomerDetails custom
}

@DeleteMapping(path = "/{customerNumber}")
@ApiOperation(value = "Delete customer and related accounts", notes = "Delete customer and all accounts associated with him.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })
@Operation(summary = "Delete customer and related accounts", description = "Delete customer and all accounts associated with him.")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })

public ResponseEntity<Object> deleteCustomer(@PathVariable Long customerNumber) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.coding.exercise.bankapp;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class BankingApplicationTests {

Expand Down