Java

Testing Java Spring Boot Microservices

Testing Java Spring Boot Microservices

Tests are an essential part of any codebase. At a minimum, they help prevent regressions as the code evolves. But not all tests are created equal — unit, integration, component, contract, and end-to-end tests each serve a distinct purpose.

This article presents a practical strategy for testing Java Spring Boot microservices, covering the role, scope, and tooling for each test type to help you make the most of your test suite.

Continue reading
Setup a Circuit Breaker with Hystrix, Feign Client and Spring Boot

Setup a Circuit Breaker with Hystrix, Feign Client and Spring Boot

In a microservices architecture, many things can go wrong: middleware can fail, the network may be unstable, or the service you’re calling might be down. In this uncertain environment, anticipating failures is crucial to prevent breaking the entire chain and delivering errors to the end user—when you could instead offer a partially degraded experience.

This article explains how to implement the circuit breaker pattern using Hystrix, Feign Client, and Spring Boot.

Continue reading
Refactoring Conditional Structures with Map

Refactoring Conditional Structures with Map

I often come across code snippets like this:

public class Day {
  public void start(Weather weather) {
    switch(weather) {
      case RAINY:
          takeAnUmbrella();
          break;
      case SUNNY:
          takeAHat();
          break;
      case STORMY:
          stayHome();
          break;
      default:
          doNothing();
          break;
    }
  }
}

Here, a specific action depends on the weather. This kind of code is difficult to test and maintain. This short article shows how to refactor it using a Map.

Continue reading
Gérer les dépendances circulaires

Gérer les dépendances circulaires

Durant mon travail, j’ai rencontré des dépendances circulaires dans une application sur laquelle je suis intervenue. Dans sa plus simple forme, il s’agit de deux classes qui dépendent l’une de l’autre. Ceci est, selon moi, un problème pour plusieurs raisons. L’objectif de cet article est de montrer ce qu’est une dépendance circulaire, en quoi cela peut poser problème, et comment les éliminer.

Continue reading