add Space (#165)

This commit is contained in:
Pascal Schumacher
2016-11-17 22:31:54 +01:00
committed by Ricky Yim
parent 6315478306
commit 5ee72af8aa
5 changed files with 135 additions and 0 deletions
+1
View File
@@ -95,6 +95,7 @@ Fakers
* Options
* PhoneNumber
* Shakespeare
* Space
* Superhero
* Team
* University
@@ -41,6 +41,7 @@ public class Faker {
private final DateAndTime dateAndTime;
private final Educator educator;
private final Shakespeare shakespeare;
private final Space space;
private final Superhero superhero;
private final Bool bool;
private final Team team;
@@ -91,6 +92,7 @@ public class Faker {
this.dateAndTime = new DateAndTime(this);
this.educator = new Educator(this);
this.shakespeare = new Shakespeare(this);
this.space = new Space(this);
this.superhero = new Superhero(this);
this.team = new Team(this);
this.bool = new Bool(this);
@@ -280,6 +282,10 @@ public class Faker {
return shakespeare;
}
public Space space() {
return space;
}
public Superhero superhero() {
return superhero;
}
@@ -0,0 +1,58 @@
package com.github.javafaker;
public class Space {
private final Faker faker;
Space(Faker faker) {
this.faker = faker;
}
public String planet() {
return faker.resolve("space.planet");
}
public String moon() {
return faker.resolve("space.moon");
}
public String galaxy() {
return faker.resolve("space.galaxy");
}
public String nebula() {
return faker.resolve("space.nebula");
}
public String starCluster() {
return faker.resolve("space.star_cluster");
}
public String constellation() {
return faker.resolve("space.constellation");
}
public String star() {
return faker.resolve("space.star");
}
public String agency() {
return faker.resolve("space.agency");
}
public String agencyAbbreviation() {
return faker.resolve("space.agency_abv");
}
public String nasaSpaceCraft() {
return faker.resolve("space.nasa_space_craft");
}
public String company() {
return faker.resolve("space.company");
}
public String distanceMeasurement() {
return faker.number().numberBetween(10, 100) + ' ' + faker.resolve("space.distance_measurement");
}
}
@@ -0,0 +1,69 @@
package com.github.javafaker;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class SpaceTest extends AbstractFakerTest {
@Test
public void testPlanet() {
assertThat(faker.space().planet(), matchesRegularExpression("(\\w+ ?){2,3}"));
}
@Test
public void testMoon() {
assertThat(faker.space().moon(), matchesRegularExpression("(\\w+ ?){2,3}"));
}
@Test
public void testGalaxy() {
assertThat(faker.space().galaxy(), matchesRegularExpression("(\\w+ ?){2,3}"));
}
@Test
public void testNebula() {
assertThat(faker.space().nebula(), matchesRegularExpression("(\\w+ ?){2,3}"));
}
@Test
public void testStarCluster() {
assertThat(faker.space().starCluster(), matchesRegularExpression("(\\w+[ -]?){1,3}"));
}
@Test
public void testConstellation() {
assertThat(faker.space().constellation(), matchesRegularExpression("(\\w+ ?){2,3}"));
}
@Test
public void testStar() {
assertThat(faker.space().star(), matchesRegularExpression("(\\w+[ -]?){2,3}"));
}
@Test
public void testAgency() {
assertThat(faker.space().agency(), matchesRegularExpression("(\\w+ ?){2,5}"));
}
@Test
public void testAgencyAbbreviation() {
assertThat(faker.space().agencyAbbreviation(), matchesRegularExpression("(\\w+ ?){2,3}"));
}
@Test
public void testNasaSpaceCraft() {
assertThat(faker.space().nasaSpaceCraft(), matchesRegularExpression("(\\w+ ?){2,3}"));
}
@Test
public void testCompany() {
assertThat(faker.space().company(), matchesRegularExpression("(\\w+ ?){2,4}"));
}
@Test
public void testDistanceMeasurement() {
assertThat(faker.space().distanceMeasurement(), matchesRegularExpression("(\\w+ ?){2,3}"));
}
}
@@ -114,6 +114,7 @@ public class FakerIT {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.hacker());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.idNumber());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.shakespeare());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.space());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.superhero());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.team());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.beer());