The broken code:
public static <T extends BaseEntity> boolean hasDuplicates(List<T> entities, T targetEntity) {
return entities.stream()
.map(BaseEntity::getUuid)
.distinct()
.count() != entities.size();
}
This code doesn't check if the target entity is in the list, so we need to add something like this to the tests to ensure that the target entity is in the list:
...
arguments(List.of(uniqueEntity, uniqueEntity, uniqueEntity), duplicateEntity1, false)
...