Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
obaibula opened this issue Apr 11, 2023 · 0 comments
Open

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

obaibula opened this issue Apr 11, 2023 · 0 comments

Comments

@obaibula
Copy link

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)
...
@shryhus shryhus added this to To do in Java Fundamentals Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant