Added Code and iml file for Medical data faker

Contains following fakers
-- Hospital Name
-- Disease
-- Medicine
-- Symptoms
This commit is contained in:
Vikram
2018-09-24 10:55:51 +05:30
parent cc17b0a115
commit 6d64f8538b
4 changed files with 69 additions and 6 deletions
+11 -6
View File
@@ -82,6 +82,7 @@ public class Faker {
private final StarTrek starTrek;
private final Weather weather;
private final Lebowski lebowski;
private final Medical medical;
public Faker() {
this(Locale.ENGLISH);
@@ -165,6 +166,7 @@ public class Faker {
this.starTrek = new StarTrek(this);
this.weather = new Weather(this);
this.lebowski = new Lebowski(this);
this.medical = new Medical(this);
}
/**
@@ -549,21 +551,24 @@ public class Faker {
return lebowski;
}
public Medical medical(){return medical;}
public String resolve(String key) {
return this.fakeValuesService.resolve(key, this, this);
}
/**
* Allows the evaluation of native YML expressions to allow you to build your own.
*
* <p>
* The following are valid expressions:
* <ul>
* <li>#{regexify '(a|b){2,3}'}</li>
* <li>#{regexify '\\.\\*\\?\\+'}</li>
* <li>#{bothify '????','false'}</li>
* <li>#{Name.first_name} #{Name.first_name} #{Name.last_name}</li>
* <li>#{number.number_between '1','10'}</li>
* <li>#{regexify '(a|b){2,3}'}</li>
* <li>#{regexify '\\.\\*\\?\\+'}</li>
* <li>#{bothify '????','false'}</li>
* <li>#{Name.first_name} #{Name.first_name} #{Name.last_name}</li>
* <li>#{number.number_between '1','10'}</li>
* </ul>
*
* @param expression (see examples above)
* @return the evaluated string expression
* @throws RuntimeException if unable to evaluate the expression
@@ -0,0 +1,26 @@
package com.github.javafaker;
public class Medical {
private final Faker faker;
protected Medical(Faker faker) {
this.faker = faker;
}
public String medicineName() {
return faker.fakeValuesService().resolve("medical.medicine_name", this, faker);
}
public String diseaseName() {
return faker.fakeValuesService().resolve("medical.disease_name", this, faker);
}
public String hospitalName() {
return faker.fakeValuesService().resolve("medical.hospital_name", this, faker);
}
public String symptoms() {
return faker.fakeValuesService().resolve("medical.symptoms", this, faker);
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,27 @@
package com.github.javafaker;
import org.junit.Test;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;
public class MedicalTest extends AbstractFakerTest {
@Test
public void testMedicineName() {
assertThat(faker.medical().medicineName(), matchesRegularExpression("([\\w']+\\.?( )?){2,4}"));
}
@Test
public void testDiseaseName() {
assertThat(faker.medical().diseaseName(), matchesRegularExpression("([\\w']+\\.?( )?){2,4}"));
}
@Test
public void testHospitalName() {
assertThat(faker.medical().hospitalName(), matchesRegularExpression("([\\w']+\\.?( )?){2,4}"));
}
@Test
public void testSymptom() {
assertThat(faker.medical().symptoms(), matchesRegularExpression("([\\w']+\\.?( )?){2,4}"));
}
}