SimpleIdentified implements Identified<T> { @Override public final I getId() { return id; } SimpleIdentified(I id); @Override final I getId(); @Override final int hashCode(); @Override final boolean equals(Object o);  }
@Test void getIdReturnsIdPassedIntoConstructor() { assertSame(id, simpleIdentified.getId()); }
@Test void isEqualToInstanceWithSameId() { SimpleIdentified<Object, I> instanceWithSameId = buildTestInstance(simpleIdentified.getId()); assertEquals(simpleIdentified, instanceWithSameId); assertEquals(instanceWithSameId, simpleIdentified); }
@Test void isNotEqualToInstanceWithDifferentId() { I otherId = getDifferentId(simpleIdentified.getId()); assertNotEquals(simpleIdentified.getId(), otherId); T instanceWithDifferentId = buildTestInstance(otherId); assertNotEquals(simpleIdentified, instanceWithDifferentId); assertNotEquals(instanceWithDifferentId, simpleIdentified); }
@Test void isNotEqualToInstanceWithDifferentClass() { SimpleIdentified<Object, I> instanceWithDifferentClass = new SimpleIdentified<Object, I>(simpleIdentified.getId()) {}; assertNotEquals(simpleIdentified, instanceWithDifferentClass); assertNotEquals(instanceWithDifferentClass, simpleIdentified); }