Hi Emanuel, the issue with the AccountService class is that it relies on two global dependencies: UUID.randomUUID() and the Account constructor. These globals cause side effects and hide dependencies, making testing difficult and requiring complex mocks.
The real problem is the use of globals. If you replace these global dependencies with proper abstractions, like lambdas, you eliminate the need for hard mocks. For instance, you can inject a UUIDGenerator and an AccountBuilder, which also solves the dependency issue, but with an extra bonus.
Using Spring or any other automatic dependency injection framework will quickly address this and simplify the final code.