Write BDD Unit Tests with BDDMockito and AssertJ

Write BDD Unit Tests with BDDMockito and AssertJ

In this post, I’ll show you how to write more readable Unit Tests using a Behavior-Driven Development style (BDD). This is a coding style that is very easy to adopt and, at the same time, brings a huge benefit: it increases your test readability (a lot). Besides, it’s a small change that may drive you to go full-BDD (i.e. writing your test scenarios before your code).

With a practical example, you’ll see how to make this change with two very popular libraries: Mockito (and its BDDMockito implementation) and AssertJ.

read more

The Six Pitfalls of Moving to Microservices

The Six Pitfalls of Moving to Microservices

Microservices are not always the solution

We, as developers, make mistakes. For example, one of the most common ones is thinking that a new technical solution or paradigm will solve all the problems existing in a given Software Project. That won’t happen, but we’ll be tempted anyway to fall into this trap. Microservices Architecture is one of the most popular traps.

read more

Guide to Java's Future and CompletableFuture

Guide to Java's Future and CompletableFuture

This post uses a practical example to compare two different approaches to asynchronous tasks in Java: Future and CompletableFuture. It also includes the synchronous alternatives so you know the differences when using these asynchronous APIs.

read more

Reactive Programming with Java 9's Flow

Reactive Programming with Java 9's Flow

In this guide, you’ll learn with an example of how the Flow API in Java 9 can help you build Reactive patterns with the new Publisher and Subscriber interfaces. After reading it, you should be able to understand this new programming style and its pros and cons. All the code is on GitHub so you can also run it yourself or try some modifications.

read more

A practical book about Microservices

A practical book about Microservices

Microservices are getting very popular these days. This type of software architecture has a lot of advantages like flexibility and ease at scale. Mapping them into small teams in an organization also gives a lot of efficiency in development.

However, going on the adventure of microservices knowing only the benefits is a wrong call. You need to know what are the new paradigms and changes that you will face and prepare for that in advance. Books and articles can provide you with some knowledge but, when you get hands-on-code, the story changes.

read more

How to improve the eviction policy in the Eureka Service Registry

How to improve the eviction policy in the Eureka Service Registry

If you use Ribbon and Eureka in your Spring Boot application, you’ll notice that the default configuration is not optimal. Eureka takes a long time to figure out that the service went down unexpectedly and, in the meantime, your load balancer Ribbon will try to connect to the dead one. In other words, the eviction policy does not perform well by default.

On the other hand, the official Eureka documentation discourages changing the leaseRenewalIntervalInSeconds parameter so, what can we do here? This post answers that question.

read more

Hystrix fallback with Zuul and Spring Boot

Hystrix fallback with Zuul and Spring Boot

When we work with a Gateway Service like Zuul, probably we want to include a Circuit Breaker mechanism to avoid ugly errors in case of redirecting to a service which is unavailable or not responding in time. We can do that by connecting Hystrix with Zuul with a ZuulFallbackProvider bean. Let’s see how.

read more