Skip to content

1-3-1-crazy-generics, hasDuplicates' test accepts the broken code #169

Open
@obaibula

Description

@obaibula

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)
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions