DomainEvent { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final DomainEvent other = (DomainEvent) obj; return Objects.equals(this.id, other.id); } DomainEvent(String aggregateRootIdentifier);  DomainEvent(String aggregateRootIdentifier, int revision); protected  DomainEvent(); String getId(); String getAggregateRootIdentifier(); int getRevision(); ZonedDateTime getTimestamp(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void whenCreating_ShouldNotBeEqual() throws Exception { String sourceIdentifier = "sourceIdentifier"; DomainEvent event1 = new DomainEvent(sourceIdentifier); DomainEvent event2 = new DomainEvent(sourceIdentifier); boolean response = event1.equals(event2); assertThat(response, is(false)); }
@Test public void whenComparingWithNull_ShouldNotBeEqual() throws Exception { String sourceIdentifier = "sourceIdentifier"; DomainEvent event1 = new DomainEvent(sourceIdentifier); boolean response = event1.equals(null); assertThat(response, is(false)); }
@Test public void whenComparingSameInstance_ShouldBeEqual() throws Exception { String sourceIdentifier = "sourceIdentifier"; DomainEvent event1 = new DomainEvent(sourceIdentifier); boolean response = event1.equals(event1); assertThat(response, is(true)); }