A example using jackson and json object from json simple. The json has a complex json scenario.i.e. json within json which we handle using a POJO as well as JsonObject.
- We have 2 methods of accessing the data -
- Direct file access.
- I have build an API endpoint to return the json via a GET, so that we have a more real world data point.
Yep, its true.
If you try this, you will find your your @Autowired dependencies return a null pointer. This is because we lose context at runtime of our injection. To curb this, we need to extend our SpringBootTest to include some other dependencies.
@RunWith -> JunitPlatform.class, to run test tags with @IncludeTags @ExcludeTags @SuiteDisplayName @Tag -> test tags @RepeatableTest @DisplayName
I use java 8 lambda on assertAll for junit-jupiter.
Using spring to build the API is like super simple. Using SpringBoot Dependency Injection -> @AutoWired to pull through our business/data-layer.