The goal of this project is to build a cloud storage microservice application using Google Cloud Platform (GCP) SDK and the Spring Boot JAVA framework. The application will utilize the GCP Storage service to store and manage data in the cloud. The data objects will be manipulated using a local library and its functionality will be exposed usng an API controller built using OpenAPI3 "Swagger"
- Java 17
- Spring Boot 2.7.6
- Maven 4.0.0
- Docker 20.10.17
This project is a simple Microservice. It is a Spring Boot application that can be run locally or in a Docker container. The purpose of this project is to build a simple microservice using the Google cloud platform to perform Business Intelligence .
You can download it from the Oracle website
git clone https://github.com/CPNV-ES-BI/BI_JAVA_GCP.git
- Spring Boot Starter
- Spring Boot Starter Web
- Spring Cloud GCP Starter
- Spring Cloud GCP Starter Storage
- Springdoc Openapi UI
- Spring Boot Starter Test
Run the spring boot application locally using the maven wrapper.
./mvnw spring-boot:run
In order to run the tests, we need to configure the environnement properties in the project.
A file name src/main/resources/gcp.example.properties contain those variables:
GCP_ACCESS_KEY_ID=
GCP_SECRET_ACCESS_KEY=
GCP_PROJECT_ID=
GCP_CLIENT_ID=
GCP_CLIENT_EMAIL=
GCP_BUCKET_NAME=
All those variables need to be set for the proper conduct of the tests like this:
GCP_ACCESS_KEY_ID=test
Even if it's a string, a property value doesn't contain quotes.
This command will run all the tests in the project.
./mvnw test
This command will run all the tests in the DataObjectControllerTest class.
./mvnw test -Dtest=DataObjectControllerTest
This command will run the test_DoesExist_ExistsCase_True test in the DataObjectControllerTest class. To make this work, you add to separate the class name from the method name with a #.
./mvnw test -Dtest=DataObjectControllerTest#test_DoesExist_ExistsCase_True
Those commands create and run the docker using docker-compose.
docker compose up developement
docker compose up test
This command starts the image and run it as a container. It runs all tests and report the result in the console.
During the project, a continous integration github action has been created to test the unit test from the project.
The configuration of the file can be find in the wiki.
The directory structure of the project is as follows:
- .github/workflows
- main.yml
- src
- main
- java
- com
- cpnv
- bijavagcp
- api
- DataObjectController
- config
- GcpConfiguration
- exceptions
- ObjectAlreadyExistsException
- ObjectNotFoundException
- services
- DataObject
- DataObjectService
- BiJavaGcpApplication
- resources
- application.properties
- gcp.properties
- test
- java
- com
- cpnv
- bijavagcp
- services
- DataObjectControllerTest
- docker-compose.yml
- Dockerfile
- README.md
- mvnw
- mvnw.cmd
- pom.xml
The root directory contains all the configuration files for the project and the dockerfile while the src directory is split into two parts: main and test. The main directory contains the code of the application while the test directory contains the tests of the application.
For branching, we will use the Gitflow branching model due to its simplicity and ease of use. Wiki link for specification : wiki
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.