How shaunthomas999/junit5-samples works
This repository contains two Java sample areas: small JUnit demonstration targets and a Spring Boot product-lookup API. The API workflow is an HTTP request to search by product name, service delegation to a repository, and a product response or mapped error. The JUnit module’s production examples are a calculator and palindrome checker; its test filenames indicate demonstrations of JUnit 5 features and JUnit 4 comparison. Those test sources were not sampled, so their detailed invocation wiring is not shown.
Main entry points: ProductsEndpoint.java Products endpoint · ProductsRepository.java Products repository · GlobalExceptionHandler.java Exception handler · ProductsService.java Products service
Components 23
JUnit samples
- Calculator
junit5-features/src/main/java/com/shaunthomas999/junit5/comparison/Calculator.java - Palindrome checker
junit5-features/src/main/java/com/shaunthomas999/junit5/features/Palindrome.java - JUnit 4 comparison
junit5-features/src/test/java/com/shaunthomas999/junit5/comparison/CalculatorJunit4Test.java - JUnit 5 comparison
junit5-features/src/test/java/com/shaunthomas999/junit5/comparison/CalculatorJunit5Test.java - Assertions
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeAssertionsTest.java - Assumptions
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeAssumptionsTest.java - Dynamic tests
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeDynamicTest.java - Nested tests
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeNestedTest.java - Parameterized tests
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeParameterizedTest.java - Repeated tests
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeRepeatedTest.java - Names and tags
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeDisplayNamesAndTagsTest.java - Custom annotation
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeTestAnnotation.java - Unit test suite
junit5-features/src/test/java/com/shaunthomas999/junit5/features/PalindromeUnitTestSuite.java
Product API
- Spring Boot app
spring-boot-mockito-junit5/src/main/java/com/shaunthomas999/products/SpringBootMockitoJunit5App.java - Products endpoint
spring-boot-mockito-junit5/src/main/java/com/shaunthomas999/products/endpoints/ProductsEndpoint.java - Products service
spring-boot-mockito-junit5/src/main/java/com/shaunthomas999/products/services/ProductsService.java - Products repository
spring-boot-mockito-junit5/src/main/java/com/shaunthomas999/products/repository/ProductsRepository.java - Product entity
spring-boot-mockito-junit5/src/main/java/com/shaunthomas999/products/model/Product.java - Exception handler
spring-boot-mockito-junit5/src/main/java/com/shaunthomas999/products/endpoints/exceptions/GlobalExceptionHandler.java - Error details
spring-boot-mockito-junit5/src/main/java/com/shaunthomas999/products/endpoints/exceptions/ErrorDetails.java - Not-found exception
spring-boot-mockito-junit5/src/main/java/com/shaunthomas999/products/endpoints/exceptions/ResourceNotFoundException.java
Other components
- API client
- Relational database
Connections 9
- API client → Products endpoint: requests products
- Spring Boot app → Products endpoint: serves routes
- Products endpoint → Products service: searches by name
- Products service → Products repository: queries name
- Products repository → Product entity: maps entity
- Products repository → Relational database: reads product
- Products endpoint → Not-found exception: throws if absent
- Exception handler → Not-found exception: handles
- Exception handler → Error details: builds response