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

Add MBTI feature #728

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 11 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<repoToken>${env.COVERALLS_TOKEN}</repoToken>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
Expand All @@ -148,5 +140,15 @@
</plugin>
</plugins>
</pluginManagement>
</build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
25 changes: 25 additions & 0 deletions src/main/java/com/github/javafaker/Faker.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class Faker {
private final RickAndMorty rickAndMorty;
private final Yoda yoda;
private final Matz matz;
private final Mbti mbti;
private final Witcher witcher;
private final DragonBall dragonBall;
private final FunnyName funnyName;
Expand Down Expand Up @@ -107,6 +108,7 @@ public class Faker {
private final Sip sip;
private final EnglandFootBall englandfootball;
private final Mountain mountain;
private final OscarMovie oscarMovie;

public Faker() {
this(Locale.ENGLISH);
Expand All @@ -128,6 +130,13 @@ public Faker(Locale locale, RandomService randomService) {
this(new FakeValuesService(locale, randomService), randomService);
}

/**
* add oscarmovie and mbti
* @param fakeValuesService
* @param random
*/
//CS304 Issue link: https://github.com/DiUS/java-faker/issues/712
//CS304 Isuue link: https://github.com/DiUS/java-faker/issues/726
public Faker(FakeValuesService fakeValuesService, RandomService random) {
this.randomService = random;
this.fakeValuesService = fakeValuesService;
Expand Down Expand Up @@ -181,6 +190,8 @@ public Faker(FakeValuesService fakeValuesService, RandomService random) {
this.lordOfTheRings = new LordOfTheRings(this);
this.zelda = new Zelda(this);
this.harryPotter = new HarryPotter(this);
this.mbti = new Mbti(this);
this.oscarMovie = new OscarMovie(this);
this.rockBand = new RockBand(this);
this.esports = new Esports(this);
this.friends = new Friends(this);
Expand Down Expand Up @@ -541,6 +552,13 @@ public HarryPotter harryPotter() {
return harryPotter;
}

/**
* add mbti object
* @return mbti
*/
//CS304 Isuue link: https://github.com/DiUS/java-faker/issues/726
public Mbti mbti(){return mbti;}

public RockBand rockBand() {
return rockBand;
}
Expand Down Expand Up @@ -629,6 +647,13 @@ public Medical medical() {
return medical;
}

/**
* initialize oscarmovie object
* @return oscarmovie object
*/
//CS304 Issue link: https://github.com/DiUS/java-faker/issues/712
public OscarMovie oscarMovie() {return oscarMovie;}

public Country country() {
return country;
}
Expand Down
62 changes: 62 additions & 0 deletions src/main/java/com/github/javafaker/Mbti.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//CS304 Issue link: https://github.com/DiUS/java-faker/issues/726
package com.github.javafaker;

public class Mbti {
private final Faker faker;
private final String choice;

/**
* initialize faker and chioce which means he which movie to choose during the same year
* @param faker
*/
public Mbti(final Faker faker) {
this.faker = faker;
choice = faker.resolve("mbti.choice");
}

/***
* The method is to randomly generate type of MBTI
* @return type of MBTI
*/
public String type() {
return faker.resolve("mbti.".concat(choice).concat(".type"));
}

/**
* The method is to randomly generate name of the same MBTI
* @return name of the same MBTI
*/
public String name() {
return faker.resolve("mbti.".concat(choice).concat(".name"));
}

/**
* The method is to generate characteristic of the same MBTI
* @return characteristic of the same MBTI
*/
public String characteristic() {
return faker.resolve("mbti.".concat(choice).concat(".characteristic"));
}

/**
* The method is to generate personage of the same MBTI
* @return personage of the same MBTI
*/
public String personage() {
return faker.resolve("mbti.".concat(choice).concat(".personage"));
}

/**
* The method is to generate merit of the same MBTI
* @return merit of the same MBTI
*/
public String merit(){return faker.resolve("mbti.".concat(choice).concat(".merit"));}

/**
* The method is to generate weakness of the same MBTI
* @return weakness of the same MBTI
*/
public String weakness(){return faker.resolve("mbti.".concat(choice).concat(".weakness"));}


}
97 changes: 97 additions & 0 deletions src/main/java/com/github/javafaker/OscarMovie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//CS304 issue: https://github.com/DiUS/java-faker/issues/712
package com.github.javafaker;

/**
* This is the class generates random stream of Movie
* @author ak-maker
* */
public class OscarMovie {
/**
* The faker instance for generating random names of things.
*/
private final Faker faker;
/**
* The year instance is used for randomly choose the year (from 2013 to 2022)
*/
private final String year;
/**
* The choice instance eis used for randomly choose the the
* first/second/third movie of that year.
*/
private final String choice;
/**
* Part of the string to reslove
*/
private final String str;
/**
* This is the constructor initialize faker and two other
* variable for random generation.
* @param faker faker The Faker instance for generating random names of things.
*/
protected OscarMovie(final Faker faker) {
this.faker = faker;
this.year = this.faker.resolve("oscarmovie.year.years");
this.choice = this.faker.resolve("oscarmovie.year.choice");
this.str = "oscarmovie.".concat(year).concat(".").concat(choice);
}

/**
* @return year
*/
public String getYear(){
return year;
}

/**
* @return choice
*/
public String getChoice(){
return choice;
}

/**
* @return str
*/
public String getStr(){
return str;
}

/**
* This method generates random actor
* @return random actor from OscarMovie.yml
*/
public String actor() {
return faker.resolve(str.concat(".actor"));
}

/**
* This method generates random movieName
* @return random movieName from OscarMovie.yml
*/
public String movieName() {
return faker.resolve(str.concat(".movieName"));
}

/**
* This method generates random quote
* @return random quote from OscarMovie.yml
*/
public String quote() {
return faker.resolve(str.concat(".quote"));
}
/**
* This method generates random character
* @return random character from OscarMovie.yml
*/
public String character() {
return faker.resolve(str.concat(".character"));
}

/**
* This method enerates random releaseDate
* @return random releaseDate from OscarMovie.yml
*/
public String releaseDate() {
return faker.resolve(str.concat(".releaseDate"));
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/github/javafaker/service/files/EnFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public String getPath() {
"markdown.yml",
"marketing.yml",
"matz.yml",
"mbti.yml",
"measurement.yml",
"medical.yml",
"michael_scott.yml",
Expand All @@ -129,6 +130,7 @@ public String getPath() {
"new_girl.yml",
"one_piece.yml",
"overwatch.yml",
"oscarmovie.yml",
"parks_and_rec.yml",
"phish.yml",
"phone_number.yml",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/en-NZ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ en-NZ:

team:
sport: [basketball, football, rugby league, netball, rugby union, hockey, cricket, golf, boxing, rowing, motorsport, tennis, athletics, sailing, surf life saving, squash]
name: [Tall Blacks, All Whites, Warriors, Silver Ferns, All Blacks, Black Sticks, Black Caps]
name: [Tall Blacks, All Whites, Warriors, Silver Ferns, All Blacks, Black Sticks, Black Caps]
Loading