Skip to content

Commit

Permalink
Merge ced1462 into 1850b03
Browse files Browse the repository at this point in the history
  • Loading branch information
bianzheng123 committed May 28, 2020
2 parents 1850b03 + ced1462 commit b25de50
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Fakers
* Crypto
* DateAndTime
* Demographic
* Disease
* Dog
* DragonBall
* Dune
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/github/javafaker/Disease.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.github.javafaker;


/**
* @author LinZhiyuan bianzheng
* */
public class Disease{
private final Faker faker;

protected Disease(final Faker faker) {
this.faker = faker;
}
/**
* Generate a random type of disease
* @return random type of disease
* */
public String type(){
return faker.fakeValuesService().resolve("disease.type",this,faker);
}


}
6 changes: 6 additions & 0 deletions src/main/java/com/github/javafaker/Faker.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class Faker {
private final GameOfThrones gameOfThrones;
private final DateAndTime dateAndTime;
private final Demographic demographic;
private final Disease disease;
private final Dog dog;
private final Educator educator;
private final ElderScrolls elderScrolls;
Expand Down Expand Up @@ -203,6 +204,7 @@ public Faker(FakeValuesService fakeValuesService, RandomService random) {
this.aquaTeenHungerForce = new AquaTeenHungerForce(this);
this.programmingLanguage = new ProgrammingLanguage(this);
this.kaamelott = new Kaamelott(this);
this.disease = new Disease(this);
}

/**
Expand Down Expand Up @@ -463,6 +465,10 @@ public Dog dog() {
return dog;
}

public Disease disease(){
return disease;
}

public Educator educator() {
return educator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public String getPath() {
"demographic.yml",
"dessert.yml",
"device.yml",
"disease.yml",
"dota.yml",
"dr_who.yml",
"dragon_ball.yml",
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/en/disease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
faker:
disease:
type: ["Acquired disease", "Acute disease", "Chronic condition or chronic disease", "Congenital disorder or congenital disease","Genetic disease", "Hereditary or inherited disease", "Iatrogenic disease", "Idiopathic disease", "Incurable disease", "Primary disease", "Secondary disease", "Terminal disease", "Illness", "Disorder", "Predisease"]
18 changes: 18 additions & 0 deletions src/test/java/com/github/javafaker/DiseaseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.github.javafaker;

import org.junit.Test;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;

/**
* @author LinZhiyuan bianzheng
* the test that generate valid disease types
* */
public class DiseaseTest extends AbstractFakerTest {
@Test
public void testTypes(){
assertThat(faker.disease().type(),matchesRegularExpression("[A-Za-z ]+"));
assertThat(faker.disease().type(),matchesRegularExpression("[A-Za-z'() 0-9-]+"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public void testAllFakerMethodsThatReturnStrings() throws Exception {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.aquaTeenHungerForce());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.programmingLanguage());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.kaamelott());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.disease());
}

private void testAllMethodsThatReturnStringsActuallyReturnStrings(Object object) throws Exception {
Expand Down

0 comments on commit b25de50

Please sign in to comment.