DomainEvent { @Override public int hashCode() { return Objects.hash(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 whenCreatingHashOfTwoObject_ShouldNotBeEqual() throws Exception { String sourceIdentifier = "sourceIdentifier"; DomainEvent event1 = new DomainEvent(sourceIdentifier); DomainEvent event2 = new DomainEvent(sourceIdentifier); int hashForEvent1 = event1.hashCode(); int hashForEvent2 = event2.hashCode(); assertThat(hashForEvent1, not(equalTo(hashForEvent2))); }