LeaderController { @GetMapping public String getInfo() { if (this.context == null) { return String.format("I am '%s' but I am not a leader of the '%s'", this.host, this.role); } return String.format("I am '%s' and I am the leader of the '%s'", this.host, this.role); } LeaderController(); @GetMapping String getInfo(); @PutMapping ResponseEntity<String> revokeLeadership(); @EventListener void handleEvent(OnGrantedEvent event); @EventListener void handleEvent(OnRevokedEvent event);  }
@Test public void shouldGetNonLeaderInfo() { String message = String.format("I am '%s' but I am not a leader of the 'null'", this.host); assertThat(this.leaderController.getInfo()).isEqualTo(message); }