This project is a Spring Boot 3 application using Java 17, H2 in-memory database, and various Spring components like Spring Data JPA, Spring Validation, and more. The application includes unit tests with JUnit 5 and Mockito.
- method1:
POST /push
json body: {"value":"value1"} - method2:
GET /pop
returns json {"value": "value1"}
- build with maven or gradle
- implement unit tests
- swagger documentation
- readme document with instructions on build and run
- optionally: arrange storage in local H2 database
- Java 17
- Spring Boot 3
- Spring Data JPA
- Spring Validation
- Springdoc OpenApi
- Spring Test
- JUnit 5
- Mockito
- H2 Database
- Maven
- Java 17
- Maven 3.6+
- Git
- Clone the repository:
git clone https://github.com/SergEndorfin/stack-test.git
cd stack-test
- Build the project:
mvn clean install
- Run the application:
mvn spring-boot:run
To run the tests, use the following command:
mvn test
- URL:
/push
- Method:
POST
- Content-Type:
application/json
- Request Body Example:
{
"value": "sample data"
}
- Responses:
- 201 Created - Data added successfully.
- 400 Bad Request - Invalid input data.
- 500 Internal Server Error - Internal server error occurred.
- URL:
/pop
- Method:
GET
- Responses:
- 200 OK - Data popped successfully.
- 404 Not Found - Data not found.
- 500 Internal Server Error - Internal server error occurred.
The application is configured to run on http://localhost:8080. You can change the server port and other settings in the
application.yml
file.
The application uses an H2 in-memory database for development and testing purposes. The database console is available at:
http://localhost:8080/h2-console.
JDBC URL: jdbc:h2:mem:testdb
Username: sa
Password: (leave empty)
The API documentation is available via OpenAPI/Swagger. When application is running access it at:
http://localhost:8080/swagger-ui/index.html
Here are some examples of request and response bodies for reference.
{
"value": "sample data"
}
{
"apiPath": "/push",
"errorCode": "BAD_REQUEST",
"errorMessage": "{value=The length of the Value should be between 3 and 30}",
"errorTime": "2024-07-26T18:53:06.597Z"
}
To add a new dependency, modify the pom.xml file:
<dependency>
<groupId>group-id</groupId>
<artifactId>artifact-id</artifactId>
<version>version</version>
</dependency>
After making changes, ensure the project builds correctly:
mvn clean install
- Fork the repository.
- Create a new branch (git checkout -b feature-branch).
- Commit your changes (git commit -am 'Add new feature').
- Push to the branch (git push origin feature-branch).
- Create a new Pull Request.
This project is not licensed and open source.
For any inquiries or support, please contact:
- Name: Sergii Kononenko
- Email: [email protected]
Happy coding!