EntityIdWithType implements EntityId, WithEntityType { public boolean isCompatibleOrThrow(@Nullable final EntityIdWithType otherEntityId) { if (!equals(otherEntityId)) { throw getIllegalArgumentExceptionForDifferentEntityIds(otherEntityId); } return true; } protected  EntityIdWithType(final EntityId entityId); @Deprecated static Consumer<I> createEqualityValidator(final I expectedEntityId); boolean isCompatibleOrThrow(@Nullable final EntityIdWithType otherEntityId); @Override boolean isDummy(); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void checkSameId() { final EntityIdWithType entityIdFoo = DummyImplementation.of(ENTITY_TYPE_PLUMBUS, "foo"); assertThat(entityIdFoo.isCompatibleOrThrow(entityIdFoo)).isTrue(); }
@Test public void checkDifferentIds() { final EntityIdWithType entityIdFoo = DummyImplementation.of(ENTITY_TYPE_PLUMBUS, "foo"); final EntityIdWithType entityIdBar = DummyImplementation.of(ENTITY_TYPE_PLUMBUS, "bar"); assertThatIllegalArgumentException() .isThrownBy(() -> entityIdFoo.isCompatibleOrThrow(entityIdBar)) .withMessage("The entity ID <%s> is not compatible with <%s>!", entityIdBar, entityIdFoo) .withNoCause(); }