When a modern robust application has to deal with failures, it tries to continue operating gracefully keeping a normal external behaviour. Usually each of these failures are reported to a logging system in order that they can be monitorized. Not only failures are reported, any relevant event is logged with the same purpose.
As soon as you build an API including a few operations, you will realize that is hard to maintain code and documentation in sync. Therefore you can use a tool like Swagger. It can generate easly a high quality documentation for you.
Swagger is both a specification and a framework implementation. The strength of Swagger is its hability to keep in sync the code and the documentation. Once you integrate Swagger with your server app, it will generate a live RESTful documentation which will let you navigate and test without coding a single line.
How to integrate your Spring Boot Application with Swagger
First step: Enabling Swagger
Including this annotation in a configuration class
JGIT-Flow Maven Plugin is an alternative to the old maven-release-plugin that supports git-flow via maven.
The main benefit of using this plugin is that it handles git branches/tags, pom versions (both release and SNAPSHOTS), and builds the project after each merging/rebasing to ensure stability.
Only works for those spring beans present in the test class. If you need to inject the mock in every bean that depends on, you must declare and autowire all those beans ( although you do not require them ).
Mocks are injected after all the Spring initializations and post-processing. If you are using @PostConstruct, FactoryBean or similar, your mocks will be injected too late and will not be invoked.
An alternative is to use @MockedBean and @EnableMockedBean. By means of these annotations, mocks are created and directly injected into the Spring Context. The original beans are replaced by the mocks, before any initialization and post-processing happen.
@EnableMockedBean@SpringBootApplication@RunWith(SpringJUnit4ClassRunner.class)@SpringApplicationConfiguration(classes=MockedBeanTest.class)publicclassMockedBeanTest{@MockedBeanprivateHelloWorldServicehelloWorldService;@AutowiredprivateMiddleComponentmiddleComponent;@TestpublicvoidhelloWorldIsCalledOnlyOnce(){middleComponent.getHelloMessage();// THEN HelloWorldService is called only onceverify(helloWorldService,times(1)).getHelloMessage();}}