Skip to content

OscarMovie should store rules to access data but not the actual field names #742

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

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

snuyanzin
Copy link
Collaborator

The issue is that OscarMovie stores field names in year, choice, str which are used to find out the next result.
Providers should not do that, so just replace it with suppliers storing only the rules how to get such data but not the actual field names

fixes #741

@what-the-diff
Copy link

what-the-diff bot commented Mar 29, 2023

PR Summary

  • ♻️ Refactored OscarMovie class
    The OscarMovie class now uses Supplier instead of String for better code design.
  • New test case for issue741
    A new test checks that methods return different values, ensuring proper functionality.

@codecov-commenter
Copy link

Codecov Report

Merging #742 (1e4bb71) into main (f8a82f1) will not change coverage.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff            @@
##               main     #742   +/-   ##
=========================================
  Coverage     92.82%   92.82%           
- Complexity     2586     2589    +3     
=========================================
  Files           281      281           
  Lines          5126     5126           
  Branches        530      530           
=========================================
  Hits           4758     4758           
  Misses          239      239           
  Partials        129      129           
Impacted Files Coverage Δ
.../datafaker/providers/entertainment/OscarMovie.java 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

faker.stream(() -> f.apply(oscarMovie)).len(10).build()
.<Stream<?>>get().collect(Collectors.toSet()))
.hasSizeGreaterThan(1);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really test that the values aren't consistent, just that something is generated. (Or I'm missing something?)

Copy link
Collaborator Author

@snuyanzin snuyanzin Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem was that it generated same values for a series of invocations like

    Faker faker = new Faker();

   String movie1 = faker.oscarMovie().movieName();
   String movie2 = faker.oscarMovie().movieName();
   String movie3 = faker.oscarMovie().movieName();

before that fix it generates same values for all 3 vars.

So the test checks that the generated value are not same after 10 times of invocations

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry missed it was collecting to set which would mean unique entries. Tks

@kingthorin kingthorin merged commit d1992a1 into datafaker-net:main Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data provider Oscar Movie doesn't generate new values on each iteration
3 participants