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

Added House Faker #165

Merged
merged 1 commit into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ Providers
* Hipster
* HitchhikersGuideToTheGalaxy
* Hobbit
* House
* HowIMetYourMother
* IdNumber
* Internet
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/datafaker/Faker.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ public Horse horse() {
return getProvider(Horse.class, () -> new Horse(this));
}

public House house() {
return getProvider(House.class, () -> new House(this));
}

public HowIMetYourMother howIMetYourMother() {
return getProvider(HowIMetYourMother.class, () -> new HowIMetYourMother(this));
}
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/net/datafaker/House.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.datafaker;

public class House {

private final Faker faker;

protected House(Faker faker) {
this.faker = faker;
}

/**
* This method generates a random name of furniture.
*
* @return a string of furniture.
*/
public String furniture() {
return faker.fakeValuesService().resolve("house.furniture", this, faker);
}

/**
* This method generates a random name of a room in a house.
*
* @return a string of room.
*/
public String room() {
return faker.fakeValuesService().resolve("house.rooms", this, faker);
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/datafaker/service/files/EnFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public String getPath() {
"hitchhikers_guide_to_the_galaxy.yml",
"hobbit.yml",
"hobby.yml",
// "house.yml",
"house.yml",
"how_i_met_your_mother.yml",
"id_number.yml",
// "industry_segments.yml",
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions src/test/java/net/datafaker/HouseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.datafaker;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class HouseTest extends AbstractFakerTest {

@Test
void testFurniture() {
assertThat(faker.house().furniture()).matches("^[a-zA-Z ]+$");
}

@Test
void testRoom() {
assertThat(faker.house().room()).matches("^[a-zA-Z ]+$");
}
}
1 change: 1 addition & 0 deletions src/test/java/net/datafaker/integration/FakerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.hipster());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.hitchhikersGuideToTheGalaxy());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.hobbit());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.house());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.howIMetYourMother());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.idNumber());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.internet());
Expand Down