Leader { public boolean isCandidate(Candidate candidate) { if (candidate == null) { return false; } return Objects.equals(this.role, candidate.getRole()) && Objects.equals(this.id, candidate.getId()); } Leader(String role, String id); String getRole(); String getId(); boolean isCandidate(Candidate candidate); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void shouldCheckWithNullCandidate() { assertThat(this.leader.isCandidate(null)).isEqualTo(false); }