-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Baseball provider * Change order of SportProviders method in alphabetical ascending order * Change Version number to 1.7.0 Co-authored-by: Ji Myoung Ha <NoPlayer40600@gmail.com>
- Loading branch information
Showing
6 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package net.datafaker.providers.sport; | ||
|
||
import net.datafaker.providers.base.AbstractProvider; | ||
|
||
/** | ||
* Generate random components of baseball game, e.g. teams, coaches, positions and players. | ||
* | ||
* @since 1.7.0 | ||
*/ | ||
public class Baseball extends AbstractProvider<SportProviders> { | ||
|
||
/** | ||
Baseball | ||
* Create a constructor for Baseball. | ||
* | ||
* @param faker The Faker instance for generating random, different kinds of disease, e.g. the internal disease. | ||
*/ | ||
protected Baseball(SportProviders faker) { | ||
super(faker); | ||
} | ||
|
||
/** | ||
* Generate random Baseball teams | ||
* | ||
* @return Baseball teams | ||
*/ | ||
public String teams() { | ||
return resolve("baseball.teams"); | ||
} | ||
|
||
/** | ||
* Generate random coaches in baseball game | ||
* | ||
* @return Baseball coaches | ||
*/ | ||
public String coaches() { | ||
return resolve("baseball.coaches"); | ||
} | ||
|
||
/** | ||
* Generate random positions in baseball game | ||
* | ||
* @return Baseball positions | ||
*/ | ||
public String positions() { | ||
return resolve("baseball.positions"); | ||
} | ||
|
||
/** | ||
* Generate random baseball players | ||
* | ||
* @return Baseball players | ||
*/ | ||
public String players() { | ||
return resolve("baseball.players"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
en: | ||
faker: | ||
baseball: | ||
teams: | ||
- Boston Red Sox | ||
- Los Angeles Angels | ||
- Los Angeles Dodgers | ||
- New York Yankees | ||
- Detroit Tigers | ||
- New York Mets | ||
|
||
players: | ||
- Bobby Doerr | ||
- Joe Cronin | ||
- Pesky Paveskovich | ||
- Carl Yastrzemski | ||
- Carlton Fisk | ||
- Billy Martin | ||
- Derek Jeter | ||
- Babe Ruth | ||
- Lou Gehrig | ||
- Joe DiMaggio | ||
- Joe Torre | ||
- Mickey Mantle | ||
- Bill Dickey | ||
- Yogi Berra | ||
- Roger Maris | ||
|
||
coaches: | ||
- Aaron Boone | ||
- Brian Snitker | ||
- Dave Roberts | ||
- Alex Cora | ||
- A.J. Hinch | ||
- Brandon Hyde | ||
- Torey Lovullo | ||
|
||
positions: | ||
- Pitcher | ||
- Catcher | ||
- First Baseman | ||
- Second Baseman | ||
- Third Baseman | ||
- Short Stop | ||
- Left Fielder | ||
- Center Fielder | ||
- Right Fielder | ||
- Designated Hitter | ||
- Pinch Hitter | ||
- Pinch Runner |
28 changes: 28 additions & 0 deletions
28
src/test/java/net/datafaker/providers/sport/BaseballTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package net.datafaker.providers.sport; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class BaseballTest extends SportFakerTest { | ||
|
||
@Test | ||
void testTeams() { | ||
assertThat(faker.baseball().teams()).matches("[\\p{L}'()., 0-9-’]+"); | ||
} | ||
|
||
@Test | ||
void testCoaches() { | ||
assertThat(faker.baseball().coaches()).matches("[\\p{L}'()., 0-9-’]+"); | ||
} | ||
|
||
@Test | ||
void testPositions() { | ||
assertThat(faker.baseball().positions()).matches("[\\p{L}'()., 0-9-’]+"); | ||
} | ||
|
||
@Test | ||
void testPlayers() { | ||
assertThat(faker.baseball().players()).matches("[\\p{L}'()., 0-9-’]+"); | ||
} | ||
} |