Skip to content

francescofiora/products

Repository files navigation

Products

SpringBoot Rest Api tutorial with OpenApi 3.0 and PostgreSql.

Topics covered

  • Spring Boot Rest Api
  • Swagger UI for visualizing APIs
  • Error Handling
  • Basic Authentication
  • Mapper for POJO<->DTO
  • Actuator
  • Eureka server and Open Feign
  • Logging
  • Testing
    • Repositories using DataJpaTest
    • Services using Mockito
    • EndPoints using WebMvcTest
    • Pojos and Dtos using OpenPojo
    • End to End Test with TestRestTemplate
    • Integration test using TestContainers and Cucumber

Getting Started

Compile

./gradlew clean build

Dependency-Check

./gradlew dependencyCheckAnalyze --info

Pitest

./gradlew pitest

SonarQube

Run SonarQube

docker-compose -f docker/docker-compose-sonar.yml up

For SonarQube configuration follow this link: Try Out SonarQube

Scan project

./gradlew sonarqube \
-Dsonar.projectKey=yourProjectKey \
-Dsonar.token=yourAuthenticationToken

Reports

company-api/build/reports/checkstyle/main.html
company-api/build/reports/checkstyle/test.html
company-api/build/reports/tests/test/index.html
company-api/build/reports/jacoco/test/index.html
company-api/build/reports/pitest/index.html
company-api/build/reports/dependency-check-report.html

company-dto/build/reports/checkstyle/main.html
company-dto/build/reports/checkstyle/test.html
company-dto/build/reports/tests/test/index.html
company-dto/build/reports/jacoco/test/index.html
company-dto/build/reports/pitest/index.html
company-dto/build/reports/dependency-check-report.html

product-api/build/reports/checkstyle/main.html
product-api/build/reports/checkstyle/test.html
product-api/build/reports/tests/test/index.html
product-api/build/reports/jacoco/test/index.html
product-api/build/reports/pitest/index.html
product-api/build/reports/dependency-check-report.html

product-common/build/reports/checkstyle/main.html
product-common/build/reports/checkstyle/test.html
product-common/build/reports/tests/test/index.html
product-common/build/reports/jacoco/test/index.html
product-common/build/reports/pitest/index.html
product-common/build/reports/dependency-check-report.html

product-dto/build/reports/checkstyle/main.html
product-dto/build/reports/checkstyle/test.html
product-dto/build/reports/tests/test/index.html
product-dto/build/reports/jacoco/test/index.html
product-dto/build/reports/pitest/index.html
product-dto/build/reports/dependency-check-report.html

product-eureka/build/reports/checkstyle/main.html
product-eureka/build/reports/checkstyle/test.html
product-eureka/build/reports/tests/test/index.html
product-eureka/build/reports/jacoco/test/index.html
product-eureka/build/reports/dependency-check-report.html

How to execute

docker-compose -f docker/docker-compose.yml up
java -jar ./product-api/build/libs/product-api-1.0-SNAPSHOT.jar
java -jar ./company-api/build/libs/company-api-1.0-SNAPSHOT.jar

Links

Security

  • Basic Authentication
    • Company Api: (user/password)
    • Product Api: (user/password)

Actuator

curl -u user:password 'http://localhost:8082/actuator/info' -i -X GET
curl -u user:password 'http://localhost:8082/actuator/health' -i -X GET
curl -u user:password 'http://localhost:8082/actuator/prometheus' -i -X GET
curl -u user:password 'http://localhost:8081/actuator/info' -i -X GET
curl -u user:password 'http://localhost:8081/actuator/health' -i -X GET
curl -u user:password 'http://localhost:8081/actuator/prometheus' -i -X GET

Create docker image

./gradlew jibDockerBuild

Integration test

Publish client and dto jars

./gradlew publishToMavenLocal

###Run Integration tests cd product-integration-test ./gradlew clean build

Technologies used

Releases

No releases published

Packages

No packages published