I am trying to implement a Junit test for a method that is annotated with @Transactional. I do not want to test if the Transactional works or not, I just want to test some logic before the save method. The point is that there is no DDBB locally to connect and because the method is annotated with @Transactional it tries to connect to the database because the method is annotated with @Transactional and must to start a transaction so the test show this error:
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
If in the "application.yaml" test file I add the real database connection obviously it works because it is able to connect to a database but for locally test purpose I would like to be able to avoid that
How can I avoid the method test tries to connect to the database because of the transnational annotation?
Thanks in advance