### Question:
DuplicateEntityIdConfigValidator { public void validate(Collection<? extends EntityIdentifiable> configDataCollection) { Set<String> knownEntityIds = new HashSet<>(configDataCollection.size()); for (EntityIdentifiable datum : configDataCollection) { String entityId = datum.getEntityId(); if (knownEntityIds.contains(entityId)) { throw ConfigValidationException.createDuplicateEntityIdException(entityId); } knownEntityIds.add(entityId); } }  void validate(Collection<? extends EntityIdentifiable> configDataCollection);  }### Answer:
@Test public void validate_shouldThrowExceptionIfTwoEntitiesHaveSameEntityId() throws Exception { String entityId = "transaction-entity-id"; Collection<EntityIdentifiable> configs = new ArrayList<>(); configs.add(aTransactionConfigData().withEntityId(entityId).build()); configs.add(anIdentityProviderConfigData().withEntityId(entityId).build()); try { this.validator.validate(configs); fail("fail"); } catch (ConfigValidationException e) { assertThat(e.getMessage()).isEqualTo(ConfigValidationException.createDuplicateEntityIdException(entityId).getMessage()); } }