Skip to content

Commit

Permalink
Merge pull request #165 from Tahanima/feature/add-house-faker
Browse files Browse the repository at this point in the history
Added House Faker
  • Loading branch information
bodiam authored May 22, 2022
2 parents 323e5cc + 8b1094f commit 830c186
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 1 deletion.
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

0 comments on commit 830c186

Please sign in to comment.