This API model an account service according to REST guidelines. It's able to create, access, find accounts and to transfer money between them.
For more info:
Project is created with:
- Java
- IntelliJ IDEA
- Spring Boot
- Spring Web MVC
- Spring Data JPA
- Spring HATEOAS
- H2
- JUnit 5
- Mockito
- Git
- Inputs will not be validated (for example with @Valid). The requirements do not ask for it, and I am short on time. It would be interesting to add it at some future point.
- 4 accounts functionalities have been implemented:
- see all accounts at get(/accounts)
- see an account at get(/accounts/{accountId})
- create an account at post(/accounts)
- edit an account at put(/accounts/{accountId})
- It has been decided that put also returns status 201
- The transfers will be modeled by the entity 'Transfer'
- transfers are perform at post(/transfers), passing as argument a 'Transfer' in json
- The @Transactional annotation has been used to ensure that transfers are perform transactionally
- The transaction propagation has been set to 'nested', considering it the most appropriate (source)
- when trying an illegal transaction or when trying to use an account that doesn't exist, the system returns an error message in json format
- there has been no need to unit test the persistence layer since no new queries have been added to the ones inherited from JpaRepository
- It would be interesting to take the currency into account when making transactions. For example, a service could be created to provide the exchange rate. In this exercise, for simplicity and due to not being explicitly indicated in the requirements, this issue has been ignored.
- year: 2020
- project name: secondrest
- author: MISRRAIM SUÁREZ PÉREZ
- mail: misrraimsp@gmail.com
- last version: 13/09/2020
- Building REST services with Spring
- Unit Testing with Spring Boot
- Testing MVC Web Controllers with Spring Boot and @WebMvcTest
- Testing JPA Queries with Spring Boot and @DataJpaTest
- Integration Tests with Spring Boot and @SpringBootTest
- Mocking with (and without) Spring Boot
- Testing a HATEOAS service
- Global exception handling with @ControllerAdvice